Permalink
Browse files

Merge branch 'release'

  • Loading branch information...
mbostock committed Oct 7, 2011
2 parents fe61281 + 05e9a39 commit 9edd4bc05833d15fe9f0f671b4556f899782b455
View
@@ -4,21 +4,18 @@ NODE_PATH ?= ./node_modules
JS_COMPILER = $(NODE_PATH)/uglify-js/bin/uglifyjs
JS_TESTER = $(NODE_PATH)/vows/bin/vows
-all: \
+JS_FILES = \
d3.js \
- d3.min.js \
d3.chart.js \
- d3.chart.min.js \
d3.layout.js \
- d3.layout.min.js \
d3.csv.js \
- d3.csv.min.js \
d3.geo.js \
- d3.geo.min.js \
d3.geom.js \
- d3.geom.min.js \
- d3.time.js \
- d3.time.min.js \
+ d3.time.js
+
+all: \
+ $(JS_FILES) \
+ $(JS_FILES:.js=.min.js) \
package.json
# Modify this rule to build your own custom release.
@@ -245,7 +242,7 @@ test: all
@rm -f $@
$(JS_COMPILER) < $< > $@
-d3.js d3%.js: Makefile
+d3.%: Makefile
@rm -f $@
cat $(filter %.js,$^) > $@
@chmod a-w $@
View
116 d3.js
@@ -10,7 +10,7 @@ try {
d3_style_setProperty.call(this, name, value + "", priority);
};
}
-d3 = {version: "2.3.2"}; // semver
+d3 = {version: "2.3.3"}; // semver
var d3_array = d3_arraySlice; // conversion for NodeLists
function d3_arrayCopy(pseudoarray) {
@@ -780,10 +780,10 @@ d3.interpolateRgb = function(a, b) {
bg = b.g - ag,
bb = b.b - ab;
return function(t) {
- return "rgb(" + Math.round(ar + br * t)
- + "," + Math.round(ag + bg * t)
- + "," + Math.round(ab + bb * t)
- + ")";
+ return "#"
+ + d3_rgb_hex(Math.round(ar + br * t))
+ + d3_rgb_hex(Math.round(ag + bg * t))
+ + d3_rgb_hex(Math.round(ab + bb * t));
};
};
@@ -867,7 +867,8 @@ function d3_uninterpolateClamp(a, b) {
}
d3.rgb = function(r, g, b) {
return arguments.length === 1
- ? d3_rgb_parse("" + r, d3_rgb, d3_hsl_rgb)
+ ? (r instanceof d3_Rgb ? d3_rgb(r.r, r.g, r.b)
+ : d3_rgb_parse("" + r, d3_rgb, d3_hsl_rgb))
: d3_rgb(~~r, ~~g, ~~b);
};
@@ -892,17 +893,17 @@ d3_Rgb.prototype.brighter = function(k) {
if (g && g < i) g = i;
if (b && b < i) b = i;
return d3_rgb(
- Math.min(255, Math.floor(r / k)),
- Math.min(255, Math.floor(g / k)),
- Math.min(255, Math.floor(b / k)));
+ Math.min(255, Math.floor(r / k)),
+ Math.min(255, Math.floor(g / k)),
+ Math.min(255, Math.floor(b / k)));
};
d3_Rgb.prototype.darker = function(k) {
k = Math.pow(0.7, arguments.length ? k : 1);
return d3_rgb(
- Math.max(0, Math.floor(k * this.r)),
- Math.max(0, Math.floor(k * this.g)),
- Math.max(0, Math.floor(k * this.b)));
+ Math.floor(k * this.r),
+ Math.floor(k * this.g),
+ Math.floor(k * this.b));
};
d3_Rgb.prototype.hsl = function() {
@@ -914,7 +915,9 @@ d3_Rgb.prototype.toString = function() {
};
function d3_rgb_hex(v) {
- return v < 0x10 ? "0" + v.toString(16) : v.toString(16);
+ return v < 0x10
+ ? "0" + Math.max(0, v).toString(16)
+ : Math.min(255, v).toString(16);
}
function d3_rgb_parse(format, rgb, hsl) {
@@ -1151,7 +1154,8 @@ for (var d3_rgb_name in d3_rgb_names) {
}
d3.hsl = function(h, s, l) {
return arguments.length === 1
- ? d3_rgb_parse("" + h, d3_rgb_hsl, d3_hsl)
+ ? (h instanceof d3_Hsl ? d3_hsl(h.h, h.s, h.l)
+ : d3_rgb_parse("" + h, d3_rgb_hsl, d3_hsl))
: d3_hsl(+h, +s, +l);
};
@@ -1180,7 +1184,7 @@ d3_Hsl.prototype.rgb = function() {
};
d3_Hsl.prototype.toString = function() {
- return "hsl(" + this.h + "," + this.s * 100 + "%," + this.l * 100 + "%)";
+ return this.rgb().toString();
};
function d3_hsl_rgb(h, s, l) {
@@ -1331,6 +1335,21 @@ d3_selectionPrototype.attr = function(name, value) {
: (name.local ? attrConstantNS : attrConstant)));
};
d3_selectionPrototype.classed = function(name, value) {
+ var names = name.split(d3_selection_classedWhitespace),
+ n = names.length,
+ i = -1;
+ if (arguments.length > 1) {
+ while (++i < n) d3_selection_classed.call(this, names[i], value);
+ return this;
+ } else {
+ while (++i < n) if (!d3_selection_classed.call(this, names[i])) return false;
+ return true;
+ }
+};
+
+var d3_selection_classedWhitespace = /\s+/g;
+
+function d3_selection_classed(name, value) {
var re = new RegExp("(^|\\s+)" + d3.requote(name) + "(\\s+|$)", "g");
// If no value is specified, return the first value.
@@ -1375,7 +1394,7 @@ d3_selectionPrototype.classed = function(name, value) {
? classedFunction : value
? classedAdd
: classedRemove);
-};
+}
d3_selectionPrototype.style = function(name, value, priority) {
if (arguments.length < 3) priority = "";
@@ -1856,10 +1875,28 @@ function d3_transition(groups, id) {
return groups;
}
+var d3_transitionRemove = {};
+
+function d3_transitionNull(d, i, a) {
+ return a != "" && d3_transitionRemove;
+}
+
function d3_transitionTween(b) {
- return typeof b === "function"
- ? function(d, i, a) { var v = b.call(this, d, i) + ""; return a != v && d3.interpolate(a, v); }
- : (b = b + "", function(d, i, a) { return a != b && d3.interpolate(a, b); });
+
+ function transitionFunction(d, i, a) {
+ var v = b.call(this, d, i);
+ return v == null
+ ? a != "" && d3_transitionRemove
+ : a != v && d3.interpolate(a, v);
+ }
+
+ function transitionString(d, i, a) {
+ return a != b && d3.interpolate(a, b);
+ }
+
+ return typeof b === "function" ? transitionFunction
+ : b == null ? d3_transitionNull
+ : (b += "", transitionString);
}
var d3_transitionPrototype = [],
@@ -1922,24 +1959,24 @@ d3_transitionPrototype.attr = function(name, value) {
return this.attrTween(name, d3_transitionTween(value));
};
-d3_transitionPrototype.attrTween = function(name, tween) {
- name = d3.ns.qualify(name);
+d3_transitionPrototype.attrTween = function(nameNS, tween) {
+ var name = d3.ns.qualify(nameNS);
function attrTween(d, i) {
var f = tween.call(this, d, i, this.getAttribute(name));
- return f && function(t) {
- this.setAttribute(name, f(t));
- };
+ return f === d3_transitionRemove
+ ? (this.removeAttribute(name), null)
+ : f && function(t) { this.setAttribute(name, f(t)); };
}
function attrTweenNS(d, i) {
var f = tween.call(this, d, i, this.getAttributeNS(name.space, name.local));
- return f && function(t) {
- this.setAttributeNS(name.space, name.local, f(t));
- };
+ return f === d3_transitionRemove
+ ? (this.removeAttributeNS(name.space, name.local), null)
+ : f && function(t) { this.setAttributeNS(name.space, name.local, f(t)); };
}
- return this.tween("attr." + name, name.local ? attrTweenNS : attrTween);
+ return this.tween("attr." + nameNS, name.local ? attrTweenNS : attrTween);
};
d3_transitionPrototype.style = function(name, value, priority) {
if (arguments.length < 3) priority = "";
@@ -1950,9 +1987,9 @@ d3_transitionPrototype.styleTween = function(name, tween, priority) {
if (arguments.length < 3) priority = "";
return this.tween("style." + name, function(d, i) {
var f = tween.call(this, d, i, window.getComputedStyle(this, null).getPropertyValue(name));
- return f && function(t) {
- this.style.setProperty(name, f(t), priority);
- };
+ return f === d3_transitionRemove
+ ? (this.style.removeProperty(name), null)
+ : f && function(t) { this.style.setProperty(name, f(t), priority); };
});
};
d3_transitionPrototype.text = function(value) {
@@ -3149,16 +3186,17 @@ function d3_svg_area(projection) {
x1 = d3_svg_lineX,
y0 = 0,
y1 = d3_svg_lineY,
- interpolate = "linear",
- interpolator = d3_svg_lineInterpolators[interpolate],
+ interpolate,
+ i0,
+ i1,
tension = .7;
function area(d) {
if (d.length < 1) return null;
var points0 = d3_svg_linePoints(this, d, x0, y0),
points1 = d3_svg_linePoints(this, d, x0 === x1 ? d3_svg_areaX(points0) : x1, y0 === y1 ? d3_svg_areaY(points0) : y1);
- return "M" + interpolator(projection(points1), tension)
- + "L" + interpolator(projection(points0.reverse()), tension)
+ return "M" + i0(projection(points1), tension)
+ + "L" + i1(projection(points0.reverse()), tension)
+ "Z";
}
@@ -3200,7 +3238,8 @@ function d3_svg_area(projection) {
area.interpolate = function(x) {
if (!arguments.length) return interpolate;
- interpolator = d3_svg_lineInterpolators[interpolate = x];
+ i0 = d3_svg_lineInterpolators[interpolate = x];
+ i1 = i0.reverse || i0;
return area;
};
@@ -3210,9 +3249,12 @@ function d3_svg_area(projection) {
return area;
};
- return area;
+ return area.interpolate("linear");
}
+d3_svg_lineStepBefore.reverse = d3_svg_lineStepAfter;
+d3_svg_lineStepAfter.reverse = d3_svg_lineStepBefore;
+
d3.svg.area = function() {
return d3_svg_area(Object);
};
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -1,6 +1,6 @@
{
"name": "d3",
- "version": "2.3.2",
+ "version": "2.3.3",
"description": "A small, free JavaScript library for manipulating documents based on data.",
"keywords": [
"dom",
View
@@ -1 +1 @@
-d3 = {version: "2.3.2"}; // semver
+d3 = {version: "2.3.3"}; // semver
View
@@ -1,6 +1,7 @@
d3.hsl = function(h, s, l) {
return arguments.length === 1
- ? d3_rgb_parse("" + h, d3_rgb_hsl, d3_hsl)
+ ? (h instanceof d3_Hsl ? d3_hsl(h.h, h.s, h.l)
+ : d3_rgb_parse("" + h, d3_rgb_hsl, d3_hsl))
: d3_hsl(+h, +s, +l);
};
@@ -29,7 +30,7 @@ d3_Hsl.prototype.rgb = function() {
};
d3_Hsl.prototype.toString = function() {
- return "hsl(" + this.h + "," + this.s * 100 + "%," + this.l * 100 + "%)";
+ return this.rgb().toString();
};
function d3_hsl_rgb(h, s, l) {
View
@@ -102,10 +102,10 @@ d3.interpolateRgb = function(a, b) {
bg = b.g - ag,
bb = b.b - ab;
return function(t) {
- return "rgb(" + Math.round(ar + br * t)
- + "," + Math.round(ag + bg * t)
- + "," + Math.round(ab + bb * t)
- + ")";
+ return "#"
+ + d3_rgb_hex(Math.round(ar + br * t))
+ + d3_rgb_hex(Math.round(ag + bg * t))
+ + d3_rgb_hex(Math.round(ab + bb * t));
};
};
View
@@ -1,6 +1,7 @@
d3.rgb = function(r, g, b) {
return arguments.length === 1
- ? d3_rgb_parse("" + r, d3_rgb, d3_hsl_rgb)
+ ? (r instanceof d3_Rgb ? d3_rgb(r.r, r.g, r.b)
+ : d3_rgb_parse("" + r, d3_rgb, d3_hsl_rgb))
: d3_rgb(~~r, ~~g, ~~b);
};
@@ -25,17 +26,17 @@ d3_Rgb.prototype.brighter = function(k) {
if (g && g < i) g = i;
if (b && b < i) b = i;
return d3_rgb(
- Math.min(255, Math.floor(r / k)),
- Math.min(255, Math.floor(g / k)),
- Math.min(255, Math.floor(b / k)));
+ Math.min(255, Math.floor(r / k)),
+ Math.min(255, Math.floor(g / k)),
+ Math.min(255, Math.floor(b / k)));
};
d3_Rgb.prototype.darker = function(k) {
k = Math.pow(0.7, arguments.length ? k : 1);
return d3_rgb(
- Math.max(0, Math.floor(k * this.r)),
- Math.max(0, Math.floor(k * this.g)),
- Math.max(0, Math.floor(k * this.b)));
+ Math.floor(k * this.r),
+ Math.floor(k * this.g),
+ Math.floor(k * this.b));
};
d3_Rgb.prototype.hsl = function() {
@@ -47,7 +48,9 @@ d3_Rgb.prototype.toString = function() {
};
function d3_rgb_hex(v) {
- return v < 0x10 ? "0" + v.toString(16) : v.toString(16);
+ return v < 0x10
+ ? "0" + Math.max(0, v).toString(16)
+ : Math.min(255, v).toString(16);
}
function d3_rgb_parse(format, rgb, hsl) {
@@ -1,4 +1,19 @@
d3_selectionPrototype.classed = function(name, value) {
+ var names = name.split(d3_selection_classedWhitespace),
+ n = names.length,
+ i = -1;
+ if (arguments.length > 1) {
+ while (++i < n) d3_selection_classed.call(this, names[i], value);
+ return this;
+ } else {
+ while (++i < n) if (!d3_selection_classed.call(this, names[i])) return false;
+ return true;
+ }
+};
+
+var d3_selection_classedWhitespace = /\s+/g;
+
+function d3_selection_classed(name, value) {
var re = new RegExp("(^|\\s+)" + d3.requote(name) + "(\\s+|$)", "g");
// If no value is specified, return the first value.
@@ -43,4 +58,4 @@ d3_selectionPrototype.classed = function(name, value) {
? classedFunction : value
? classedAdd
: classedRemove);
-};
+}
Oops, something went wrong.

0 comments on commit 9edd4bc

Please sign in to comment.