Skip to content

Commit

Permalink
Merge branch '2.10.3'
Browse files Browse the repository at this point in the history
  • Loading branch information
mbostock committed Oct 4, 2012
2 parents e01f789 + 443f0e6 commit 41fece5
Show file tree
Hide file tree
Showing 16 changed files with 109 additions and 90 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ d3.core.js: \
src/core/transform.js \
src/core/interpolate.js \
src/core/uninterpolate.js \
src/core/color.js \
src/core/rgb.js \
src/core/hsl.js \
src/core/hcl.js \
Expand Down
2 changes: 1 addition & 1 deletion component.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "d3",
"version": "2.10.2",
"version": "2.10.3",
"main": "./d3.v2.js"
}
69 changes: 31 additions & 38 deletions d3.v2.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@
return Math.max(0, Math.min(1, (x - a) * b));
};
}
function d3_Color() {}
function d3_rgb(r, g, b) {
return new d3_Rgb(r, g, b);
}
Expand Down Expand Up @@ -621,6 +622,7 @@
var t0 = null, t1 = d3_timer_queue, then = Infinity;
while (t1) {
if (t1.flush) {
delete d3_timer_byId[t1.callback.id];
t1 = t0 ? t0.next = t1.next : d3_timer_queue = t1.next;
} else {
then = Math.min(then, t1.then + t1.delay);
Expand Down Expand Up @@ -2572,7 +2574,7 @@
};
}
d3 = {
version: "2.10.2"
version: "2.10.3"
};
var d3_array = d3_arraySlice;
try {
Expand Down Expand Up @@ -3347,14 +3349,18 @@
}, function(a, b) {
return (typeof a === "string" || typeof b === "string") && d3.interpolateString(a + "", b + "");
}, function(a, b) {
return (typeof b === "string" ? d3_rgb_names.has(b) || /^(#|rgb\(|hsl\()/.test(b) : b instanceof d3_Rgb || b instanceof d3_Hsl) && d3.interpolateRgb(a, b);
return (typeof b === "string" ? d3_rgb_names.has(b) || /^(#|rgb\(|hsl\()/.test(b) : b instanceof d3_Color) && d3.interpolateRgb(a, b);
}, function(a, b) {
return !isNaN(a = +a) && !isNaN(b = +b) && d3.interpolateNumber(a, b);
} ];
d3_Color.prototype.toString = function() {
return this.rgb() + "";
};
d3.rgb = function(r, g, b) {
return arguments.length === 1 ? 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);
};
d3_Rgb.prototype.brighter = function(k) {
var d3_rgbPrototype = d3_Rgb.prototype = new d3_Color;
d3_rgbPrototype.brighter = function(k) {
k = Math.pow(.7, arguments.length ? k : 1);
var r = this.r, g = this.g, b = this.b, i = 30;
if (!r && !g && !b) return d3_rgb(i, i, i);
Expand All @@ -3363,14 +3369,14 @@
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)));
};
d3_Rgb.prototype.darker = function(k) {
d3_rgbPrototype.darker = function(k) {
k = Math.pow(.7, arguments.length ? k : 1);
return d3_rgb(Math.floor(k * this.r), Math.floor(k * this.g), Math.floor(k * this.b));
};
d3_Rgb.prototype.hsl = function() {
d3_rgbPrototype.hsl = function() {
return d3_rgb_hsl(this.r, this.g, this.b);
};
d3_Rgb.prototype.toString = function() {
d3_rgbPrototype.toString = function() {
return "#" + d3_rgb_hex(this.r) + d3_rgb_hex(this.g) + d3_rgb_hex(this.b);
};
var d3_rgb_names = d3.map({
Expand Down Expand Up @@ -3528,52 +3534,46 @@
d3.hsl = function(h, s, l) {
return arguments.length === 1 ? 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);
};
d3_Hsl.prototype.brighter = function(k) {
var d3_hslPrototype = d3_Hsl.prototype = new d3_Color;
d3_hslPrototype.brighter = function(k) {
k = Math.pow(.7, arguments.length ? k : 1);
return d3_hsl(this.h, this.s, this.l / k);
};
d3_Hsl.prototype.darker = function(k) {
d3_hslPrototype.darker = function(k) {
k = Math.pow(.7, arguments.length ? k : 1);
return d3_hsl(this.h, this.s, k * this.l);
};
d3_Hsl.prototype.rgb = function() {
d3_hslPrototype.rgb = function() {
return d3_hsl_rgb(this.h, this.s, this.l);
};
d3_Hsl.prototype.toString = function() {
return this.rgb().toString();
};
d3.hcl = function(h, c, l) {
return arguments.length === 1 ? h instanceof d3_Hcl ? d3_hcl(h.h, h.c, h.l) : h instanceof d3_Lab ? d3_lab_hcl(h.l, h.a, h.b) : d3_lab_hcl((h = d3_rgb_lab((h = d3.rgb(h)).r, h.g, h.b)).l, h.a, h.b) : d3_hcl(+h, +c, +l);
};
d3_Hcl.prototype.brighter = function(k) {
var d3_hclPrototype = d3_Hcl.prototype = new d3_Color;
d3_hclPrototype.brighter = function(k) {
return d3_hcl(this.h, this.c, Math.min(100, this.l + d3_lab_K * (arguments.length ? k : 1)));
};
d3_Hcl.prototype.darker = function(k) {
d3_hclPrototype.darker = function(k) {
return d3_hcl(this.h, this.c, Math.max(0, this.l - d3_lab_K * (arguments.length ? k : 1)));
};
d3_Hcl.prototype.rgb = function() {
d3_hclPrototype.rgb = function() {
return d3_hcl_lab(this.h, this.c, this.l).rgb();
};
d3_Hcl.prototype.toString = function() {
return this.rgb() + "";
};
d3.lab = function(l, a, b) {
return arguments.length === 1 ? l instanceof d3_Lab ? d3_lab(l.l, l.a, l.b) : l instanceof d3_Hcl ? d3_hcl_lab(l.l, l.c, l.h) : d3_rgb_lab((l = d3.rgb(l)).r, l.g, l.b) : d3_lab(+l, +a, +b);
};
var d3_lab_K = 18;
var d3_lab_X = .95047, d3_lab_Y = 1, d3_lab_Z = 1.08883;
d3_Lab.prototype.brighter = function(k) {
var d3_labPrototype = d3_Lab.prototype = new d3_Color;
d3_labPrototype.brighter = function(k) {
return d3_lab(Math.min(100, this.l + d3_lab_K * (arguments.length ? k : 1)), this.a, this.b);
};
d3_Lab.prototype.darker = function(k) {
d3_labPrototype.darker = function(k) {
return d3_lab(Math.max(0, this.l - d3_lab_K * (arguments.length ? k : 1)), this.a, this.b);
};
d3_Lab.prototype.rgb = function() {
d3_labPrototype.rgb = function() {
return d3_lab_rgb(this.l, this.a, this.b);
};
d3_Lab.prototype.toString = function() {
return this.rgb() + "";
};
var d3_select = function(s, n) {
return n.querySelector(s);
}, d3_selectAll = function(s, n) {
Expand Down Expand Up @@ -4056,32 +4056,25 @@
d3.tween = function(b, interpolate) {
function tweenFunction(d, i, a) {
var v = b.call(this, d, i);
return v == null ? a != "" && d3_tweenRemove : a != v && interpolate(a, v);
return v == null ? a != "" && d3_tweenRemove : a != v && interpolate(a, v + "");
}
function tweenString(d, i, a) {
return a != b && interpolate(a, b);
}
return typeof b === "function" ? tweenFunction : b == null ? d3_tweenNull : (b += "", tweenString);
};
var d3_tweenRemove = {};
var d3_timer_queue = null, d3_timer_interval, d3_timer_timeout;
var d3_timer_id = 0, d3_timer_byId = {}, d3_timer_queue = null, d3_timer_interval, d3_timer_timeout;
d3.timer = function(callback, delay, then) {
var found = false, t0, t1 = d3_timer_queue;
if (arguments.length < 3) {
if (arguments.length < 2) delay = 0; else if (!isFinite(delay)) return;
then = Date.now();
}
while (t1) {
if (t1.callback === callback) {
t1.then = then;
t1.delay = delay;
found = true;
break;
}
t0 = t1;
t1 = t1.next;
}
if (!found) d3_timer_queue = {
var timer = d3_timer_byId[callback.id];
if (timer && timer.callback === callback) {
timer.then = then;
timer.delay = delay;
} else d3_timer_byId[callback.id = ++d3_timer_id] = d3_timer_queue = {
callback: callback,
then: then,
delay: delay,
Expand Down
8 changes: 4 additions & 4 deletions d3.v2.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": "2.10.2",
"version": "2.10.3",
"description": "A small, free JavaScript library for manipulating documents based on data.",
"keywords": [
"dom",
Expand Down
5 changes: 5 additions & 0 deletions src/core/color.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
function d3_Color() {}

d3_Color.prototype.toString = function() {
return this.rgb() + "";
};
2 changes: 1 addition & 1 deletion src/core/core.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
d3 = {version: "2.10.2"}; // semver
d3 = {version: "2.10.3"}; // semver
12 changes: 5 additions & 7 deletions src/core/hcl.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,20 @@ function d3_Hcl(h, c, l) {
this.l = l;
}

d3_Hcl.prototype.brighter = function(k) {
var d3_hclPrototype = d3_Hcl.prototype = new d3_Color;

d3_hclPrototype.brighter = function(k) {
return d3_hcl(this.h, this.c, Math.min(100, this.l + d3_lab_K * (arguments.length ? k : 1)));
};

d3_Hcl.prototype.darker = function(k) {
d3_hclPrototype.darker = function(k) {
return d3_hcl(this.h, this.c, Math.max(0, this.l - d3_lab_K * (arguments.length ? k : 1)));
};

d3_Hcl.prototype.rgb = function() {
d3_hclPrototype.rgb = function() {
return d3_hcl_lab(this.h, this.c, this.l).rgb();
};

d3_Hcl.prototype.toString = function() {
return this.rgb() + "";
};

function d3_hcl_lab(h, c, l) {
return d3_lab(l, Math.cos(h *= Math.PI / 180) * c, Math.sin(h) * c);
}
12 changes: 5 additions & 7 deletions src/core/hsl.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,22 @@ function d3_Hsl(h, s, l) {
this.l = l;
}

d3_Hsl.prototype.brighter = function(k) {
var d3_hslPrototype = d3_Hsl.prototype = new d3_Color;

d3_hslPrototype.brighter = function(k) {
k = Math.pow(0.7, arguments.length ? k : 1);
return d3_hsl(this.h, this.s, this.l / k);
};

d3_Hsl.prototype.darker = function(k) {
d3_hslPrototype.darker = function(k) {
k = Math.pow(0.7, arguments.length ? k : 1);
return d3_hsl(this.h, this.s, k * this.l);
};

d3_Hsl.prototype.rgb = function() {
d3_hslPrototype.rgb = function() {
return d3_hsl_rgb(this.h, this.s, this.l);
};

d3_Hsl.prototype.toString = function() {
return this.rgb().toString();
};

function d3_hsl_rgb(h, s, l) {
var m1,
m2;
Expand Down
2 changes: 1 addition & 1 deletion src/core/interpolate.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,6 @@ d3.interpolators = [
d3.interpolateObject,
function(a, b) { return b instanceof Array && d3.interpolateArray(a, b); },
function(a, b) { return (typeof a === "string" || typeof b === "string") && d3.interpolateString(a + "", b + ""); },
function(a, b) { return (typeof b === "string" ? d3_rgb_names.has(b) || /^(#|rgb\(|hsl\()/.test(b) : b instanceof d3_Rgb || b instanceof d3_Hsl) && d3.interpolateRgb(a, b); },
function(a, b) { return (typeof b === "string" ? d3_rgb_names.has(b) || /^(#|rgb\(|hsl\()/.test(b) : b instanceof d3_Color) && d3.interpolateRgb(a, b); },
function(a, b) { return !isNaN(a = +a) && !isNaN(b = +b) && d3.interpolateNumber(a, b); }
];
12 changes: 5 additions & 7 deletions src/core/lab.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,20 @@ var d3_lab_X = 0.950470,
d3_lab_Y = 1,
d3_lab_Z = 1.088830;

d3_Lab.prototype.brighter = function(k) {
var d3_labPrototype = d3_Lab.prototype = new d3_Color;

d3_labPrototype.brighter = function(k) {
return d3_lab(Math.min(100, this.l + d3_lab_K * (arguments.length ? k : 1)), this.a, this.b);
};

d3_Lab.prototype.darker = function(k) {
d3_labPrototype.darker = function(k) {
return d3_lab(Math.max(0, this.l - d3_lab_K * (arguments.length ? k : 1)), this.a, this.b);
};

d3_Lab.prototype.rgb = function() {
d3_labPrototype.rgb = function() {
return d3_lab_rgb(this.l, this.a, this.b);
};

d3_Lab.prototype.toString = function() {
return this.rgb() + "";
};

function d3_lab_rgb(l, a, b) {
var y = (l + 16) / 116,
x = y + a / 500,
Expand Down
10 changes: 6 additions & 4 deletions src/core/rgb.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ function d3_Rgb(r, g, b) {
this.b = b;
}

d3_Rgb.prototype.brighter = function(k) {
var d3_rgbPrototype = d3_Rgb.prototype = new d3_Color;

d3_rgbPrototype.brighter = function(k) {
k = Math.pow(0.7, arguments.length ? k : 1);
var r = this.r,
g = this.g,
Expand All @@ -31,19 +33,19 @@ d3_Rgb.prototype.brighter = function(k) {
Math.min(255, Math.floor(b / k)));
};

d3_Rgb.prototype.darker = function(k) {
d3_rgbPrototype.darker = function(k) {
k = Math.pow(0.7, arguments.length ? k : 1);
return d3_rgb(
Math.floor(k * this.r),
Math.floor(k * this.g),
Math.floor(k * this.b));
};

d3_Rgb.prototype.hsl = function() {
d3_rgbPrototype.hsl = function() {
return d3_rgb_hsl(this.r, this.g, this.b);
};

d3_Rgb.prototype.toString = function() {
d3_rgbPrototype.toString = function() {
return "#" + d3_rgb_hex(this.r) + d3_rgb_hex(this.g) + d3_rgb_hex(this.b);
};

Expand Down
30 changes: 12 additions & 18 deletions src/core/timer.js
Original file line number Diff line number Diff line change
@@ -1,33 +1,26 @@
var d3_timer_queue = null,
var d3_timer_id = 0,
d3_timer_byId = {},
d3_timer_queue = null,
d3_timer_interval, // is an interval (or frame) active?
d3_timer_timeout; // is a timeout active?

// The timer will continue to fire until callback returns true.
d3.timer = function(callback, delay, then) {
var found = false,
t0,
t1 = d3_timer_queue;

if (arguments.length < 3) {
if (arguments.length < 2) delay = 0;
else if (!isFinite(delay)) return;
then = Date.now();
}

// See if the callback's already in the queue.
while (t1) {
if (t1.callback === callback) {
t1.then = then;
t1.delay = delay;
found = true;
break;
}
t0 = t1;
t1 = t1.next;
// If the callback's already in the queue, update it.
var timer = d3_timer_byId[callback.id];
if (timer && timer.callback === callback) {
timer.then = then;
timer.delay = delay;
}

// Otherwise, add the callback to the queue.
if (!found) d3_timer_queue = {
else d3_timer_byId[callback.id = ++d3_timer_id] = d3_timer_queue = {
callback: callback,
then: then,
delay: delay,
Expand All @@ -40,7 +33,7 @@ d3.timer = function(callback, delay, then) {
d3_timer_interval = 1;
d3_timer_frame(d3_timer_step);
}
}
};

function d3_timer_step() {
var elapsed,
Expand Down Expand Up @@ -80,13 +73,14 @@ d3.timer.flush = function() {
d3_timer_flush();
};

// Flush after callbacks, to avoid concurrent queue modification.
// Flush after callbacks to avoid concurrent queue modification.
function d3_timer_flush() {
var t0 = null,
t1 = d3_timer_queue,
then = Infinity;
while (t1) {
if (t1.flush) {
delete d3_timer_byId[t1.callback.id];
t1 = t0 ? t0.next = t1.next : d3_timer_queue = t1.next;
} else {
then = Math.min(then, t1.then + t1.delay);
Expand Down
Loading

0 comments on commit 41fece5

Please sign in to comment.