Permalink
Browse files

Merge branch 'release'

  • Loading branch information...
2 parents a40876c + a8558d9 commit 6a9eda0b57b0ed30bccdb40d7f360f33682137a1 @mbostock mbostock committed Jul 20, 2011
Showing with 2,896 additions and 166 deletions.
  1. +73 −38 Makefile
  2. +2 −2 d3.js
  3. +55 −15 d3.layout.js
  4. +1 −1 d3.layout.min.js
  5. +1 −1 d3.min.js
  6. +249 −0 d3.time.js
  7. +1 −1 d3.time.min.js
  8. +22 −0 examples/treemap/treemap-svg.html
  9. +34 −0 examples/treemap/treemap-svg.js
  10. +1 −0 examples/treemap/treemap.js
  11. +1 −1 src/core/core.js
  12. +1 −1 src/layout/histogram.js
  13. +54 −14 src/layout/treemap.js
  14. +1 −1 src/scale/linear.js
  15. +7 −0 src/time/day.js
  16. +7 −0 src/time/days.js
  17. +8 −0 src/time/hour.js
  18. +6 −0 src/time/hours.js
  19. +5 −0 src/time/minute.js
  20. +5 −0 src/time/minutes.js
  21. +7 −0 src/time/month.js
  22. +7 −0 src/time/months.js
  23. +8 −0 src/time/range.js
  24. +36 −0 src/time/scale-utc.js
  25. +115 −0 src/time/scale.js
  26. +5 −0 src/time/second.js
  27. +5 −0 src/time/seconds.js
  28. +9 −0 src/time/week.js
  29. +7 −0 src/time/weeks.js
  30. +7 −0 src/time/year.js
  31. +7 −0 src/time/years.js
  32. 0 {tests → test}/barley.json
  33. +3 −3 {tests → test/core}/test-append.js
  34. 0 {tests → test/core}/test-append.out
  35. +3 −3 {tests → test/core}/test-attr.js
  36. 0 {tests → test/core}/test-attr.out
  37. +2 −2 {tests → test/core}/test-bisect.js
  38. 0 {tests → test/core}/test-bisect.out
  39. +3 −3 {tests → test/core}/test-call.js
  40. 0 {tests → test/core}/test-call.out
  41. +3 −3 {tests → test/core}/test-classed.js
  42. 0 {tests → test/core}/test-classed.out
  43. +2 −2 {tests → test/core}/test-format.js
  44. 0 {tests → test/core}/test-format.out
  45. +2 −2 {tests → test/core}/test-hsl.js
  46. 0 {tests → test/core}/test-hsl.out
  47. +3 −3 {tests → test/core}/test-insert.js
  48. 0 {tests → test/core}/test-insert.out
  49. +2 −2 {tests → test/core}/test-interpolate.js
  50. 0 {tests → test/core}/test-interpolate.out
  51. +2 −2 {tests → test/core}/test-keys.js
  52. 0 {tests → test/core}/test-keys.out
  53. +2 −2 {tests → test/core}/test-max.js
  54. 0 {tests → test/core}/test-max.out
  55. +2 −2 {tests → test/core}/test-min.js
  56. 0 {tests → test/core}/test-min.out
  57. +3 −3 {tests → test/core}/test-nest.js
  58. 0 {tests → test/core}/test-nest.out
  59. +2 −2 {tests → test/core}/test-permute.js
  60. 0 {tests → test/core}/test-permute.out
  61. +3 −3 {tests → test/core}/test-remove.js
  62. 0 {tests → test/core}/test-remove.out
  63. +2 −2 {tests → test/core}/test-rgb.js
  64. 0 {tests → test/core}/test-rgb.out
  65. +2 −2 {tests → test/core}/test-round.js
  66. 0 {tests → test/core}/test-round.out
  67. +2 −2 {tests → test/core}/test-sum.js
  68. 0 {tests → test/core}/test-sum.out
  69. +3 −3 {tests → test/core}/test-transition.js
  70. 0 {tests → test/core}/test-transition.out
  71. +2 −2 {tests → test/core}/test-zip.js
  72. 0 {tests → test/core}/test-zip.out
  73. +3 −3 tests/test-csv-parse.js → test/csv/test-parse.js
  74. 0 tests/test-csv-parse.out → test/csv/test-parse.out
  75. +29 −0 test/layout/test-histogram.js
  76. +12 −0 test/layout/test-histogram.out
  77. +65 −0 test/layout/test-treemap.js
  78. +43 −0 test/layout/test-treemap.out
  79. +2 −2 tests/test-scale-linear.js → test/scale/test-linear.js
  80. 0 tests/test-scale-linear.out → test/scale/test-linear.out
  81. +2 −2 tests/test-scale-log.js → test/scale/test-log.js
  82. 0 tests/test-scale-log.out → test/scale/test-log.out
  83. +2 −2 tests/test-scale-polylinear.js → test/scale/test-polylinear.js
  84. 0 tests/test-scale-polylinear.out → test/scale/test-polylinear.out
  85. +2 −2 tests/test-scale-pow.js → test/scale/test-pow.js
  86. 0 tests/test-scale-pow.out → test/scale/test-pow.out
  87. +2 −2 tests/test-scale-quantile.js → test/scale/test-quantile.js
  88. 0 tests/test-scale-quantile.out → test/scale/test-quantile.out
  89. +3 −3 tests/test-scale-sqrt.js → test/scale/test-sqrt.js
  90. 0 tests/test-scale-sqrt.out → test/scale/test-sqrt.out
  91. +2 −2 tests/test-svg-arc.js → test/svg/test-arc.js
  92. 0 tests/test-svg-arc.out → test/svg/test-arc.out
  93. +2 −2 tests/test-svg-area.js → test/svg/test-area.js
  94. 0 tests/test-svg-area.out → test/svg/test-area.out
  95. +3 −3 tests/test-svg-line.js → test/svg/test-line.js
  96. 0 tests/test-svg-line.out → test/svg/test-line.out
  97. +2 −2 tests/test-svg-symbol.js → test/svg/test-symbol.js
  98. 0 tests/test-svg-symbol.out → test/svg/test-symbol.out
  99. +22 −0 test/time/test-day.js
  100. +14 −0 test/time/test-day.out
  101. +26 −0 test/time/test-days.js
  102. +20 −0 test/time/test-days.out
  103. +3 −3 tests/test-time-format-iso.js → test/time/test-format-iso.js
  104. 0 tests/test-time-format-iso.out → test/time/test-format-iso.out
  105. +3 −3 tests/test-time-format-utc.js → test/time/test-format-utc.js
  106. 0 tests/test-time-format-utc.out → test/time/test-format-utc.out
  107. +3 −3 tests/test-time-format.js → test/time/test-format.js
  108. 0 tests/test-time-format.out → test/time/test-format.out
  109. +65 −0 test/time/test-hour.js
  110. +48 −0 test/time/test-hour.out
  111. +26 −0 test/time/test-hours.js
  112. +24 −0 test/time/test-hours.out
  113. +20 −0 test/time/test-minute.js
  114. +12 −0 test/time/test-minute.out
  115. +22 −0 test/time/test-minutes.js
  116. +18 −0 test/time/test-minutes.out
  117. +22 −0 test/time/test-month.js
  118. +14 −0 test/time/test-month.out
  119. +26 −0 test/time/test-months.js
  120. +20 −0 test/time/test-months.out
  121. +3 −3 tests/test-time-parse-iso.js → test/time/test-parse-iso.js
  122. 0 tests/test-time-parse-iso.out → test/time/test-parse-iso.out
  123. +3 −3 tests/test-time-parse-utc.js → test/time/test-parse-utc.js
  124. 0 tests/test-time-parse-utc.out → test/time/test-parse-utc.out
  125. +3 −3 tests/test-time-parse.js → test/time/test-parse.js
  126. 0 tests/test-time-parse.out → test/time/test-parse.out
  127. +170 −0 test/time/test-scale-utc.js
  128. +465 −0 test/time/test-scale-utc.out
  129. +166 −0 test/time/test-scale.js
  130. +469 −0 test/time/test-scale.out
  131. +22 −0 test/time/test-second.js
  132. +14 −0 test/time/test-second.out
  133. +22 −0 test/time/test-seconds.js
  134. +18 −0 test/time/test-seconds.out
  135. +22 −0 test/time/test-week.js
  136. +14 −0 test/time/test-week.out
  137. +26 −0 test/time/test-weeks.js
  138. +20 −0 test/time/test-weeks.out
  139. +22 −0 test/time/test-year.js
  140. +14 −0 test/time/test-year.out
  141. +26 −0 test/time/test-years.js
  142. +20 −0 test/time/test-years.out
