This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <svg :width="width" :height="height"> | |
| <g v-for="rectangle in rectangles" fill="grey"> | |
| <rect | |
| :x=rectangle[0] | |
| :y=rectangle[1] | |
| :width=rectangle[2] | |
| :height=rectangle[3] | |
| style="stroke-width:1;stroke:white"/> | |
| <text | |
| :x="rectangle[0] + rectangle[2] / 2" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function squarify (children, row, width) { | |
| if (children.length === 1) { | |
| layoutLastRow(row, children, width) | |
| return | |
| } | |
| const rowWithChild = [...row, children[0]] | |
| if (row.length === 0 || worst(row, width) >= worst(rowWithChild, width)) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <svg width="600" height="400"> | |
| <rect x="0" y="0" width="300" height="200"/> | |
| <rect x="0" y="200" width="300" height="200"/> | |
| </svg> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| procedure squarify(list of real children, list of real row,real w) | |
| begin | |
| real c = head(children); | |
| if worst(row, w) ≤ worst(row++[c], w) then | |
| squarify(tail(children), row++[c], w) | |
| else | |
| layoutrow(row); | |
| squarify(children, [], width()); | |
| fi | |
| end |