(parent, x0, y0, x1, y1)
| 14223 | } |
| 14224 | |
| 14225 | function binary(parent, x0, y0, x1, y1) { |
| 14226 | var nodes = parent.children, |
| 14227 | i, n = nodes.length, |
| 14228 | sum, sums = new Array(n + 1); |
| 14229 | |
| 14230 | for (sums[0] = sum = i = 0; i < n; ++i) { |
| 14231 | sums[i + 1] = sum += nodes[i].value; |
| 14232 | } |
| 14233 | |
| 14234 | partition(0, n, parent.value, x0, y0, x1, y1); |
| 14235 | |
| 14236 | function partition(i, j, value, x0, y0, x1, y1) { |
| 14237 | if (i >= j - 1) { |
| 14238 | var node = nodes[i]; |
| 14239 | node.x0 = x0, node.y0 = y0; |
| 14240 | node.x1 = x1, node.y1 = y1; |
| 14241 | return; |
| 14242 | } |
| 14243 | |
| 14244 | var valueOffset = sums[i], |
| 14245 | valueTarget = (value / 2) + valueOffset, |
| 14246 | k = i + 1, |
| 14247 | hi = j - 1; |
| 14248 | |
| 14249 | while (k < hi) { |
| 14250 | var mid = k + hi >>> 1; |
| 14251 | if (sums[mid] < valueTarget) k = mid + 1; |
| 14252 | else hi = mid; |
| 14253 | } |
| 14254 | |
| 14255 | if ((valueTarget - sums[k - 1]) < (sums[k] - valueTarget) && i + 1 < k) --k; |
| 14256 | |
| 14257 | var valueLeft = sums[k] - valueOffset, |
| 14258 | valueRight = value - valueLeft; |
| 14259 | |
| 14260 | if ((x1 - x0) > (y1 - y0)) { |
| 14261 | var xk = value ? (x0 * valueRight + x1 * valueLeft) / value : x1; |
| 14262 | partition(i, k, valueLeft, x0, y0, xk, y1); |
| 14263 | partition(k, j, valueRight, xk, y0, x1, y1); |
| 14264 | } else { |
| 14265 | var yk = value ? (y0 * valueRight + y1 * valueLeft) / value : y1; |
| 14266 | partition(i, k, valueLeft, x0, y0, x1, yk); |
| 14267 | partition(k, j, valueRight, x0, yk, x1, y1); |
| 14268 | } |
| 14269 | } |
| 14270 | } |
| 14271 | |
| 14272 | function sliceDice(parent, x0, y0, x1, y1) { |
| 14273 | (parent.depth & 1 ? treemapSlice : treemapDice)(parent, x0, y0, x1, y1); |
nothing calls this directly
no test coverage detected