View
111 Makefile
@@ -156,6 +156,23 @@ d3.time.js: \
src/time/format.js \
src/time/format-utc.js \
src/time/format-iso.js \
+ src/time/range.js \
+ src/time/second.js \
+ src/time/seconds.js \
+ src/time/minute.js \
+ src/time/minutes.js \
+ src/time/hour.js \
+ src/time/hours.js \
+ src/time/day.js \
+ src/time/days.js \
+ src/time/week.js \
+ src/time/weeks.js \
+ src/time/month.js \
+ src/time/months.js \
+ src/time/year.js \
+ src/time/years.js \
+ src/time/scale.js \
+ src/time/scale-utc.js \
src/end.js
d3.geom.js: \
@@ -169,44 +186,62 @@ d3.geom.js: \
src/geom/quadtree.js \
src/end.js
-tests: \
- tests/test-append.test \
- tests/test-attr.test \
- tests/test-classed.test \
- tests/test-call.test \
- tests/test-csv-parse.test \
- tests/test-format.test \
- tests/test-insert.test \
- tests/test-interpolate.test \
- tests/test-keys.test \
- tests/test-max.test \
- tests/test-min.test \
- tests/test-sum.test \
- tests/test-nest.test \
- tests/test-permute.test \
- tests/test-zip.test \
- tests/test-remove.test \
- tests/test-rgb.test \
- tests/test-round.test \
- tests/test-hsl.test \
- tests/test-time-format.test \
- tests/test-time-format-iso.test \
- tests/test-time-format-utc.test \
- tests/test-time-parse.test \
- tests/test-time-parse-iso.test \
- tests/test-time-parse-utc.test \
- tests/test-transition.test \
- tests/test-scale-linear.test \
- tests/test-scale-polylinear.test \
- tests/test-scale-log.test \
- tests/test-scale-sqrt.test \
- tests/test-scale-pow.test \
- tests/test-scale-quantile.test \
- tests/test-bisect.test \
- tests/test-svg-arc.test \
- tests/test-svg-area.test \
- tests/test-svg-line.test \
- tests/test-svg-symbol.test
+test: \
+ test/core/test-append.test \
+ test/core/test-attr.test \
+ test/core/test-bisect.test \
+ test/core/test-call.test \
+ test/core/test-classed.test \
+ test/core/test-format.test \
+ test/core/test-hsl.test \
+ test/core/test-insert.test \
+ test/core/test-interpolate.test \
+ test/core/test-keys.test \
+ test/core/test-max.test \
+ test/core/test-min.test \
+ test/core/test-nest.test \
+ test/core/test-permute.test \
+ test/core/test-remove.test \
+ test/core/test-rgb.test \
+ test/core/test-round.test \
+ test/core/test-sum.test \
+ test/core/test-transition.test \
+ test/core/test-zip.test \
+ test/csv/test-parse.test \
+ test/layout/test-histogram.test \
+ test/layout/test-treemap.test \
+ test/scale/test-linear.test \
+ test/scale/test-log.test \
+ test/scale/test-polylinear.test \
+ test/scale/test-pow.test \
+ test/scale/test-quantile.test \
+ test/scale/test-sqrt.test \
+ test/svg/test-arc.test \
+ test/svg/test-area.test \
+ test/svg/test-line.test \
+ test/svg/test-symbol.test \
+ test/time/test-day.test \
+ test/time/test-days.test \
+ test/time/test-format-iso.test \
+ test/time/test-format-utc.test \
+ test/time/test-format.test \
+ test/time/test-hour.test \
+ test/time/test-hours.test \
+ test/time/test-minute.test \
+ test/time/test-minutes.test \
+ test/time/test-month.test \
+ test/time/test-months.test \
+ test/time/test-parse-iso.test \
+ test/time/test-parse-utc.test \
+ test/time/test-parse.test \
+ test/time/test-scale.test \
+ test/time/test-scale-utc.test \
+ test/time/test-second.test \
+ test/time/test-seconds.test \
+ test/time/test-week.test \
+ test/time/test-weeks.test \
+ test/time/test-year.test \
+ test/time/test-years.test
%.min.js: %.js Makefile
@rm -f $@
View
4 d3.js
@@ -1,4 +1,4 @@
-(function(){d3 = {version: "1.27.2"}; // semver
+(function(){d3 = {version: "1.28.0"}; // semver
if (!Date.now) Date.now = function() {
return +new Date;
};
@@ -2280,7 +2280,7 @@ function d3_scale_linearRebind(scale, linear) {
scale.interpolate = d3.rebind(scale, linear.interpolate);
scale.clamp = d3.rebind(scale, linear.clamp);
return scale;
-};
+}
function d3_scale_linearNice(dx) {
dx = Math.pow(10, Math.round(Math.log(dx) / Math.LN10) - 1);
View
@@ -989,7 +989,7 @@ d3.layout.histogram = function() {
i = -1,
n = values.length,
m = thresholds.length - 1,
- k = frequency ? 1 / n : 1,
+ k = frequency ? 1 : 1 / n,
x;
// Initialize the bins.
@@ -1713,33 +1713,36 @@ d3.layout.treemap = function() {
var hierarchy = d3.layout.hierarchy(),
round = Math.round,
size = [1, 1], // width, height
+ padding = null,
+ pad = d3_layout_treemapPadNull,
sticky = false,
stickies,
ratio = 0.5 * (1 + Math.sqrt(5)); // golden ratio
- // Recursively compute the node area based on value & scale.
- function scale(node, k) {
- var children = node.children,
- value = node.value;
- node.area = isNaN(value) || value < 0 ? 0 : value * k;
- if (children) {
- var i = -1,
- n = children.length;
- while (++i < n) scale(children[i], k);
+ // Compute the area for each child based on value & scale.
+ function scale(children, k) {
+ var i = -1,
+ n = children.length,
+ child,
+ area;
+ while (++i < n) {
+ area = (child = children[i]).value * (k < 0 ? 0 : k);
+ child.area = isNaN(area) || area <= 0 ? 0 : area;
}
}
// Recursively arranges the specified node's children into squarified rows.
function squarify(node) {
if (!node.children) return;
- var rect = {x: node.x, y: node.y, dx: node.dx, dy: node.dy},
+ var rect = pad(node),
row = [],
children = node.children.slice(), // copy-on-write
child,
best = Infinity, // the best row score so far
score, // the current row score
u = Math.min(rect.dx, rect.dy), // initial orientation
n;
+ scale(children, rect.dx * rect.dy / node.value);
row.area = 0;
while ((n = children.length) > 0) {
row.push(child = children[n - 1]);
@@ -1766,10 +1769,11 @@ d3.layout.treemap = function() {
// Preserves the existing layout!
function stickify(node) {
if (!node.children) return;
- var rect = {x: node.x, y: node.y, dx: node.dx, dy: node.dy},
+ var rect = pad(node),
children = node.children.slice(), // copy-on-write
child,
row = [];
+ scale(children, rect.dx * rect.dy / node.value);
row.area = 0;
while (child = children.pop()) {
row.push(child);
@@ -1817,7 +1821,7 @@ d3.layout.treemap = function() {
o.x = x;
o.y = y;
o.dy = v;
- x += o.dx = round(o.area / v);
+ x += o.dx = v ? round(o.area / v) : 0;
}
o.z = true;
o.dx += rect.x + rect.dx - x; // rounding error
@@ -1830,7 +1834,7 @@ d3.layout.treemap = function() {
o.x = x;
o.y = y;
o.dx = v;
- y += o.dy = round(o.area / v);
+ y += o.dy = v ? round(o.area / v) : 0;
}
o.z = false;
o.dy += rect.y + rect.dy - y; // rounding error
@@ -1847,7 +1851,7 @@ d3.layout.treemap = function() {
root.dx = size[0];
root.dy = size[1];
if (stickies) hierarchy.revalue(root);
- scale(root, size[0] * size[1] / root.value);
+ scale([root], root.dx * root.dy / root.value);
(stickies ? stickify : squarify)(root);
if (sticky) stickies = nodes;
return nodes;
@@ -1859,6 +1863,28 @@ d3.layout.treemap = function() {
return treemap;
};
+ treemap.padding = function(x) {
+ if (!arguments.length) return padding;
+
+ function padFunction(node) {
+ var p = x.call(treemap, node, node.depth);
+ return p == null
+ ? d3_layout_treemapPadNull(node)
+ : d3_layout_treemapPad(node, typeof p === "number" ? [p, p, p, p] : p);
+ }
+
+ function padConstant(node) {
+ return d3_layout_treemapPad(node, x);
+ }
+
+ var type;
+ pad = (padding = x) == null ? d3_layout_treemapPadNull
+ : (type = typeof x) === "function" ? padFunction
+ : type === "number" ? (x = [x, x, x, x], padConstant)
+ : padConstant;
+ return treemap;
+ };
+
treemap.round = function(x) {
if (!arguments.length) return round != Number;
round = x ? Math.round : Number;
@@ -1880,4 +1906,18 @@ d3.layout.treemap = function() {
return d3_layout_hierarchyRebind(treemap, hierarchy);
};
+
+function d3_layout_treemapPadNull(node) {
+ return {x: node.x, y: node.y, dx: node.dx, dy: node.dy};
+}
+
+function d3_layout_treemapPad(node, padding) {
+ var x = node.x + padding[3],
+ y = node.y + padding[0],
+ dx = node.dx - padding[1] - padding[3],
+ dy = node.dy - padding[0] - padding[2];
+ if (dx < 0) { x += dx / 2; dx = 0; }
+ if (dy < 0) { y += dy / 2; dy = 0; }
+ return {x: x, y: y, dx: dx, dy: dy};
+}
})();
View

Large diffs are not rendered by default.

Oops, something went wrong.
View

Large diffs are not rendered by default.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit 6a9eda0

Please sign in to comment.