| 125 | }); |
| 126 | |
| 127 | var getTextWidth = function(node) { |
| 128 | var text = (node.data.label !== undefined) ? node.data.label : node.id; |
| 129 | if (node._width && node._width[text]) |
| 130 | return node._width[text]; |
| 131 | |
| 132 | ctx.save(); |
| 133 | ctx.font = (node.data.font !== undefined) ? node.data.font : nodeFont; |
| 134 | var width = ctx.measureText(text).width; |
| 135 | ctx.restore(); |
| 136 | |
| 137 | node._width || (node._width = {}); |
| 138 | node._width[text] = width; |
| 139 | |
| 140 | return width; |
| 141 | }; |
| 142 | |
| 143 | var getTextHeight = function(node) { |
| 144 | return 16; |