Skip to content

Commit

Permalink
Merge branch '3.1.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock committed Apr 30, 2013
2 parents d8c14b9 + 42da3ba commit 1d0409e
Show file tree
Hide file tree
Showing 25 changed files with 321 additions and 166 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ src/format/format-localized.js: src/locale.js src/format/format-locale.js
src/time/format-localized.js: src/locale.js src/time/format-locale.js
LC_TIME=$(LOCALE) locale -ck LC_TIME | node src/locale.js src/time/format-locale.js > $@

d3.js: $(shell node_modules/.bin/smash --list src/d3.js)
d3.js: $(shell node_modules/.bin/smash --list src/d3.js) package.json
@rm -f $@
node_modules/.bin/smash src/d3.js \
| sed 's/[[:<:]]VERSION[[:>:]]/"$(shell ./version)"/' \
Expand All @@ -32,7 +32,7 @@ d3.min.js: d3.js
@rm -f $@
node_modules/.bin/uglifyjs $< -c -m -o $@

component.json: src/component.js d3.js
component.json: src/component.js d3.js package.json
@rm -f $@
node src/component.js > $@
@chmod a-w $@
Expand Down
2 changes: 1 addition & 1 deletion component.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "d3",
"version": "3.1.5",
"version": "3.1.6",
"main": "index-browserify.js",
"scripts": [
"index-browserify.js",
Expand Down
107 changes: 50 additions & 57 deletions d3.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
d3 = function() {
var d3 = {
version: "3.1.5"
version: "3.1.6"
};
if (!Date.now) Date.now = function() {
return +new Date();
Expand Down Expand Up @@ -566,11 +566,10 @@ d3 = function() {
};
d3_selectMatches = Sizzle.matchesSelector;
}
var d3_selectionPrototype = [];
d3.selection = function() {
return d3_selectionRoot;
};
d3.selection.prototype = d3_selectionPrototype;
var d3_selectionPrototype = d3.selection.prototype = [];
d3_selectionPrototype.select = function(selector) {
var subgroups = [], subgroup, subnode, group, node;
if (typeof selector !== "function") selector = d3_selection_selector(selector);
Expand Down Expand Up @@ -1088,14 +1087,17 @@ d3 = function() {
}
return d3_transition(subgroups, id);
};
var d3_selectionRoot = d3_selection([ [ d3_document ] ]);
d3_selectionRoot[0].parentNode = d3_selectRoot;
d3.select = function(selector) {
return typeof selector === "string" ? d3_selectionRoot.select(selector) : d3_selection([ [ selector ] ]);
d3.select = function(node) {
var group = [ typeof node === "string" ? d3_select(node, d3_document) : node ];
group.parentNode = d3_selectRoot;
return d3_selection([ group ]);
};
d3.selectAll = function(selector) {
return typeof selector === "string" ? d3_selectionRoot.selectAll(selector) : d3_selection([ d3_array(selector) ]);
d3.selectAll = function(nodes) {
var group = d3_array(typeof nodes === "string" ? d3_selectAll(nodes, d3_document) : nodes);
group.parentNode = d3_selectRoot;
return d3_selection([ group ]);
};
var d3_selectionRoot = d3.select(d3_selectRoot);
d3.behavior.zoom = function() {
var translate = [ 0, 0 ], translate0, scale = 1, scale0, scaleExtent = d3_behavior_zoomInfinity, event = d3_eventDispatch(zoom, "zoom"), x0, x1, y0, y1, touchtime;
function zoom() {
Expand Down Expand Up @@ -1264,9 +1266,8 @@ d3 = function() {
};
function d3_hsl_rgb(h, s, l) {
var m1, m2;
h = h % 360;
if (h < 0) h += 360;
s = s < 0 ? 0 : s > 1 ? 1 : s;
h = isNaN(h) ? 0 : (h %= 360) < 0 ? h + 360 : h;
s = isNaN(s) ? 0 : s < 0 ? 0 : s > 1 ? 1 : s;
l = l < 0 ? 0 : l > 1 ? 1 : l;
m2 = l <= .5 ? l * (1 + s) : l + s - l * s;
m1 = 2 * l - m2;
Expand Down Expand Up @@ -1323,6 +1324,8 @@ d3 = function() {
return d3_hcl_lab(this.h, this.c, this.l).rgb();
};
function d3_hcl_lab(h, c, l) {
if (isNaN(h)) h = 0;
if (isNaN(c)) c = 0;
return d3_lab(l, Math.cos(h *= d3_radians) * c, Math.sin(h) * c);
}
d3.lab = function(l, a, b) {
Expand Down Expand Up @@ -1356,7 +1359,7 @@ d3 = function() {
return d3_rgb(d3_xyz_rgb(3.2404542 * x - 1.5371385 * y - .4985314 * z), d3_xyz_rgb(-.969266 * x + 1.8760108 * y + .041556 * z), d3_xyz_rgb(.0556434 * x - .2040259 * y + 1.0572252 * z));
}
function d3_lab_hcl(l, a, b) {
return d3_hcl(Math.atan2(b, a) * d3_degrees, Math.sqrt(a * a + b * b), l);
return l > 0 ? d3_hcl(Math.atan2(b, a) * d3_degrees, Math.sqrt(a * a + b * b), l) : d3_hcl(NaN, NaN, l);
}
function d3_lab_xyz(x) {
return x > .206893034 ? x * x * x : (x - 4 / 29) / 7.787037;
Expand Down Expand Up @@ -1439,13 +1442,11 @@ d3 = function() {
return rgb(r, g, b);
}
function d3_rgb_hsl(r, g, b) {
var min = Math.min(r /= 255, g /= 255, b /= 255), max = Math.max(r, g, b), d = max - min, h, s, l = (max + min) / 2;
var min = Math.min(r /= 255, g /= 255, b /= 255), max = Math.max(r, g, b), d = max - min, h = NaN, s = h, l = (max + min) / 2;
if (d) {
s = l < .5 ? d / (max + min) : d / (2 - max - min);
if (r == max) h = (g - b) / d + (g < b ? 6 : 0); else if (g == max) h = (b - r) / d + 2; else h = (r - g) / d + 4;
h *= 60;
} else {
s = h = 0;
}
return d3_hsl(h, s, l);
}
Expand Down Expand Up @@ -3945,11 +3946,7 @@ d3 = function() {
vertices.push([ +fx.call(this, d = data[i], i), +fy.call(this, d, i) ]);
}
for (i = 1; i < n; ++i) {
if (vertices[i][1] < vertices[h][1]) {
h = i;
} else if (vertices[i][1] == vertices[h][1]) {
h = vertices[i][0] < vertices[h][0] ? i : h;
}
if (vertices[i][1] < vertices[h][1] || vertices[i][1] == vertices[h][1] && vertices[i][0] < vertices[h][0]) h = i;
}
for (i = 0; i < n; ++i) {
if (i === h) continue;
Expand All @@ -3975,37 +3972,32 @@ d3 = function() {
y2 = vertices[j][1] - vertices[h][1];
if (x1 * x1 + y1 * y1 >= x2 * x2 + y2 * y2) {
points[i].index = -1;
continue;
} else {
points[u].index = -1;
a = points[i].angle;
u = i;
v = j;
}
} else {
a = points[i].angle;
u = i;
v = j;
}
a = points[i].angle;
u = i;
v = j;
}
stack.push(h);
for (i = 0, j = 0; i < 2; ++j) {
if (points[j].index !== -1) {
if (points[j].index > -1) {
stack.push(points[j].index);
i++;
}
}
sp = stack.length;
for (;j < plen; ++j) {
if (points[j].index === -1) continue;
if (points[j].index < 0) continue;
while (!d3_geom_hullCCW(stack[sp - 2], stack[sp - 1], points[j].index, vertices)) {
--sp;
}
stack[sp++] = points[j].index;
}
var poly = [];
for (i = 0; i < sp; ++i) {
poly.push(data[stack[i]]);
}
for (i = sp - 1; i >= 0; --i) poly.push(data[stack[i]]);
return poly;
}
hull.x = function(_) {
Expand Down Expand Up @@ -4956,7 +4948,8 @@ d3 = function() {
a = d3.hcl(a);
b = d3.hcl(b);
var ah = a.h, ac = a.c, al = a.l, bh = b.h - ah, bc = b.c - ac, bl = b.l - al;
if (bh > 180) bh -= 360; else if (bh < -180) bh += 360;
if (isNaN(bc)) bc = 0, ac = isNaN(ac) ? b.c : ac;
if (isNaN(bh)) bh = 0, ah = isNaN(ah) ? b.h : ah; else if (bh > 180) bh -= 360; else if (bh < -180) bh += 360;
return function(t) {
return d3_hcl_lab(ah + bh * t, ac + bc * t, al + bl * t) + "";
};
Expand All @@ -4965,10 +4958,11 @@ d3 = function() {
function d3_interpolateHsl(a, b) {
a = d3.hsl(a);
b = d3.hsl(b);
var h0 = a.h, s0 = a.s, l0 = a.l, h1 = b.h - h0, s1 = b.s - s0, l1 = b.l - l0;
if (h1 > 180) h1 -= 360; else if (h1 < -180) h1 += 360;
var ah = a.h, as = a.s, al = a.l, bh = b.h - ah, bs = b.s - as, bl = b.l - al;
if (isNaN(bs)) bs = 0, as = isNaN(as) ? b.s : as;
if (isNaN(bh)) bh = 0, ah = isNaN(ah) ? b.h : ah; else if (bh > 180) bh -= 360; else if (bh < -180) bh += 360;
return function(t) {
return d3_hsl_rgb(h0 + h1 * t, s0 + s1 * t, l0 + l1 * t) + "";
return d3_hsl_rgb(ah + bh * t, as + bs * t, al + bl * t) + "";
};
}
d3.interpolateLab = d3_interpolateLab;
Expand Down Expand Up @@ -7213,21 +7207,23 @@ d3 = function() {
function attrNullNS() {
this.removeAttributeNS(name.space, name.local);
}
return d3_transition_tween(this, "attr." + nameNS, value, function(b) {
function attrString() {
function attrTween(b) {
return b == null ? attrNull : (b += "", function() {
var a = this.getAttribute(name), i;
return a !== b && (i = interpolate(a, b), function(t) {
this.setAttribute(name, i(t));
});
}
function attrStringNS() {
});
}
function attrTweenNS(b) {
return b == null ? attrNullNS : (b += "", function() {
var a = this.getAttributeNS(name.space, name.local), i;
return a !== b && (i = interpolate(a, b), function(t) {
this.setAttributeNS(name.space, name.local, i(t));
});
}
return b == null ? name.local ? attrNullNS : attrNull : (b += "", name.local ? attrStringNS : attrString);
});
});
}
return d3_transition_tween(this, "attr." + nameNS, value, name.local ? attrTweenNS : attrTween);
};
d3_transitionPrototype.attrTween = function(nameNS, tween) {
var name = d3.ns.qualify(nameNS);
Expand Down Expand Up @@ -7259,24 +7255,25 @@ d3 = function() {
function styleNull() {
this.style.removeProperty(name);
}
return d3_transition_tween(this, "style." + name, value, function(b) {
function styleString() {
function styleString(b) {
return b == null ? styleNull : (b += "", function() {
var a = d3_window.getComputedStyle(this, null).getPropertyValue(name), i;
return a !== b && (i = interpolate(a, b), function(t) {
this.style.setProperty(name, i(t), priority);
});
}
return b == null ? styleNull : (b += "", styleString);
});
});
}
return d3_transition_tween(this, "style." + name, value, styleString);
};
d3_transitionPrototype.styleTween = function(name, tween, priority) {
if (arguments.length < 3) priority = "";
return this.tween("style." + name, function(d, i) {
function styleTween(d, i) {
var f = tween.call(this, d, i, d3_window.getComputedStyle(this, null).getPropertyValue(name));
return f && function(t) {
this.style.setProperty(name, f(t), priority);
};
});
}
return this.tween("style." + name, styleTween);
};
d3_transitionPrototype.text = function(value) {
return d3_transition_tween(this, "text", value, d3_transition_text);
Expand Down Expand Up @@ -8305,7 +8302,7 @@ d3 = function() {
}));
};
scale.ticks = function(m, k) {
var extent = d3_time_scaleExtent(scale.domain());
var extent = d3_scaleExtent(scale.domain());
if (typeof m !== "function") {
var span = extent[1] - extent[0], target = span / m, i = d3.bisect(d3_time_scaleSteps, target);
if (i == d3_time_scaleSteps.length) return methods.year(extent, m);
Expand All @@ -8323,11 +8320,7 @@ d3 = function() {
scale.copy = function() {
return d3_time_scale(linear.copy(), methods, format);
};
return d3.rebind(scale, linear, "range", "rangeRound", "interpolate", "clamp");
}
function d3_time_scaleExtent(domain) {
var start = domain[0], stop = domain[domain.length - 1];
return start < stop ? [ start, stop ] : [ stop, start ];
return d3_scale_linearRebind(scale, linear);
}
function d3_time_scaleDate(t) {
return new Date(t);
Expand Down
10 changes: 5 additions & 5 deletions d3.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "d3",
"version": "3.1.5",
"version": "3.1.6",
"description": "A small, free JavaScript library for manipulating documents based on data.",
"keywords": [
"dom",
Expand Down
2 changes: 2 additions & 0 deletions src/color/hcl.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,7 @@ d3_hclPrototype.rgb = function() {
};

function d3_hcl_lab(h, c, l) {
if (isNaN(h)) h = 0;
if (isNaN(c)) c = 0;
return d3_lab(l, Math.cos(h *= d3_radians) * c, Math.sin(h) * c);
}
4 changes: 2 additions & 2 deletions src/color/hsl.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ function d3_hsl_rgb(h, s, l) {
m2;

/* Some simple corrections for h, s and l. */
h = h % 360; if (h < 0) h += 360;
s = s < 0 ? 0 : s > 1 ? 1 : s;
h = isNaN(h) ? 0 : (h %= 360) < 0 ? h + 360 : h;
s = isNaN(s) ? 0 : s < 0 ? 0 : s > 1 ? 1 : s;
l = l < 0 ? 0 : l > 1 ? 1 : l;

/* From FvD 13.37, CSS Color Module Level 3 */
Expand Down
4 changes: 3 additions & 1 deletion src/color/lab.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@ function d3_lab_rgb(l, a, b) {
}

function d3_lab_hcl(l, a, b) {
return d3_hcl(Math.atan2(b, a) * d3_degrees, Math.sqrt(a * a + b * b), l);
return l > 0
? d3_hcl(Math.atan2(b, a) * d3_degrees, Math.sqrt(a * a + b * b), l)
: d3_hcl(NaN, NaN, l);
}

function d3_lab_xyz(x) {
Expand Down
6 changes: 2 additions & 4 deletions src/color/rgb.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,17 +117,15 @@ function d3_rgb_hsl(r, g, b) {
var min = Math.min(r /= 255, g /= 255, b /= 255),
max = Math.max(r, g, b),
d = max - min,
h,
s,
h = NaN,
s = h,
l = (max + min) / 2;
if (d) {
s = l < .5 ? d / (max + min) : d / (2 - max - min);
if (r == max) h = (g - b) / d + (g < b ? 6 : 0);
else if (g == max) h = (b - r) / d + 2;
else h = (r - g) / d + 4;
h *= 60;
} else {
s = h = 0;
}
return d3_hsl(h, s, l);
}
Expand Down
Loading

0 comments on commit 1d0409e

Please sign in to comment.