Refactor project structure
This commit is contained in:
1 parent
889baf124c
commit
e3a7e18d9c
5513 files changed
+32
-27
No files matched your search
@@ -0,0 +1,155 @@
|
||||
(function(d3) {
|
||||
var cie = d3.cie = {};
|
||||
|
||||
cie.lab = function(l, a, b) {
|
||||
return arguments.length === 1
|
||||
? (l instanceof Lab ? lab(l.l, l.a, l.b)
|
||||
: (l instanceof Lch ? lch_lab(l.l, l.c, l.h)
|
||||
: rgb_lab((l = d3.rgb(l)).r, l.g, l.b)))
|
||||
: lab(+l, +a, +b);
|
||||
};
|
||||
|
||||
cie.lch = function(l, c, h) {
|
||||
return arguments.length === 1
|
||||
? (l instanceof Lch ? lch(l.l, l.c, l.h)
|
||||
: (l instanceof Lab ? lab_lch(l.l, l.a, l.b)
|
||||
: lab_lch((l = rgb_lab((l = d3.rgb(l)).r, l.g, l.b)).l, l.a, l.b)))
|
||||
: lch(+l, +c, +h);
|
||||
};
|
||||
|
||||
cie.interpolateLab = function(a, b) {
|
||||
a = cie.lab(a);
|
||||
b = cie.lab(b);
|
||||
var al = a.l,
|
||||
aa = a.a,
|
||||
ab = a.b,
|
||||
bl = b.l - al,
|
||||
ba = b.a - aa,
|
||||
bb = b.b - ab;
|
||||
return function(t) {
|
||||
return lab_rgb(al + bl * t, aa + ba * t, ab + bb * t) + "";
|
||||
};
|
||||
};
|
||||
|
||||
cie.interpolateLch = function(a, b) {
|
||||
a = cie.lch(a);
|
||||
b = cie.lch(b);
|
||||
var al = a.l,
|
||||
ac = a.c,
|
||||
ah = a.h,
|
||||
bl = b.l - al,
|
||||
bc = b.c - ac,
|
||||
bh = b.h - ah;
|
||||
if (bh > 180) bh -= 360; else if (bh < -180) bh += 360; // shortest path
|
||||
return function(t) {
|
||||
return lch_lab(al + bl * t, ac + bc * t, ah + bh * t) + "";
|
||||
};
|
||||
};
|
||||
|
||||
function lab(l, a, b) {
|
||||
return new Lab(l, a, b);
|
||||
}
|
||||
|
||||
function Lab(l, a, b) {
|
||||
this.l = l;
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
}
|
||||
|
||||
Lab.prototype.brighter = function(k) {
|
||||
return lab(Math.min(100, this.l + K * (arguments.length ? k : 1)), this.a, this.b);
|
||||
};
|
||||
|
||||
Lab.prototype.darker = function(k) {
|
||||
return lab(Math.max(0, this.l - K * (arguments.length ? k : 1)), this.a, this.b);
|
||||
};
|
||||
|
||||
Lab.prototype.rgb = function() {
|
||||
return lab_rgb(this.l, this.a, this.b);
|
||||
};
|
||||
|
||||
Lab.prototype.toString = function() {
|
||||
return this.rgb() + "";
|
||||
};
|
||||
|
||||
function lch(l, c, h) {
|
||||
return new Lch(l, c, h);
|
||||
}
|
||||
|
||||
function Lch(l, c, h) {
|
||||
this.l = l;
|
||||
this.c = c;
|
||||
this.h = h;
|
||||
}
|
||||
|
||||
Lch.prototype.brighter = function(k) {
|
||||
return lch(Math.min(100, this.l + K * (arguments.length ? k : 1)), this.c, this.h);
|
||||
};
|
||||
|
||||
Lch.prototype.darker = function(k) {
|
||||
return lch(Math.max(0, this.l - K * (arguments.length ? k : 1)), this.c, this.h);
|
||||
};
|
||||
|
||||
Lch.prototype.rgb = function() {
|
||||
return lch_lab(this.l, this.c, this.h).rgb();
|
||||
};
|
||||
|
||||
Lch.prototype.toString = function() {
|
||||
return this.rgb() + "";
|
||||
};
|
||||
|
||||
// Corresponds roughly to RGB brighter/darker
|
||||
var K = 18;
|
||||
|
||||
// D65 standard referent
|
||||
var X = 0.950470, Y = 1, Z = 1.088830;
|
||||
|
||||
function lab_rgb(l, a, b) {
|
||||
var y = (l + 16) / 116, x = y + a / 500, z = y - b / 200;
|
||||
x = lab_xyz(x) * X;
|
||||
y = lab_xyz(y) * Y;
|
||||
z = lab_xyz(z) * Z;
|
||||
return d3.rgb(
|
||||
xyz_rgb( 3.2404542 * x - 1.5371385 * y - 0.4985314 * z),
|
||||
xyz_rgb(-0.9692660 * x + 1.8760108 * y + 0.0415560 * z),
|
||||
xyz_rgb( 0.0556434 * x - 0.2040259 * y + 1.0572252 * z)
|
||||
);
|
||||
}
|
||||
|
||||
function rgb_lab(r, g, b) {
|
||||
r = rgb_xyz(r);
|
||||
g = rgb_xyz(g);
|
||||
b = rgb_xyz(b);
|
||||
var x = xyz_lab((0.4124564 * r + 0.3575761 * g + 0.1804375 * b) / X),
|
||||
y = xyz_lab((0.2126729 * r + 0.7151522 * g + 0.0721750 * b) / Y),
|
||||
z = xyz_lab((0.0193339 * r + 0.1191920 * g + 0.9503041 * b) / Z);
|
||||
return lab(116 * y - 16, 500 * (x - y), 200 * (y - z));
|
||||
}
|
||||
|
||||
function lab_lch(l, a, b) {
|
||||
var c = Math.sqrt(a * a + b * b),
|
||||
h = Math.atan2(b, a) / Math.PI * 180;
|
||||
return lch(l, c, h);
|
||||
}
|
||||
|
||||
function lch_lab(l, c, h) {
|
||||
h = h * Math.PI / 180;
|
||||
return lab(l, Math.cos(h) * c, Math.sin(h) * c);
|
||||
}
|
||||
|
||||
function lab_xyz(x) {
|
||||
return x > 0.206893034 ? x * x * x : (x - 4 / 29) / 7.787037;
|
||||
}
|
||||
|
||||
function xyz_lab(x) {
|
||||
return x > 0.008856 ? Math.pow(x, 1 / 3) : 7.787037 * x + 4 / 29;
|
||||
}
|
||||
|
||||
function xyz_rgb(r) {
|
||||
return Math.round(255 * (r <= 0.00304 ? 12.92 * r : 1.055 * Math.pow(r, 1 / 2.4) - 0.055));
|
||||
}
|
||||
|
||||
function rgb_xyz(r) {
|
||||
return (r /= 255) <= 0.04045 ? r / 12.92 : Math.pow((r + 0.055) / 1.055, 2.4);
|
||||
}
|
||||
})(d3);
|
||||
@@ -0,0 +1,302 @@
|
||||
// This product includes color specifications and designs developed by Cynthia Brewer (http://colorbrewer.org/).
|
||||
var colorbrewer = {YlGn: {
|
||||
3: ["#f7fcb9","#addd8e","#31a354"],
|
||||
4: ["#ffffcc","#c2e699","#78c679","#238443"],
|
||||
5: ["#ffffcc","#c2e699","#78c679","#31a354","#006837"],
|
||||
6: ["#ffffcc","#d9f0a3","#addd8e","#78c679","#31a354","#006837"],
|
||||
7: ["#ffffcc","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#005a32"],
|
||||
8: ["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#005a32"],
|
||||
9: ["#ffffe5","#f7fcb9","#d9f0a3","#addd8e","#78c679","#41ab5d","#238443","#006837","#004529"]
|
||||
},YlGnBu: {
|
||||
3: ["#edf8b1","#7fcdbb","#2c7fb8"],
|
||||
4: ["#ffffcc","#a1dab4","#41b6c4","#225ea8"],
|
||||
5: ["#ffffcc","#a1dab4","#41b6c4","#2c7fb8","#253494"],
|
||||
6: ["#ffffcc","#c7e9b4","#7fcdbb","#41b6c4","#2c7fb8","#253494"],
|
||||
7: ["#ffffcc","#c7e9b4","#7fcdbb","#41b6c4","#1d91c0","#225ea8","#0c2c84"],
|
||||
8: ["#ffffd9","#edf8b1","#c7e9b4","#7fcdbb","#41b6c4","#1d91c0","#225ea8","#0c2c84"],
|
||||
9: ["#ffffd9","#edf8b1","#c7e9b4","#7fcdbb","#41b6c4","#1d91c0","#225ea8","#253494","#081d58"]
|
||||
},GnBu: {
|
||||
3: ["#e0f3db","#a8ddb5","#43a2ca"],
|
||||
4: ["#f0f9e8","#bae4bc","#7bccc4","#2b8cbe"],
|
||||
5: ["#f0f9e8","#bae4bc","#7bccc4","#43a2ca","#0868ac"],
|
||||
6: ["#f0f9e8","#ccebc5","#a8ddb5","#7bccc4","#43a2ca","#0868ac"],
|
||||
7: ["#f0f9e8","#ccebc5","#a8ddb5","#7bccc4","#4eb3d3","#2b8cbe","#08589e"],
|
||||
8: ["#f7fcf0","#e0f3db","#ccebc5","#a8ddb5","#7bccc4","#4eb3d3","#2b8cbe","#08589e"],
|
||||
9: ["#f7fcf0","#e0f3db","#ccebc5","#a8ddb5","#7bccc4","#4eb3d3","#2b8cbe","#0868ac","#084081"]
|
||||
},BuGn: {
|
||||
3: ["#e5f5f9","#99d8c9","#2ca25f"],
|
||||
4: ["#edf8fb","#b2e2e2","#66c2a4","#238b45"],
|
||||
5: ["#edf8fb","#b2e2e2","#66c2a4","#2ca25f","#006d2c"],
|
||||
6: ["#edf8fb","#ccece6","#99d8c9","#66c2a4","#2ca25f","#006d2c"],
|
||||
7: ["#edf8fb","#ccece6","#99d8c9","#66c2a4","#41ae76","#238b45","#005824"],
|
||||
8: ["#f7fcfd","#e5f5f9","#ccece6","#99d8c9","#66c2a4","#41ae76","#238b45","#005824"],
|
||||
9: ["#f7fcfd","#e5f5f9","#ccece6","#99d8c9","#66c2a4","#41ae76","#238b45","#006d2c","#00441b"]
|
||||
},PuBuGn: {
|
||||
3: ["#ece2f0","#a6bddb","#1c9099"],
|
||||
4: ["#f6eff7","#bdc9e1","#67a9cf","#02818a"],
|
||||
5: ["#f6eff7","#bdc9e1","#67a9cf","#1c9099","#016c59"],
|
||||
6: ["#f6eff7","#d0d1e6","#a6bddb","#67a9cf","#1c9099","#016c59"],
|
||||
7: ["#f6eff7","#d0d1e6","#a6bddb","#67a9cf","#3690c0","#02818a","#016450"],
|
||||
8: ["#fff7fb","#ece2f0","#d0d1e6","#a6bddb","#67a9cf","#3690c0","#02818a","#016450"],
|
||||
9: ["#fff7fb","#ece2f0","#d0d1e6","#a6bddb","#67a9cf","#3690c0","#02818a","#016c59","#014636"]
|
||||
},PuBu: {
|
||||
3: ["#ece7f2","#a6bddb","#2b8cbe"],
|
||||
4: ["#f1eef6","#bdc9e1","#74a9cf","#0570b0"],
|
||||
5: ["#f1eef6","#bdc9e1","#74a9cf","#2b8cbe","#045a8d"],
|
||||
6: ["#f1eef6","#d0d1e6","#a6bddb","#74a9cf","#2b8cbe","#045a8d"],
|
||||
7: ["#f1eef6","#d0d1e6","#a6bddb","#74a9cf","#3690c0","#0570b0","#034e7b"],
|
||||
8: ["#fff7fb","#ece7f2","#d0d1e6","#a6bddb","#74a9cf","#3690c0","#0570b0","#034e7b"],
|
||||
9: ["#fff7fb","#ece7f2","#d0d1e6","#a6bddb","#74a9cf","#3690c0","#0570b0","#045a8d","#023858"]
|
||||
},BuPu: {
|
||||
3: ["#e0ecf4","#9ebcda","#8856a7"],
|
||||
4: ["#edf8fb","#b3cde3","#8c96c6","#88419d"],
|
||||
5: ["#edf8fb","#b3cde3","#8c96c6","#8856a7","#810f7c"],
|
||||
6: ["#edf8fb","#bfd3e6","#9ebcda","#8c96c6","#8856a7","#810f7c"],
|
||||
7: ["#edf8fb","#bfd3e6","#9ebcda","#8c96c6","#8c6bb1","#88419d","#6e016b"],
|
||||
8: ["#f7fcfd","#e0ecf4","#bfd3e6","#9ebcda","#8c96c6","#8c6bb1","#88419d","#6e016b"],
|
||||
9: ["#f7fcfd","#e0ecf4","#bfd3e6","#9ebcda","#8c96c6","#8c6bb1","#88419d","#810f7c","#4d004b"]
|
||||
},RdPu: {
|
||||
3: ["#fde0dd","#fa9fb5","#c51b8a"],
|
||||
4: ["#feebe2","#fbb4b9","#f768a1","#ae017e"],
|
||||
5: ["#feebe2","#fbb4b9","#f768a1","#c51b8a","#7a0177"],
|
||||
6: ["#feebe2","#fcc5c0","#fa9fb5","#f768a1","#c51b8a","#7a0177"],
|
||||
7: ["#feebe2","#fcc5c0","#fa9fb5","#f768a1","#dd3497","#ae017e","#7a0177"],
|
||||
8: ["#fff7f3","#fde0dd","#fcc5c0","#fa9fb5","#f768a1","#dd3497","#ae017e","#7a0177"],
|
||||
9: ["#fff7f3","#fde0dd","#fcc5c0","#fa9fb5","#f768a1","#dd3497","#ae017e","#7a0177","#49006a"]
|
||||
},PuRd: {
|
||||
3: ["#e7e1ef","#c994c7","#dd1c77"],
|
||||
4: ["#f1eef6","#d7b5d8","#df65b0","#ce1256"],
|
||||
5: ["#f1eef6","#d7b5d8","#df65b0","#dd1c77","#980043"],
|
||||
6: ["#f1eef6","#d4b9da","#c994c7","#df65b0","#dd1c77","#980043"],
|
||||
7: ["#f1eef6","#d4b9da","#c994c7","#df65b0","#e7298a","#ce1256","#91003f"],
|
||||
8: ["#f7f4f9","#e7e1ef","#d4b9da","#c994c7","#df65b0","#e7298a","#ce1256","#91003f"],
|
||||
9: ["#f7f4f9","#e7e1ef","#d4b9da","#c994c7","#df65b0","#e7298a","#ce1256","#980043","#67001f"]
|
||||
},OrRd: {
|
||||
3: ["#fee8c8","#fdbb84","#e34a33"],
|
||||
4: ["#fef0d9","#fdcc8a","#fc8d59","#d7301f"],
|
||||
5: ["#fef0d9","#fdcc8a","#fc8d59","#e34a33","#b30000"],
|
||||
6: ["#fef0d9","#fdd49e","#fdbb84","#fc8d59","#e34a33","#b30000"],
|
||||
7: ["#fef0d9","#fdd49e","#fdbb84","#fc8d59","#ef6548","#d7301f","#990000"],
|
||||
8: ["#fff7ec","#fee8c8","#fdd49e","#fdbb84","#fc8d59","#ef6548","#d7301f","#990000"],
|
||||
9: ["#fff7ec","#fee8c8","#fdd49e","#fdbb84","#fc8d59","#ef6548","#d7301f","#b30000","#7f0000"]
|
||||
},YlOrRd: {
|
||||
3: ["#ffeda0","#feb24c","#f03b20"],
|
||||
4: ["#ffffb2","#fecc5c","#fd8d3c","#e31a1c"],
|
||||
5: ["#ffffb2","#fecc5c","#fd8d3c","#f03b20","#bd0026"],
|
||||
6: ["#ffffb2","#fed976","#feb24c","#fd8d3c","#f03b20","#bd0026"],
|
||||
7: ["#ffffb2","#fed976","#feb24c","#fd8d3c","#fc4e2a","#e31a1c","#b10026"],
|
||||
8: ["#ffffcc","#ffeda0","#fed976","#feb24c","#fd8d3c","#fc4e2a","#e31a1c","#b10026"],
|
||||
9: ["#ffffcc","#ffeda0","#fed976","#feb24c","#fd8d3c","#fc4e2a","#e31a1c","#bd0026","#800026"]
|
||||
},YlOrBr: {
|
||||
3: ["#fff7bc","#fec44f","#d95f0e"],
|
||||
4: ["#ffffd4","#fed98e","#fe9929","#cc4c02"],
|
||||
5: ["#ffffd4","#fed98e","#fe9929","#d95f0e","#993404"],
|
||||
6: ["#ffffd4","#fee391","#fec44f","#fe9929","#d95f0e","#993404"],
|
||||
7: ["#ffffd4","#fee391","#fec44f","#fe9929","#ec7014","#cc4c02","#8c2d04"],
|
||||
8: ["#ffffe5","#fff7bc","#fee391","#fec44f","#fe9929","#ec7014","#cc4c02","#8c2d04"],
|
||||
9: ["#ffffe5","#fff7bc","#fee391","#fec44f","#fe9929","#ec7014","#cc4c02","#993404","#662506"]
|
||||
},Purples: {
|
||||
3: ["#efedf5","#bcbddc","#756bb1"],
|
||||
4: ["#f2f0f7","#cbc9e2","#9e9ac8","#6a51a3"],
|
||||
5: ["#f2f0f7","#cbc9e2","#9e9ac8","#756bb1","#54278f"],
|
||||
6: ["#f2f0f7","#dadaeb","#bcbddc","#9e9ac8","#756bb1","#54278f"],
|
||||
7: ["#f2f0f7","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#4a1486"],
|
||||
8: ["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#4a1486"],
|
||||
9: ["#fcfbfd","#efedf5","#dadaeb","#bcbddc","#9e9ac8","#807dba","#6a51a3","#54278f","#3f007d"]
|
||||
},Blues: {
|
||||
3: ["#deebf7","#9ecae1","#3182bd"],
|
||||
4: ["#eff3ff","#bdd7e7","#6baed6","#2171b5"],
|
||||
5: ["#eff3ff","#bdd7e7","#6baed6","#3182bd","#08519c"],
|
||||
6: ["#eff3ff","#c6dbef","#9ecae1","#6baed6","#3182bd","#08519c"],
|
||||
7: ["#eff3ff","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#084594"],
|
||||
8: ["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#084594"],
|
||||
9: ["#f7fbff","#deebf7","#c6dbef","#9ecae1","#6baed6","#4292c6","#2171b5","#08519c","#08306b"]
|
||||
},Greens: {
|
||||
3: ["#e5f5e0","#a1d99b","#31a354"],
|
||||
4: ["#edf8e9","#bae4b3","#74c476","#238b45"],
|
||||
5: ["#edf8e9","#bae4b3","#74c476","#31a354","#006d2c"],
|
||||
6: ["#edf8e9","#c7e9c0","#a1d99b","#74c476","#31a354","#006d2c"],
|
||||
7: ["#edf8e9","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#005a32"],
|
||||
8: ["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#005a32"],
|
||||
9: ["#f7fcf5","#e5f5e0","#c7e9c0","#a1d99b","#74c476","#41ab5d","#238b45","#006d2c","#00441b"]
|
||||
},Oranges: {
|
||||
3: ["#fee6ce","#fdae6b","#e6550d"],
|
||||
4: ["#feedde","#fdbe85","#fd8d3c","#d94701"],
|
||||
5: ["#feedde","#fdbe85","#fd8d3c","#e6550d","#a63603"],
|
||||
6: ["#feedde","#fdd0a2","#fdae6b","#fd8d3c","#e6550d","#a63603"],
|
||||
7: ["#feedde","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#8c2d04"],
|
||||
8: ["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#8c2d04"],
|
||||
9: ["#fff5eb","#fee6ce","#fdd0a2","#fdae6b","#fd8d3c","#f16913","#d94801","#a63603","#7f2704"]
|
||||
},Reds: {
|
||||
3: ["#fee0d2","#fc9272","#de2d26"],
|
||||
4: ["#fee5d9","#fcae91","#fb6a4a","#cb181d"],
|
||||
5: ["#fee5d9","#fcae91","#fb6a4a","#de2d26","#a50f15"],
|
||||
6: ["#fee5d9","#fcbba1","#fc9272","#fb6a4a","#de2d26","#a50f15"],
|
||||
7: ["#fee5d9","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#99000d"],
|
||||
8: ["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#99000d"],
|
||||
9: ["#fff5f0","#fee0d2","#fcbba1","#fc9272","#fb6a4a","#ef3b2c","#cb181d","#a50f15","#67000d"]
|
||||
},Greys: {
|
||||
3: ["#f0f0f0","#bdbdbd","#636363"],
|
||||
4: ["#f7f7f7","#cccccc","#969696","#525252"],
|
||||
5: ["#f7f7f7","#cccccc","#969696","#636363","#252525"],
|
||||
6: ["#f7f7f7","#d9d9d9","#bdbdbd","#969696","#636363","#252525"],
|
||||
7: ["#f7f7f7","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525"],
|
||||
8: ["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525"],
|
||||
9: ["#ffffff","#f0f0f0","#d9d9d9","#bdbdbd","#969696","#737373","#525252","#252525","#000000"]
|
||||
},PuOr: {
|
||||
3: ["#f1a340","#f7f7f7","#998ec3"],
|
||||
4: ["#e66101","#fdb863","#b2abd2","#5e3c99"],
|
||||
5: ["#e66101","#fdb863","#f7f7f7","#b2abd2","#5e3c99"],
|
||||
6: ["#b35806","#f1a340","#fee0b6","#d8daeb","#998ec3","#542788"],
|
||||
7: ["#b35806","#f1a340","#fee0b6","#f7f7f7","#d8daeb","#998ec3","#542788"],
|
||||
8: ["#b35806","#e08214","#fdb863","#fee0b6","#d8daeb","#b2abd2","#8073ac","#542788"],
|
||||
9: ["#b35806","#e08214","#fdb863","#fee0b6","#f7f7f7","#d8daeb","#b2abd2","#8073ac","#542788"],
|
||||
10: ["#7f3b08","#b35806","#e08214","#fdb863","#fee0b6","#d8daeb","#b2abd2","#8073ac","#542788","#2d004b"],
|
||||
11: ["#7f3b08","#b35806","#e08214","#fdb863","#fee0b6","#f7f7f7","#d8daeb","#b2abd2","#8073ac","#542788","#2d004b"]
|
||||
},BrBG: {
|
||||
3: ["#d8b365","#f5f5f5","#5ab4ac"],
|
||||
4: ["#a6611a","#dfc27d","#80cdc1","#018571"],
|
||||
5: ["#a6611a","#dfc27d","#f5f5f5","#80cdc1","#018571"],
|
||||
6: ["#8c510a","#d8b365","#f6e8c3","#c7eae5","#5ab4ac","#01665e"],
|
||||
7: ["#8c510a","#d8b365","#f6e8c3","#f5f5f5","#c7eae5","#5ab4ac","#01665e"],
|
||||
8: ["#8c510a","#bf812d","#dfc27d","#f6e8c3","#c7eae5","#80cdc1","#35978f","#01665e"],
|
||||
9: ["#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e"],
|
||||
10: ["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"],
|
||||
11: ["#543005","#8c510a","#bf812d","#dfc27d","#f6e8c3","#f5f5f5","#c7eae5","#80cdc1","#35978f","#01665e","#003c30"]
|
||||
},PRGn: {
|
||||
3: ["#af8dc3","#f7f7f7","#7fbf7b"],
|
||||
4: ["#7b3294","#c2a5cf","#a6dba0","#008837"],
|
||||
5: ["#7b3294","#c2a5cf","#f7f7f7","#a6dba0","#008837"],
|
||||
6: ["#762a83","#af8dc3","#e7d4e8","#d9f0d3","#7fbf7b","#1b7837"],
|
||||
7: ["#762a83","#af8dc3","#e7d4e8","#f7f7f7","#d9f0d3","#7fbf7b","#1b7837"],
|
||||
8: ["#762a83","#9970ab","#c2a5cf","#e7d4e8","#d9f0d3","#a6dba0","#5aae61","#1b7837"],
|
||||
9: ["#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837"],
|
||||
10: ["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"],
|
||||
11: ["#40004b","#762a83","#9970ab","#c2a5cf","#e7d4e8","#f7f7f7","#d9f0d3","#a6dba0","#5aae61","#1b7837","#00441b"]
|
||||
},PiYG: {
|
||||
3: ["#e9a3c9","#f7f7f7","#a1d76a"],
|
||||
4: ["#d01c8b","#f1b6da","#b8e186","#4dac26"],
|
||||
5: ["#d01c8b","#f1b6da","#f7f7f7","#b8e186","#4dac26"],
|
||||
6: ["#c51b7d","#e9a3c9","#fde0ef","#e6f5d0","#a1d76a","#4d9221"],
|
||||
7: ["#c51b7d","#e9a3c9","#fde0ef","#f7f7f7","#e6f5d0","#a1d76a","#4d9221"],
|
||||
8: ["#c51b7d","#de77ae","#f1b6da","#fde0ef","#e6f5d0","#b8e186","#7fbc41","#4d9221"],
|
||||
9: ["#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221"],
|
||||
10: ["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"],
|
||||
11: ["#8e0152","#c51b7d","#de77ae","#f1b6da","#fde0ef","#f7f7f7","#e6f5d0","#b8e186","#7fbc41","#4d9221","#276419"]
|
||||
},RdBu: {
|
||||
3: ["#ef8a62","#f7f7f7","#67a9cf"],
|
||||
4: ["#ca0020","#f4a582","#92c5de","#0571b0"],
|
||||
5: ["#ca0020","#f4a582","#f7f7f7","#92c5de","#0571b0"],
|
||||
6: ["#b2182b","#ef8a62","#fddbc7","#d1e5f0","#67a9cf","#2166ac"],
|
||||
7: ["#b2182b","#ef8a62","#fddbc7","#f7f7f7","#d1e5f0","#67a9cf","#2166ac"],
|
||||
8: ["#b2182b","#d6604d","#f4a582","#fddbc7","#d1e5f0","#92c5de","#4393c3","#2166ac"],
|
||||
9: ["#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac"],
|
||||
10: ["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"],
|
||||
11: ["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#f7f7f7","#d1e5f0","#92c5de","#4393c3","#2166ac","#053061"]
|
||||
},RdGy: {
|
||||
3: ["#ef8a62","#ffffff","#999999"],
|
||||
4: ["#ca0020","#f4a582","#bababa","#404040"],
|
||||
5: ["#ca0020","#f4a582","#ffffff","#bababa","#404040"],
|
||||
6: ["#b2182b","#ef8a62","#fddbc7","#e0e0e0","#999999","#4d4d4d"],
|
||||
7: ["#b2182b","#ef8a62","#fddbc7","#ffffff","#e0e0e0","#999999","#4d4d4d"],
|
||||
8: ["#b2182b","#d6604d","#f4a582","#fddbc7","#e0e0e0","#bababa","#878787","#4d4d4d"],
|
||||
9: ["#b2182b","#d6604d","#f4a582","#fddbc7","#ffffff","#e0e0e0","#bababa","#878787","#4d4d4d"],
|
||||
10: ["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#e0e0e0","#bababa","#878787","#4d4d4d","#1a1a1a"],
|
||||
11: ["#67001f","#b2182b","#d6604d","#f4a582","#fddbc7","#ffffff","#e0e0e0","#bababa","#878787","#4d4d4d","#1a1a1a"]
|
||||
},RdYlBu: {
|
||||
3: ["#fc8d59","#ffffbf","#91bfdb"],
|
||||
4: ["#d7191c","#fdae61","#abd9e9","#2c7bb6"],
|
||||
5: ["#d7191c","#fdae61","#ffffbf","#abd9e9","#2c7bb6"],
|
||||
6: ["#d73027","#fc8d59","#fee090","#e0f3f8","#91bfdb","#4575b4"],
|
||||
7: ["#d73027","#fc8d59","#fee090","#ffffbf","#e0f3f8","#91bfdb","#4575b4"],
|
||||
8: ["#d73027","#f46d43","#fdae61","#fee090","#e0f3f8","#abd9e9","#74add1","#4575b4"],
|
||||
9: ["#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4"],
|
||||
10: ["#a50026","#d73027","#f46d43","#fdae61","#fee090","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"],
|
||||
11: ["#a50026","#d73027","#f46d43","#fdae61","#fee090","#ffffbf","#e0f3f8","#abd9e9","#74add1","#4575b4","#313695"]
|
||||
},Spectral: {
|
||||
3: ["#fc8d59","#ffffbf","#99d594"],
|
||||
4: ["#d7191c","#fdae61","#abdda4","#2b83ba"],
|
||||
5: ["#d7191c","#fdae61","#ffffbf","#abdda4","#2b83ba"],
|
||||
6: ["#d53e4f","#fc8d59","#fee08b","#e6f598","#99d594","#3288bd"],
|
||||
7: ["#d53e4f","#fc8d59","#fee08b","#ffffbf","#e6f598","#99d594","#3288bd"],
|
||||
8: ["#d53e4f","#f46d43","#fdae61","#fee08b","#e6f598","#abdda4","#66c2a5","#3288bd"],
|
||||
9: ["#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd"],
|
||||
10: ["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"],
|
||||
11: ["#9e0142","#d53e4f","#f46d43","#fdae61","#fee08b","#ffffbf","#e6f598","#abdda4","#66c2a5","#3288bd","#5e4fa2"]
|
||||
},RdYlGn: {
|
||||
3: ["#fc8d59","#ffffbf","#91cf60"],
|
||||
4: ["#d7191c","#fdae61","#a6d96a","#1a9641"],
|
||||
5: ["#d7191c","#fdae61","#ffffbf","#a6d96a","#1a9641"],
|
||||
6: ["#d73027","#fc8d59","#fee08b","#d9ef8b","#91cf60","#1a9850"],
|
||||
7: ["#d73027","#fc8d59","#fee08b","#ffffbf","#d9ef8b","#91cf60","#1a9850"],
|
||||
8: ["#d73027","#f46d43","#fdae61","#fee08b","#d9ef8b","#a6d96a","#66bd63","#1a9850"],
|
||||
9: ["#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850"],
|
||||
10: ["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"],
|
||||
11: ["#a50026","#d73027","#f46d43","#fdae61","#fee08b","#ffffbf","#d9ef8b","#a6d96a","#66bd63","#1a9850","#006837"]
|
||||
},Accent: {
|
||||
3: ["#7fc97f","#beaed4","#fdc086"],
|
||||
4: ["#7fc97f","#beaed4","#fdc086","#ffff99"],
|
||||
5: ["#7fc97f","#beaed4","#fdc086","#ffff99","#386cb0"],
|
||||
6: ["#7fc97f","#beaed4","#fdc086","#ffff99","#386cb0","#f0027f"],
|
||||
7: ["#7fc97f","#beaed4","#fdc086","#ffff99","#386cb0","#f0027f","#bf5b17"],
|
||||
8: ["#7fc97f","#beaed4","#fdc086","#ffff99","#386cb0","#f0027f","#bf5b17","#666666"]
|
||||
},Dark2: {
|
||||
3: ["#1b9e77","#d95f02","#7570b3"],
|
||||
4: ["#1b9e77","#d95f02","#7570b3","#e7298a"],
|
||||
5: ["#1b9e77","#d95f02","#7570b3","#e7298a","#66a61e"],
|
||||
6: ["#1b9e77","#d95f02","#7570b3","#e7298a","#66a61e","#e6ab02"],
|
||||
7: ["#1b9e77","#d95f02","#7570b3","#e7298a","#66a61e","#e6ab02","#a6761d"],
|
||||
8: ["#1b9e77","#d95f02","#7570b3","#e7298a","#66a61e","#e6ab02","#a6761d","#666666"]
|
||||
},Paired: {
|
||||
3: ["#a6cee3","#1f78b4","#b2df8a"],
|
||||
4: ["#a6cee3","#1f78b4","#b2df8a","#33a02c"],
|
||||
5: ["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99"],
|
||||
6: ["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c"],
|
||||
7: ["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f"],
|
||||
8: ["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00"],
|
||||
9: ["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6"],
|
||||
10: ["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6","#6a3d9a"],
|
||||
11: ["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6","#6a3d9a","#ffff99"],
|
||||
12: ["#a6cee3","#1f78b4","#b2df8a","#33a02c","#fb9a99","#e31a1c","#fdbf6f","#ff7f00","#cab2d6","#6a3d9a","#ffff99","#b15928"]
|
||||
},Pastel1: {
|
||||
3: ["#fbb4ae","#b3cde3","#ccebc5"],
|
||||
4: ["#fbb4ae","#b3cde3","#ccebc5","#decbe4"],
|
||||
5: ["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6"],
|
||||
6: ["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6","#ffffcc"],
|
||||
7: ["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6","#ffffcc","#e5d8bd"],
|
||||
8: ["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6","#ffffcc","#e5d8bd","#fddaec"],
|
||||
9: ["#fbb4ae","#b3cde3","#ccebc5","#decbe4","#fed9a6","#ffffcc","#e5d8bd","#fddaec","#f2f2f2"]
|
||||
},Pastel2: {
|
||||
3: ["#b3e2cd","#fdcdac","#cbd5e8"],
|
||||
4: ["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4"],
|
||||
5: ["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4","#e6f5c9"],
|
||||
6: ["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4","#e6f5c9","#fff2ae"],
|
||||
7: ["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4","#e6f5c9","#fff2ae","#f1e2cc"],
|
||||
8: ["#b3e2cd","#fdcdac","#cbd5e8","#f4cae4","#e6f5c9","#fff2ae","#f1e2cc","#cccccc"]
|
||||
},Set1: {
|
||||
3: ["#e41a1c","#377eb8","#4daf4a"],
|
||||
4: ["#e41a1c","#377eb8","#4daf4a","#984ea3"],
|
||||
5: ["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00"],
|
||||
6: ["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00","#ffff33"],
|
||||
7: ["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00","#ffff33","#a65628"],
|
||||
8: ["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00","#ffff33","#a65628","#f781bf"],
|
||||
9: ["#e41a1c","#377eb8","#4daf4a","#984ea3","#ff7f00","#ffff33","#a65628","#f781bf","#999999"]
|
||||
},Set2: {
|
||||
3: ["#66c2a5","#fc8d62","#8da0cb"],
|
||||
4: ["#66c2a5","#fc8d62","#8da0cb","#e78ac3"],
|
||||
5: ["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#a6d854"],
|
||||
6: ["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#a6d854","#ffd92f"],
|
||||
7: ["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#a6d854","#ffd92f","#e5c494"],
|
||||
8: ["#66c2a5","#fc8d62","#8da0cb","#e78ac3","#a6d854","#ffd92f","#e5c494","#b3b3b3"]
|
||||
},Set3: {
|
||||
3: ["#8dd3c7","#ffffb3","#bebada"],
|
||||
4: ["#8dd3c7","#ffffb3","#bebada","#fb8072"],
|
||||
5: ["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3"],
|
||||
6: ["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462"],
|
||||
7: ["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69"],
|
||||
8: ["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5"],
|
||||
9: ["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9"],
|
||||
10: ["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd"],
|
||||
11: ["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5"],
|
||||
12: ["#8dd3c7","#ffffb3","#bebada","#fb8072","#80b1d3","#fdb462","#b3de69","#fccde5","#d9d9d9","#bc80bd","#ccebc5","#ffed6f"]
|
||||
}};
|
||||
File diff suppressed because it is too large.
Load diff
Vendored
+1
@@ -0,0 +1 @@
|
||||
(function(a){function b(a){return a}function c(a,b){for(var c=0,d=b.length,e=new Array(d);c<d;++c)e[c]=a[b[c]];return e}function e(a){function b(b,c,d,e){while(d<e){var f=d+e>>1;a(b[f])<c?d=f+1:e=f}return d}function c(b,c,d,e){while(d<e){var f=d+e>>1;c<a(b[f])?e=f:d=f+1}return d}return c.right=c,c.left=b,c}function g(a){function b(a,b,c){var e=c-b,f=(e>>>1)+1;while(--f>0)d(a,f,e,b);return a}function c(a,b,c){var e=c-b,f;while(--e>0)f=a[b],a[b]=a[b+e],a[b+e]=f,d(a,1,e,b);return a}function d(b,c,d,e){var f=b[--e+c],g=a(f),h;while((h=c<<1)<=d){h<d&&a(b[e+h])>a(b[e+h+1])&&h++;if(g<=a(b[e+h]))break;b[e+c]=b[e+h],c=h}b[e+c]=f}return b.sort=c,b}function i(a){function c(c,d,e,f){var g=new Array(f=Math.min(e-d,f)),h,i,j,k;for(i=0;i<f;++i)g[i]=c[d++];b(g,0,f);if(d<e){h=a(g[0]);do if(j=a(k=c[d])>h)g[0]=k,h=a(b(g,0,f)[0]);while(++d<e)}return g}var b=g(a);return c}function k(a){function b(b,c,d){for(var e=c+1;e<d;++e){for(var f=e,g=b[e],h=a(g);f>c&&a(b[f-1])>h;--f)b[f]=b[f-1];b[f]=g}return b}return b}function m(a){function c(a,c,e){return(e-c<n?b:d)(a,c,e)}function d(b,d,e){var f=(e-d)/6|0,g=d+f,h=e-1-f,i=d+e-1>>1,j=i-f,k=i+f,l=b[g],m=a(l),n=b[j],o=a(n),p=b[i],q=a(p),r=b[k],s=a(r),t=b[h],u=a(t),v;m>o&&(v=l,l=n,n=v,v=m,m=o,o=v),s>u&&(v=r,r=t,t=v,v=s,s=u,u=v),m>q&&(v=l,l=p,p=v,v=m,m=q,q=v),o>q&&(v=n,n=p,p=v,v=o,o=q,q=v),m>s&&(v=l,l=r,r=v,v=m,m=s,s=v),q>s&&(v=p,p=r,r=v,v=q,q=s,s=v),o>u&&(v=n,n=t,t=v,v=o,o=u,u=v),o>q&&(v=n,n=p,p=v,v=o,o=q,q=v),s>u&&(v=r,r=t,t=v,v=s,s=u,u=v);var w=n,x=o,y=r,z=s;b[g]=l,b[j]=b[d],b[i]=p,b[k]=b[e-1],b[h]=t;var A=d+1,B=e-2,C=x<=z&&x>=z;if(C)for(var D=A;D<=B;++D){var E=b[D],F=a(E);if(F<x)D!==A&&(b[D]=b[A],b[A]=E),++A;else if(F>x)for(;;){var G=a(b[B]);if(G>x){B--;continue}if(G<x){b[D]=b[A],b[A++]=b[B],b[B--]=E;break}b[D]=b[B],b[B--]=E;break}}else for(var D=A;D<=B;D++){var E=b[D],F=a(E);if(F<x)D!==A&&(b[D]=b[A],b[A]=E),++A;else if(F>z)for(;;){var G=a(b[B]);if(G>z){B--;if(B<D)break;continue}G<x?(b[D]=b[A],b[A++]=b[B],b[B--]=E):(b[D]=b[B],b[B--]=E);break}}b[d]=b[A-1],b[A-1]=w,b[e-1]=b[B+1],b[B+1]=y,c(b,d,A-1),c(b,B+2,e);if(C)return b;if(A<g&&B>h){var H,G;while((H=a(b[A]))<=x&&H>=x)++A;while((G=a(b[B]))<=z&&G>=z)--B;for(var D=A;D<=B;D++){var E=b[D],F=a(E);if(F<=x&&F>=x)D!==A&&(b[D]=b[A],b[A]=E),A++;else if(F<=z&&F>=z)for(;;){var G=a(b[B]);if(G<=z&&G>=z){B--;if(B<D)break;continue}G<x?(b[D]=b[A],b[A++]=b[B],b[B--]=E):(b[D]=b[B],b[B--]=E);break}}}return c(b,A,B+1)}var b=k(a);return c}function t(a){return new Array(a)}function u(a,b){return function(c){var d=c.length;return[a.left(c,b,0,d),a.right(c,b,0,d)]}}function v(a,b){var c=b[0],d=b[1];return function(b){var e=b.length;return[a.left(b,c,0,e),a.left(b,d,0,e)]}}function w(a){return[0,a.length]}function x(){return null}function y(){return 0}function z(a){return a+1}function A(a){return a-1}function B(a){return function(b,c){return b+ +a(c)}}function C(a){return function(b,c){return b-a(c)}}function D(){function p(b){var c=f,d=b.length;return d&&(e=e.concat(b),k=r(k,f+=d),n.forEach(function(a){a(b,c,d)})),a}function q(a){function P(b,d,e){H=b.map(a),I=J(F(e),0,e),H=c(H,I);var g=K(H),h=g[0],i=g[1],j;for(j=0;j<h;++j)k[I[j]+d]|=p;for(j=i;j<e;++j)k[I[j]+d]|=p;if(!d){t=H,D=I,N=h,O=i;return}var l=t,m=D,n=0,o=0;t=new Array(f),D=E(f,f);for(j=0;n<d&&o<e;++j)l[n]<H[o]?(t[j]=l[n],D[j]=m[n++]):(t[j]=H[o],D[j]=I[o++]+d);for(;n<d;++n,++j)t[j]=l[n],D[j]=m[n];for(;o<e;++o,++j)t[j]=H[o],D[j]=I[o]+d;g=K(t),N=g[0],O=g[1]}function Q(a,b,c){L.forEach(function(a){a(H,I,b,c)}),H=I=null}function R(a){var b,c,d,e=a[0],f=a[1],g=[],h=[];if(e<N)for(b=e,c=Math.min(N,f);b<c;++b)k[d=D[b]]^=p,g.push(d);else if(e>N)for(b=N,c=Math.min(e,O);b<c;++b)k[d=D[b]]^=p,h.push(d);if(f>O)for(b=Math.max(e,O),c=f;b<c;++b)k[d=D[b]]^=p,g.push(d);else if(f<O)for(b=Math.max(N,f),c=O;b<c;++b)k[d=D[b]]^=p,h.push(d);return N=e,O=f,l.forEach(function(a){a(p,g,h)}),o}function S(a){return a==null?V():Array.isArray(a)?U(a):T(a)}function T(a){return R((K=u(d,a))(t))}function U(a){return R((K=v(d,a))(t))}function V(){return R((K=w)(t))}function W(a){var b=[],c=O,d;while(--c>=N&&a>0)k[d=D[c]]||(b.push(e[d]),--a);return b}function X(a){function K(b,c,g,i){function Q(){++n===m&&(p=s(p,j<<=1),h=s(h,j),m=G(j))}var o=d,p=E(n,m),t=v,u=F,w=n,y=0,z=0,A,B,C,D,K,L;J&&(t=u=x),d=new Array(n),n=0,h=w>1?r(h,f):E(f,m),w&&(C=(B=o[0]).key);while(z<i&&!((D=a(b[z]))>=D))++z;while(z<i){if(B&&C<=D){K=B,L=C,p[y]=n;if(B=o[++y])C=B.key}else K={key:D,value:u()},L=D;d[n]=K;while(!(D>L)){h[A=c[z]+g]=n,k[A]&q||(K.value=t(K.value,e[A]));if(++z>=i)break;D=a(b[z])}Q()}while(y<w)d[p[y]=n]=o[y++],Q();if(n>y)for(y=0;y<g;++y)h[y]=p[h[y]];A=l.indexOf(H),n>1?(H=M,I=O):(n===1?(H=N,I=P):(H=x,I=x),h=null),l[A]=H}function M(a,b,c){if(a===p||J)return;var f,g,i,j;for(f=0,i=b.length;f<i;++f)k[g=b[f]]&q||(j=d[h[g]],j.value=v(j.value,e[g]));for(f=0,i=c.length;f<i;++f)(k[g=c[f]]&q)===a&&(j=d[h[g]],j.value=w(j.value,e[g]))}function N(a,b,c){if(a===p||J)return;var f,g,h,i=d[0];for(f=0,h=b.length;f<h;++f)k[g=b[f]]&q||(i.value=v(i.value,e[g]));for(f=0,h=c.lengthLine truncated
|
||||
Vendored
+7033
File diff suppressed because it is too large.
Load diff
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
(function(){function e(e,t){try{for(var n in t)Object.defineProperty(e.prototype,n,{value:t[n],enumerable:!1})}catch(r){e.prototype=t}}function t(e){var t=-1,n=e.length,r=[];while(++t<n)r.push(e[t]);return r}function n(e){return Array.prototype.slice.call(e)}function r(){}function i(e){return e}function s(){return this}function o(){return!0}function u(e){return typeof e=="function"?e:function(){return e}}function a(e,t,n){return function(){var r=n.apply(t,arguments);return arguments.length?e:r}}function f(e){return e!=null&&!isNaN(e)}function l(e){return e.length}function c(e){return e==null}function h(e){return e.trim().replace(/\s+/g," ")}function p(e){var t=1;while(e*t%1)t*=10;return t}function d(){}function v(e){function t(){var t=n,r=-1,i=t.length,s;while(++r<i)(s=t[r].on)&&s.apply(this,arguments);return e}var n=[],i=new r;return t.on=function(t,r){var s=i.get(t),o;return arguments.length<2?s&&s.on:(s&&(s.on=null,n=n.slice(0,o=n.indexOf(s)).concat(n.slice(o+1)),i.remove(t)),r&&n.push(i.set(t,{on:r})),e)},t}function m(e,t){return t-(e?1+Math.floor(Math.log(e+Math.pow(10,1+Math.floor(Math.log(e)/Math.LN10)-t))/Math.LN10):1)}function g(e){return e+""}function y(e){var t=e.lastIndexOf("."),n=t>=0?e.substring(t):(t=e.length,""),r=[];while(t>0)r.push(e.substring(t-=3,t+3));return r.reverse().join(",")+n}function b(e,t){var n=Math.pow(10,Math.abs(8-t)*3);return{scale:t>8?function(e){return e/n}:function(e){return e*n},symbol:e}}function w(e){return function(t){return t<=0?0:t>=1?1:e(t)}}function E(e){return function(t){return 1-e(1-t)}}function S(e){return function(t){return.5*(t<.5?e(2*t):2-e(2-2*t))}}function x(e){return e}function T(e){return function(t){return Math.pow(t,e)}}function N(e){return 1-Math.cos(e*Math.PI/2)}function C(e){return Math.pow(2,10*(e-1))}function k(e){return 1-Math.sqrt(1-e*e)}function L(e,t){var n;return arguments.length<2&&(t=.45),arguments.length<1?(e=1,n=t/4):n=t/(2*Math.PI)*Math.asin(1/e),function(r){return 1+e*Math.pow(2,10*-r)*Math.sin((r-n)*2*Math.PI/t)}}function A(e){return e||(e=1.70158),function(t){return t*t*((e+1)*t-e)}}function O(e){return e<1/2.75?7.5625*e*e:e<2/2.75?7.5625*(e-=1.5/2.75)*e+.75:e<2.5/2.75?7.5625*(e-=2.25/2.75)*e+.9375:7.5625*(e-=2.625/2.75)*e+.984375}function M(){d3.event.stopPropagation(),d3.event.preventDefault()}function _(){var e=d3.event,t;while(t=e.sourceEvent)e=t;return e}function D(e){var t=new d,n=0,r=arguments.length;while(++n<r)t[arguments[n]]=v(t);return t.of=function(n,r){return function(i){try{var s=i.sourceEvent=d3.event;i.target=e,d3.event=i,t[i.type].apply(n,r)}finally{d3.event=s}}},t}function P(e){var t=[e.a,e.b],n=[e.c,e.d],r=B(t),i=H(t,n),s=B(j(n,t,-i))||0;t[0]*n[1]<n[0]*t[1]&&(t[0]*=-1,t[1]*=-1,r*=-1,i*=-1),this.rotate=(r?Math.atan2(t[1],t[0]):Math.atan2(-n[0],n[1]))*fs,this.translate=[e.e,e.f],this.scale=[r,s],this.skew=s?Math.atan2(i,s)*fs:0}function H(e,t){return e[0]*t[0]+e[1]*t[1]}function B(e){var t=Math.sqrt(H(e,e));return t&&(e[0]/=t,e[1]/=t),t}function j(e,t,n){return e[0]+=n*t[0],e[1]+=n*t[1],e}function F(e){return e=="transform"?d3.interpolateTransform:d3.interpolate}function I(e,t){return t=t-(e=+e)?1/(t-e):0,function(n){return(n-e)*t}}function q(e,t){return t=t-(e=+e)?1/(t-e):0,function(n){return Math.max(0,Math.min(1,(n-e)*t))}}function R(e,t,n){return new U(e,t,n)}function U(e,t,n){this.r=e,this.g=t,this.b=n}function z(e){return e<16?"0"+Math.max(0,e).toString(16):Math.min(255,e).toString(16)}function W(e,t,n){var r=0,i=0,s=0,o,u,a;o=/([a-z]+)\((.*)\)/i.exec(e);if(o){u=o[2].split(",");switch(o[1]){case"hsl":return n(parseFloat(u[0]),parseFloat(u[1])/100,parseFloat(u[2])/100);case"rgb":return t(J(u[0]),J(u[1]),J(u[2]))}}return(a=hs.get(e))?t(a.r,a.g,a.b):(e!=null&&e.charAt(0)==="#"&&(e.length===4?(r=e.charAt(1),r+=r,i=e.charAt(2),i+=i,s=e.charAt(3),s+=s):e.length===7&&(r=e.substring(1,3),i=e.substring(3,5),s=e.substring(5,7)),r=parseInt(r,16),i=parseInt(i,16),s=parseInt(s,16)),t(r,i,s))}function X(e,t,n){var r=Math.min(e/=255,t/=255,n/=255),i=Math.max(e,t,n),s=i-r,o,u,a=(i+r)/2;return s?(u=a<.5?s/(i+r):s/(2-i-r),e==i?o=(t-n)/s+(t<n?6:0):t==i?o=(n-e)/s+2:o=(e-t)/s+4,o*=60):u=o=0,K(o,u,a)}function V(e,t,n){e=$(e),t=$(t),n=$(n);var r=ot((.4124564*e+.3575761*t+.1804375*n)/ds),i=ot((.2126729*e+.7151522*t+.072175*n)/vs),s=ot((.0193339*e+.119192*t+.9503041*n)/ms);return tt(116*i-16,500*(r-i),200*(i-s))}function $(e){return(e/=255)<=.04045?e/12.92:Math.pow((e+.055)/1.055,2.4)}function J(e){var t=parseFloat(e);return e.charAt(e.length-1)==="%"?Math.round(t*2.55):t}function K(e,t,n){return new Q(e,t,n)}function Q(e,t,n){this.h=e,this.s=t,this.l=n}function G(e,t,n){function r(e){return e>360?e-=360:e<0&&(e+=360),e<60?s+(o-s)*e/60:e<180?o:e<240?s+(o-s)*(240-e)/60:s}function i(e){return Math.round(r(e)*255)}var s,o;return e%=360,e<0&&(e+=360),t=t<0?0:t>1?1:t,n=n<0?0:n>1?1:n,o=n<=.5?n*(1+t):n+t-n*t,s=2*n-o,R(i(e+120),i(e),i(e-120))}function Y(e,t,n){return new Z(e,t,n)}function Z(e,t,n){this.h=e,this.c=t,this.l=n}function et(e,t,nLine truncated
|
||||
),r.insert(a,h),m=i.intersect(h,f),m&&s.insert(h,m,i.distance(m,o)),o=n.list.shift();else{if(!!s.empty())break;a=s.extractMin(),l=r.left(a),f=r.right(a),c=r.right(f),p=r.leftRegion(a),d=r.rightRegion(f),g=a.vertex,i.endPoint(a.edge,a.side,g),i.endPoint(f.edge,f.side,g),r.del(a),s.del(f),r.del(f),b="l",p.y>d.y&&(v=p,p=d,d=v,b="r"),y=i.bisect(p,d),h=r.createHalfEdge(y,b),r.insert(l,h),i.endPoint(y,ho[b],g),m=i.intersect(l,h),m&&(s.del(l),s.insert(l,m,i.distance(m,p))),m=i.intersect(h,c),m&&s.insert(h,m,i.distance(m,p))}}for(a=r.right(r.leftEnd);a!=r.rightEnd;a=r.right(a))t(a.edge)}function ui(){return{leaf:!0,nodes:[],point:null}}function ai(e,t,n,r,i,s){if(!e(t,n,r,i,s)){var o=(n+i)*.5,u=(r+s)*.5,a=t.nodes;a[0]&&ai(e,a[0],n,r,o,u),a[1]&&ai(e,a[1],o,r,i,u),a[2]&&ai(e,a[2],n,u,o,s),a[3]&&ai(e,a[3],o,u,i,s)}}function fi(e){return{x:e[0],y:e[1]}}function li(){this._=new Date(arguments.length>1?Date.UTC.apply(this,arguments):arguments[0])}function ci(e){return e.substring(0,3)}function hi(e,t,n,r){var i,s,o=0,u=t.length,a=n.length;while(o<u){if(r>=a)return-1;i=t.charCodeAt(o++);if(i==37){s=Ho[t.charAt(o++)];if(!s||(r=s(e,n,r))<0)return-1}else if(i!=n.charCodeAt(r++))return-1}return r}function pi(e){return new RegExp("^(?:"+e.map(d3.requote).join("|")+")","i")}function di(e){var t=new r,n=-1,i=e.length;while(++n<i)t.set(e[n].toLowerCase(),n);return t}function vi(e,t,n){Ao.lastIndex=0;var r=Ao.exec(t.substring(n));return r?n+=r[0].length:-1}function mi(e,t,n){Lo.lastIndex=0;var r=Lo.exec(t.substring(n));return r?n+=r[0].length:-1}function gi(e,t,n){_o.lastIndex=0;var r=_o.exec(t.substring(n));return r?(e.m=Do.get(r[0].toLowerCase()),n+=r[0].length):-1}function yi(e,t,n){Oo.lastIndex=0;var r=Oo.exec(t.substring(n));return r?(e.m=Mo.get(r[0].toLowerCase()),n+=r[0].length):-1}function bi(e,t,n){return hi(e,Po.c.toString(),t,n)}function wi(e,t,n){return hi(e,Po.x.toString(),t,n)}function Ei(e,t,n){return hi(e,Po.X.toString(),t,n)}function Si(e,t,n){Bo.lastIndex=0;var r=Bo.exec(t.substring(n,n+4));return r?(e.y=+r[0],n+=r[0].length):-1}function xi(e,t,n){Bo.lastIndex=0;var r=Bo.exec(t.substring(n,n+2));return r?(e.y=Ti(+r[0]),n+=r[0].length):-1}function Ti(e){return e+(e>68?1900:2e3)}function Ni(e,t,n){Bo.lastIndex=0;var r=Bo.exec(t.substring(n,n+2));return r?(e.m=r[0]-1,n+=r[0].length):-1}function Ci(e,t,n){Bo.lastIndex=0;var r=Bo.exec(t.substring(n,n+2));return r?(e.d=+r[0],n+=r[0].length):-1}function ki(e,t,n){Bo.lastIndex=0;var r=Bo.exec(t.substring(n,n+2));return r?(e.H=+r[0],n+=r[0].length):-1}function Li(e,t,n){Bo.lastIndex=0;var r=Bo.exec(t.substring(n,n+2));return r?(e.M=+r[0],n+=r[0].length):-1}function Ai(e,t,n){Bo.lastIndex=0;var r=Bo.exec(t.substring(n,n+2));return r?(e.S=+r[0],n+=r[0].length):-1}function Oi(e,t,n){Bo.lastIndex=0;var r=Bo.exec(t.substring(n,n+3));return r?(e.L=+r[0],n+=r[0].length):-1}function Mi(e,t,n){var r=jo.get(t.substring(n,n+=2).toLowerCase());return r==null?-1:(e.p=r,n)}function _i(e){var t=e.getTimezoneOffset(),n=t>0?"-":"+",r=~~(Math.abs(t)/60),i=Math.abs(t)%60;return n+To(r)+To(i)}function Di(e){return e.toISOString()}function Pi(e,t,n){function r(t){var n=e(t),r=s(n,1);return t-n<r-t?n:r}function i(n){return t(n=e(new po(n-1)),1),n}function s(e,n){return t(e=new po(+e),n),e}function o(e,r,s){var o=i(e),u=[];if(s>1)while(o<r)n(o)%s||u.push(new Date(+o)),t(o,1);else while(o<r)u.push(new Date(+o)),t(o,1);return u}function u(e,t,n){try{po=li;var r=new li;return r._=e,o(r,t,n)}finally{po=Date}}e.floor=e,e.round=r,e.ceil=i,e.offset=s,e.range=o;var a=e.utc=Hi(e);return a.floor=a,a.round=Hi(r),a.ceil=Hi(i),a.offset=Hi(s),a.range=u,e}function Hi(e){return function(t,n){try{po=li;var r=new li;return r._=t,e(r,n)._}finally{po=Date}}}function Bi(e,t,n){function r(t){return e(t)}return r.invert=function(t){return Fi(e.invert(t))},r.domain=function(t){return arguments.length?(e.domain(t),r):e.domain().map(Fi)},r.nice=function(e){return r.domain(Dt(r.domain(),function(){return e}))},r.ticks=function(n,i){var s=ji(r.domain());if(typeof n!="function"){var o=s[1]-s[0],u=o/n,a=d3.bisect(Io,u);if(a==Io.length)return t.year(s,n);if(!a)return e.ticks(n).map(Fi);Math.log(u/Io[a-1])<Math.log(Io[a]/u)&&--a,n=t[a],i=n[1],n=n[0].range}return n(s[0],new Date(+s[1]+1),i)},r.tickFormat=function(){return n},r.copy=function(){return Bi(e.copy(),t,n)},d3.rebind(r,e,"range","rangeRound","interpolate","clamp")}function ji(e){var t=e[0],n=e[e.length-1];return t<n?[t,n]:[n,t]}function Fi(e){return new Date(e)}function Ii(e){return function(t){var n=e.length-1,r=e[n];while(!r[1](t))r=e[--n];return r[0](t)}}function qi(e){var t=new Date(e,0,1);return t.setFullYear(e),t}function Ri(e){var t=e.getFullYear(),n=qi(t),r=qi(t+1);return t+(e-n)/(r-n)}function Ui(e){var t=new Date(Date.UTC(e,0,1));return t.setUTCFullYear(e),t}function zi(e){var t=e.getUTCFullYear(),n=Ui(t),r=Ui(t+1);return t+(e-n)/(r-n)}Date.now||(Date.now=function(){return+(new Date)});try{document.createElement("div").style.setProperty("opacity",0,"")}catLine truncated
|
||||
window.mozRequestAnimationFrame||window.oRequestAnimationFrame||window.msRequestAnimationFrame||function(e){setTimeout(e,17)};d3.mouse=function(e){return At(e,_())};var Is=/WebKit/.test(navigator.userAgent)?-1:0;d3.touches=function(e,t){return arguments.length<2&&(t=_().touches),t?$i(t).map(function(t){var n=At(e,t);return n.identifier=t.identifier,n}):[]},d3.scale={},d3.scale.linear=function(){return Ht([0,1],[0,1],d3.interpolate,!1)},d3.scale.log=function(){return zt(d3.scale.linear(),Wt)};var qs=d3.format(".0e");Wt.pow=function(e){return Math.pow(10,e)},Xt.pow=function(e){return-Math.pow(10,-e)},d3.scale.pow=function(){return Vt(d3.scale.linear(),1)},d3.scale.sqrt=function(){return d3.scale.pow().exponent(.5)},d3.scale.ordinal=function(){return Jt([],{t:"range",a:[[]]})},d3.scale.category10=function(){return d3.scale.ordinal().range(Rs)},d3.scale.category20=function(){return d3.scale.ordinal().range(Us)},d3.scale.category20b=function(){return d3.scale.ordinal().range(zs)},d3.scale.category20c=function(){return d3.scale.ordinal().range(Ws)};var Rs=["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"],Us=["#1f77b4","#aec7e8","#ff7f0e","#ffbb78","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5","#8c564b","#c49c94","#e377c2","#f7b6d2","#7f7f7f","#c7c7c7","#bcbd22","#dbdb8d","#17becf","#9edae5"],zs=["#393b79","#5254a3","#6b6ecf","#9c9ede","#637939","#8ca252","#b5cf6b","#cedb9c","#8c6d31","#bd9e39","#e7ba52","#e7cb94","#843c39","#ad494a","#d6616b","#e7969c","#7b4173","#a55194","#ce6dbd","#de9ed6"],Ws=["#3182bd","#6baed6","#9ecae1","#c6dbef","#e6550d","#fd8d3c","#fdae6b","#fdd0a2","#31a354","#74c476","#a1d99b","#c7e9c0","#756bb1","#9e9ac8","#bcbddc","#dadaeb","#636363","#969696","#bdbdbd","#d9d9d9"];d3.scale.quantile=function(){return Kt([],[])},d3.scale.quantize=function(){return Qt(0,1,[0,1])},d3.scale.threshold=function(){return Gt([.5],[0,1])},d3.scale.identity=function(){return Yt([0,1])},d3.svg={},d3.svg.arc=function(){function e(){var e=t.apply(this,arguments),s=n.apply(this,arguments),o=r.apply(this,arguments)+Xs,u=i.apply(this,arguments)+Xs,a=(u<o&&(a=o,o=u,u=a),u-o),f=a<Math.PI?"0":"1",l=Math.cos(o),c=Math.sin(o),h=Math.cos(u),p=Math.sin(u);return a>=Vs?e?"M0,"+s+"A"+s+","+s+" 0 1,1 0,"+ -s+"A"+s+","+s+" 0 1,1 0,"+s+"M0,"+e+"A"+e+","+e+" 0 1,0 0,"+ -e+"A"+e+","+e+" 0 1,0 0,"+e+"Z":"M0,"+s+"A"+s+","+s+" 0 1,1 0,"+ -s+"A"+s+","+s+" 0 1,1 0,"+s+"Z":e?"M"+s*l+","+s*c+"A"+s+","+s+" 0 "+f+",1 "+s*h+","+s*p+"L"+e*h+","+e*p+"A"+e+","+e+" 0 "+f+",0 "+e*l+","+e*c+"Z":"M"+s*l+","+s*c+"A"+s+","+s+" 0 "+f+",1 "+s*h+","+s*p+"L0,0"+"Z"}var t=Zt,n=en,r=tn,i=nn;return e.innerRadius=function(n){return arguments.length?(t=u(n),e):t},e.outerRadius=function(t){return arguments.length?(n=u(t),e):n},e.startAngle=function(t){return arguments.length?(r=u(t),e):r},e.endAngle=function(t){return arguments.length?(i=u(t),e):i},e.centroid=function(){var e=(t.apply(this,arguments)+n.apply(this,arguments))/2,s=(r.apply(this,arguments)+i.apply(this,arguments))/2+Xs;return[Math.cos(s)*e,Math.sin(s)*e]},e};var Xs=-Math.PI/2,Vs=2*Math.PI-1e-6;d3.svg.line=function(){return rn(i)};var $s=d3.map({linear:un,"linear-closed":an,"step-before":fn,"step-after":ln,basis:mn,"basis-open":gn,"basis-closed":yn,bundle:bn,cardinal:pn,"cardinal-open":cn,"cardinal-closed":hn,monotone:Nn});$s.forEach(function(e,t){t.key=e,t.closed=/-closed$/.test(e)});var Js=[0,2/3,1/3,0],Ks=[0,1/3,2/3,0],Qs=[0,1/6,2/3,1/6];d3.svg.line.radial=function(){var e=rn(Cn);return e.radius=e.x,delete e.x,e.angle=e.y,delete e.y,e},fn.reverse=ln,ln.reverse=fn,d3.svg.area=function(){return kn(i)},d3.svg.area.radial=function(){var e=kn(Cn);return e.radius=e.x,delete e.x,e.innerRadius=e.x0,delete e.x0,e.outerRadius=e.x1,delete e.x1,e.angle=e.y,delete e.y,e.startAngle=e.y0,delete e.y0,e.endAngle=e.y1,delete e.y1,e},d3.svg.chord=function(){function e(e,u){var a=t(this,s,e,u),f=t(this,o,e,u);return"M"+a.p0+r(a.r,a.p1,a.a1-a.a0)+(n(a,f)?i(a.r,a.p1,a.r,a.p0):i(a.r,a.p1,f.r,f.p0)+r(f.r,f.p1,f.a1-f.a0)+i(f.r,f.p1,a.r,a.p0))+"Z"}function t(e,t,n,r){var i=t.call(e,n,r),s=a.call(e,i,r),o=f.call(e,i,r)+Xs,u=l.call(e,i,r)+Xs;return{r:s,a0:o,a1:u,p0:[s*Math.cos(o),s*Math.sin(o)],p1:[s*Math.cos(u),s*Math.sin(u)]}}function n(e,t){return e.a0==t.a0&&e.a1==t.a1}function r(e,t,n){return"A"+e+","+e+" 0 "+ +(n>Math.PI)+",1 "+t}function i(e,t,n,r){return"Q 0,0 "+r}var s=Ln,o=An,a=On,f=tn,l=nn;return e.radius=function(t){return arguments.length?(a=u(t),e):a},e.source=function(t){return arguments.length?(s=u(t),e):s},e.target=function(t){return arguments.length?(o=u(t),e):o},e.startAngle=function(t){return arguments.length?(f=u(t),e):f},e.endAngle=function(t){return arguments.length?(l=u(t),e):l},e},d3.svg.diagonal=function(){function e(e,i){var s=t.call(this,e,i),o=n.call(this,e,i),u=(s.y+o.y)/2,a=[s,{x:s.x,y:u},{x:o.x,y:u},o];return a=a.map(r),"M"+a[0]+"C"+a[1]+" "+a[2]+" "+a[3]}var t=Ln,n=An,r=Dn;return e.source=function(n){return arguments.lengtLine truncated
|
||||
(s=t*ao),e):s/ao},e.origin=function(t){return arguments.length?(r=t[0]*ao,i=t[1]*ao,e):[r/ao,i/ao]},e.scale=function(n){return arguments.length?(t=+n,e):t},e.translate=function(t){return arguments.length?(n=[+t[0],+t[1]],e):n},e.origin([0,0]).parallel(45)},d3.geo.equirectangular=function(){function e(e){var r=e[0]/360,i=-e[1]/360;return[t*r+n[0],t*i+n[1]]}var t=500,n=[480,250];return e.invert=function(e){var r=(e[0]-n[0])/t,i=(e[1]-n[1])/t;return[360*r,-360*i]},e.scale=function(n){return arguments.length?(t=+n,e):t},e.translate=function(t){return arguments.length?(n=[+t[0],+t[1]],e):n},e},d3.geo.mercator=function(){function e(e){var r=e[0]/360,i=-(Math.log(Math.tan(Math.PI/4+e[1]*ao/2))/ao)/360;return[t*r+n[0],t*Math.max(-0.5,Math.min(.5,i))+n[1]]}var t=500,n=[480,250];return e.invert=function(e){var r=(e[0]-n[0])/t,i=(e[1]-n[1])/t;return[360*r,2*Math.atan(Math.exp(-360*i*ao))/ao-90]},e.scale=function(n){return arguments.length?(t=+n,e):t},e.translate=function(t){return arguments.length?(n=[+t[0],+t[1]],e):n},e},d3.geo.path=function(){function e(e,t){typeof s=="function"&&(o=Ur(s.apply(this,arguments))),f(e);var n=a.length?a.join(""):null;return a=[],n}function t(e){return u(e).join(",")}function n(e){var t=i(e[0]),n=0,r=e.length;while(++n<r)t-=i(e[n]);return t}function r(e){var t=d3.geom.polygon(e[0].map(u)),n=t.area(),r=t.centroid(n<0?(n*=-1,1):-1),i=r[0],s=r[1],o=n,a=0,f=e.length;while(++a<f)t=d3.geom.polygon(e[a].map(u)),n=t.area(),r=t.centroid(n<0?(n*=-1,1):-1),i-=r[0],s-=r[1],o-=n;return[i,s,6*o]}function i(e){return Math.abs(d3.geom.polygon(e.map(u)).area())}var s=4.5,o=Ur(s),u=d3.geo.albersUsa(),a=[],f=Rr({FeatureCollection:function(e){var t=e.features,n=-1,r=t.length;while(++n<r)a.push(f(t[n].geometry))},Feature:function(e){f(e.geometry)},Point:function(e){a.push("M",t(e.coordinates),o)},MultiPoint:function(e){var n=e.coordinates,r=-1,i=n.length;while(++r<i)a.push("M",t(n[r]),o)},LineString:function(e){var n=e.coordinates,r=-1,i=n.length;a.push("M");while(++r<i)a.push(t(n[r]),"L");a.pop()},MultiLineString:function(e){var n=e.coordinates,r=-1,i=n.length,s,o,u;while(++r<i){s=n[r],o=-1,u=s.length,a.push("M");while(++o<u)a.push(t(s[o]),"L");a.pop()}},Polygon:function(e){var n=e.coordinates,r=-1,i=n.length,s,o,u;while(++r<i){s=n[r],o=-1;if((u=s.length-1)>0){a.push("M");while(++o<u)a.push(t(s[o]),"L");a[a.length-1]="Z"}}},MultiPolygon:function(e){var n=e.coordinates,r=-1,i=n.length,s,o,u,f,l,c;while(++r<i){s=n[r],o=-1,u=s.length;while(++o<u){f=s[o],l=-1;if((c=f.length-1)>0){a.push("M");while(++l<c)a.push(t(f[l]),"L");a[a.length-1]="Z"}}}},GeometryCollection:function(e){var t=e.geometries,n=-1,r=t.length;while(++n<r)a.push(f(t[n]))}}),l=e.area=Rr({FeatureCollection:function(e){var t=0,n=e.features,r=-1,i=n.length;while(++r<i)t+=l(n[r]);return t},Feature:function(e){return l(e.geometry)},Polygon:function(e){return n(e.coordinates)},MultiPolygon:function(e){var t=0,r=e.coordinates,i=-1,s=r.length;while(++i<s)t+=n(r[i]);return t},GeometryCollection:function(e){var t=0,n=e.geometries,r=-1,i=n.length;while(++r<i)t+=l(n[r]);return t}},0),c=e.centroid=Rr({Feature:function(e){return c(e.geometry)},Polygon:function(e){var t=r(e.coordinates);return[t[0]/t[2],t[1]/t[2]]},MultiPolygon:function(e){var t=0,n=e.coordinates,i,s=0,o=0,u=0,a=-1,f=n.length;while(++a<f)i=r(n[a]),s+=i[0],o+=i[1],u+=i[2];return[s/u,o/u]}});return e.projection=function(t){return u=t,e},e.pointRadius=function(t){return typeof t=="function"?s=t:(s=+t,o=Ur(s)),e},e},d3.geo.bounds=function(e){var t=Infinity,n=Infinity,r=-Infinity,i=-Infinity;return zr(e,function(e,s){e<t&&(t=e),e>r&&(r=e),s<n&&(n=s),s>i&&(i=s)}),[[t,n],[r,i]]};var fo={Feature:Wr,FeatureCollection:Xr,GeometryCollection:Vr,LineString:$r,MultiLineString:Jr,MultiPoint:$r,MultiPolygon:Kr,Point:Qr,Polygon:Gr};d3.geo.circle=function(){function e(){}function t(e){return a.distance(e)<u}function n(e){var t=-1,n=e.length,i=[],s,o,f,l,c;while(++t<n)c=a.distance(f=e[t]),c<u?(o&&i.push(ti(o,f)((l-u)/(l-c))),i.push(f),s=o=null):(o=f,!s&&i.length&&(i.push(ti(i[i.length-1],o)((u-l)/(c-l))),s=o)),l=c;return s=e[0],o=i[0],o&&f[0]===s[0]&&f[1]===s[1]&&(f[0]!==o[0]||f[1]!==o[1])&&i.push(o),r(i)}function r(e){var t=0,n=e.length,r,i,s=n?[e[0]]:e,o,u=a.source();while(++t<n){o=a.source(e[t-1])(e[t]).coordinates;for(r=0,i=o.length;++r<i;)s.push(o[r])}return a.source(u),s}var s=[0,0],o=89.99,u=o*ao,a=d3.geo.greatArc().source(s).target(i);e.clip=function(e){return typeof s=="function"&&a.source(s.apply(this,arguments)),f(e)||null};var f=Rr({FeatureCollection:function(e){var t=e.features.map(f).filter(i);return t&&(e=Object.create(e),e.features=t,e)},Feature:function(e){var t=f(e.geometry);return t&&(e=Object.create(e),e.geometry=t,e)},Point:function(e){return t(e.coordinates)&&e},MultiPoint:function(e){var n=e.coordinates.filter(t);return n.length&&{type:e.type,coordinates:n}},LineString:function(e){var t=n(e.coordinates);return t.length&&(e=Object.create(e),e.coordinates=t,e)},MultiLineString:function(e){vLine truncated
|
||||
Vendored
+8436
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,86 @@
|
||||
(function() {
|
||||
d3.fisheye = {
|
||||
scale: function(scaleType) {
|
||||
return d3_fisheye_scale(scaleType(), 3, 0);
|
||||
},
|
||||
circular: function() {
|
||||
var radius = 200,
|
||||
distortion = 2,
|
||||
k0,
|
||||
k1,
|
||||
focus = [0, 0];
|
||||
|
||||
function fisheye(d) {
|
||||
var dx = d.x - focus[0],
|
||||
dy = d.y - focus[1],
|
||||
dd = Math.sqrt(dx * dx + dy * dy);
|
||||
if (!dd || dd >= radius) return {x: d.x, y: d.y, z: 1};
|
||||
var k = k0 * (1 - Math.exp(-dd * k1)) / dd * .75 + .25;
|
||||
return {x: focus[0] + dx * k, y: focus[1] + dy * k, z: Math.min(k, 10)};
|
||||
}
|
||||
|
||||
function rescale() {
|
||||
k0 = Math.exp(distortion);
|
||||
k0 = k0 / (k0 - 1) * radius;
|
||||
k1 = distortion / radius;
|
||||
return fisheye;
|
||||
}
|
||||
|
||||
fisheye.radius = function(_) {
|
||||
if (!arguments.length) return radius;
|
||||
radius = +_;
|
||||
return rescale();
|
||||
};
|
||||
|
||||
fisheye.distortion = function(_) {
|
||||
if (!arguments.length) return distortion;
|
||||
distortion = +_;
|
||||
return rescale();
|
||||
};
|
||||
|
||||
fisheye.focus = function(_) {
|
||||
if (!arguments.length) return focus;
|
||||
focus = _;
|
||||
return fisheye;
|
||||
};
|
||||
|
||||
return rescale();
|
||||
}
|
||||
};
|
||||
|
||||
function d3_fisheye_scale(scale, d, a) {
|
||||
|
||||
function fisheye(_) {
|
||||
var x = scale(_),
|
||||
left = x < a,
|
||||
v,
|
||||
range = d3.extent(scale.range()),
|
||||
min = range[0],
|
||||
max = range[1],
|
||||
m = left ? a - min : max - a;
|
||||
if (m == 0) m = max - min;
|
||||
return (left ? -1 : 1) * m * (d + 1) / (d + (m / Math.abs(x - a))) + a;
|
||||
}
|
||||
|
||||
fisheye.distortion = function(_) {
|
||||
if (!arguments.length) return d;
|
||||
d = +_;
|
||||
return fisheye;
|
||||
};
|
||||
|
||||
fisheye.focus = function(_) {
|
||||
if (!arguments.length) return a;
|
||||
a = +_;
|
||||
return fisheye;
|
||||
};
|
||||
|
||||
fisheye.copy = function() {
|
||||
return d3_fisheye_scale(scale.copy(), d, a);
|
||||
};
|
||||
|
||||
fisheye.nice = scale.nice;
|
||||
fisheye.ticks = scale.ticks;
|
||||
fisheye.tickFormat = scale.tickFormat;
|
||||
return d3.rebind(fisheye, scale, "domain", "range");
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,80 @@
|
||||
d3.hive = {};
|
||||
|
||||
d3.hive.link = function() {
|
||||
var source = function(d) { return d.source; },
|
||||
target = function(d) { return d.target; },
|
||||
angle = function(d) { return d.angle; },
|
||||
startRadius = function(d) { return d.radius; },
|
||||
endRadius = startRadius,
|
||||
arcOffset = -Math.PI / 2;
|
||||
|
||||
function link(d, i) {
|
||||
var s = node(source, this, d, i),
|
||||
t = node(target, this, d, i),
|
||||
x;
|
||||
if (t.a < s.a) x = t, t = s, s = x;
|
||||
if (t.a - s.a > Math.PI) s.a += 2 * Math.PI;
|
||||
var a1 = s.a + (t.a - s.a) / 3,
|
||||
a2 = t.a - (t.a - s.a) / 3;
|
||||
return s.r0 - s.r1 || t.r0 - t.r1
|
||||
? "M" + Math.cos(s.a) * s.r0 + "," + Math.sin(s.a) * s.r0
|
||||
+ "L" + Math.cos(s.a) * s.r1 + "," + Math.sin(s.a) * s.r1
|
||||
+ "C" + Math.cos(a1) * s.r1 + "," + Math.sin(a1) * s.r1
|
||||
+ " " + Math.cos(a2) * t.r1 + "," + Math.sin(a2) * t.r1
|
||||
+ " " + Math.cos(t.a) * t.r1 + "," + Math.sin(t.a) * t.r1
|
||||
+ "L" + Math.cos(t.a) * t.r0 + "," + Math.sin(t.a) * t.r0
|
||||
+ "C" + Math.cos(a2) * t.r0 + "," + Math.sin(a2) * t.r0
|
||||
+ " " + Math.cos(a1) * s.r0 + "," + Math.sin(a1) * s.r0
|
||||
+ " " + Math.cos(s.a) * s.r0 + "," + Math.sin(s.a) * s.r0
|
||||
: "M" + Math.cos(s.a) * s.r0 + "," + Math.sin(s.a) * s.r0
|
||||
+ "C" + Math.cos(a1) * s.r1 + "," + Math.sin(a1) * s.r1
|
||||
+ " " + Math.cos(a2) * t.r1 + "," + Math.sin(a2) * t.r1
|
||||
+ " " + Math.cos(t.a) * t.r1 + "," + Math.sin(t.a) * t.r1;
|
||||
}
|
||||
|
||||
function node(method, thiz, d, i) {
|
||||
var node = method.call(thiz, d, i),
|
||||
a = +(typeof angle === "function" ? angle.call(thiz, node, i) : angle) + arcOffset,
|
||||
r0 = +(typeof startRadius === "function" ? startRadius.call(thiz, node, i) : startRadius),
|
||||
r1 = (startRadius === endRadius ? r0 : +(typeof endRadius === "function" ? endRadius.call(thiz, node, i) : endRadius));
|
||||
return {r0: r0, r1: r1, a: a};
|
||||
}
|
||||
|
||||
link.source = function(_) {
|
||||
if (!arguments.length) return source;
|
||||
source = _;
|
||||
return link;
|
||||
};
|
||||
|
||||
link.target = function(_) {
|
||||
if (!arguments.length) return target;
|
||||
target = _;
|
||||
return link;
|
||||
};
|
||||
|
||||
link.angle = function(_) {
|
||||
if (!arguments.length) return angle;
|
||||
angle = _;
|
||||
return link;
|
||||
};
|
||||
|
||||
link.radius = function(_) {
|
||||
if (!arguments.length) return startRadius;
|
||||
startRadius = endRadius = _;
|
||||
return link;
|
||||
};
|
||||
|
||||
link.startRadius = function(_) {
|
||||
if (!arguments.length) return startRadius;
|
||||
startRadius = _;
|
||||
return link;
|
||||
};
|
||||
|
||||
link.endRadius = function(_) {
|
||||
if (!arguments.length) return endRadius;
|
||||
endRadius = _;
|
||||
return link;
|
||||
};
|
||||
|
||||
return link;
|
||||
};
|
||||
@@ -0,0 +1,192 @@
|
||||
(function() {
|
||||
d3.horizon = function() {
|
||||
var bands = 1, // between 1 and 5, typically
|
||||
mode = "offset", // or mirror
|
||||
interpolate = "linear", // or basis, monotone, step-before, etc.
|
||||
x = d3_horizonX,
|
||||
y = d3_horizonY,
|
||||
w = 960,
|
||||
h = 40,
|
||||
duration = 0;
|
||||
|
||||
var color = d3.scale.linear()
|
||||
.domain([-1, 0, 1])
|
||||
.range(["#d62728", "#fff", "#1f77b4"]);
|
||||
|
||||
// For each small multiple…
|
||||
function horizon(g) {
|
||||
g.each(function(d, i) {
|
||||
var g = d3.select(this),
|
||||
n = 2 * bands + 1,
|
||||
xMin = Infinity,
|
||||
xMax = -Infinity,
|
||||
yMax = -Infinity,
|
||||
x0, // old x-scale
|
||||
y0, // old y-scale
|
||||
id; // unique id for paths
|
||||
|
||||
// Compute x- and y-values along with extents.
|
||||
var data = d.map(function(d, i) {
|
||||
var xv = x.call(this, d, i),
|
||||
yv = y.call(this, d, i);
|
||||
if (xv < xMin) xMin = xv;
|
||||
if (xv > xMax) xMax = xv;
|
||||
if (-yv > yMax) yMax = -yv;
|
||||
if (yv > yMax) yMax = yv;
|
||||
return [xv, yv];
|
||||
});
|
||||
|
||||
// Compute the new x- and y-scales, and transform.
|
||||
var x1 = d3.scale.linear().domain([xMin, xMax]).range([0, w]),
|
||||
y1 = d3.scale.linear().domain([0, yMax]).range([0, h * bands]),
|
||||
t1 = d3_horizonTransform(bands, h, mode);
|
||||
|
||||
// Retrieve the old scales, if this is an update.
|
||||
if (this.__chart__) {
|
||||
x0 = this.__chart__.x;
|
||||
y0 = this.__chart__.y;
|
||||
t0 = this.__chart__.t;
|
||||
id = this.__chart__.id;
|
||||
} else {
|
||||
x0 = x1.copy();
|
||||
y0 = y1.copy();
|
||||
t0 = t1;
|
||||
id = ++d3_horizonId;
|
||||
}
|
||||
|
||||
// We'll use a defs to store the area path and the clip path.
|
||||
var defs = g.selectAll("defs")
|
||||
.data([null]);
|
||||
|
||||
// The clip path is a simple rect.
|
||||
defs.enter().append("defs").append("clipPath")
|
||||
.attr("id", "d3_horizon_clip" + id)
|
||||
.append("rect")
|
||||
.attr("width", w)
|
||||
.attr("height", h);
|
||||
|
||||
defs.select("rect").transition()
|
||||
.duration(duration)
|
||||
.attr("width", w)
|
||||
.attr("height", h);
|
||||
|
||||
// We'll use a container to clip all horizon layers at once.
|
||||
g.selectAll("g")
|
||||
.data([null])
|
||||
.enter().append("g")
|
||||
.attr("clip-path", "url(#d3_horizon_clip" + id + ")");
|
||||
|
||||
// Instantiate each copy of the path with different transforms.
|
||||
var path = g.select("g").selectAll("path")
|
||||
.data(d3.range(-1, -bands - 1, -1).concat(d3.range(1, bands + 1)), Number);
|
||||
|
||||
var d0 = d3_horizonArea
|
||||
.interpolate(interpolate)
|
||||
.x(function(d) { return x0(d[0]); })
|
||||
.y0(h * bands)
|
||||
.y1(function(d) { return h * bands - y0(d[1]); })
|
||||
(data);
|
||||
|
||||
var d1 = d3_horizonArea
|
||||
.x(function(d) { return x1(d[0]); })
|
||||
.y1(function(d) { return h * bands - y1(d[1]); })
|
||||
(data);
|
||||
|
||||
path.enter().append("path")
|
||||
.style("fill", color)
|
||||
.attr("transform", t0)
|
||||
.attr("d", d0);
|
||||
|
||||
path.transition()
|
||||
.duration(duration)
|
||||
.style("fill", color)
|
||||
.attr("transform", t1)
|
||||
.attr("d", d1);
|
||||
|
||||
path.exit().transition()
|
||||
.duration(duration)
|
||||
.attr("transform", t1)
|
||||
.attr("d", d1)
|
||||
.remove();
|
||||
|
||||
// Stash the new scales.
|
||||
this.__chart__ = {x: x1, y: y1, t: t1, id: id};
|
||||
});
|
||||
d3.timer.flush();
|
||||
}
|
||||
|
||||
horizon.duration = function(x) {
|
||||
if (!arguments.length) return duration;
|
||||
duration = +x;
|
||||
return horizon;
|
||||
};
|
||||
|
||||
horizon.bands = function(x) {
|
||||
if (!arguments.length) return bands;
|
||||
bands = +x;
|
||||
color.domain([-bands, 0, bands]);
|
||||
return horizon;
|
||||
};
|
||||
|
||||
horizon.mode = function(x) {
|
||||
if (!arguments.length) return mode;
|
||||
mode = x + "";
|
||||
return horizon;
|
||||
};
|
||||
|
||||
horizon.colors = function(x) {
|
||||
if (!arguments.length) return color.range();
|
||||
color.range(x);
|
||||
return horizon;
|
||||
};
|
||||
|
||||
horizon.interpolate = function(x) {
|
||||
if (!arguments.length) return interpolate;
|
||||
interpolate = x + "";
|
||||
return horizon;
|
||||
};
|
||||
|
||||
horizon.x = function(z) {
|
||||
if (!arguments.length) return x;
|
||||
x = z;
|
||||
return horizon;
|
||||
};
|
||||
|
||||
horizon.y = function(z) {
|
||||
if (!arguments.length) return y;
|
||||
y = z;
|
||||
return horizon;
|
||||
};
|
||||
|
||||
horizon.width = function(x) {
|
||||
if (!arguments.length) return w;
|
||||
w = +x;
|
||||
return horizon;
|
||||
};
|
||||
|
||||
horizon.height = function(x) {
|
||||
if (!arguments.length) return h;
|
||||
h = +x;
|
||||
return horizon;
|
||||
};
|
||||
|
||||
return horizon;
|
||||
};
|
||||
|
||||
var d3_horizonArea = d3.svg.area(),
|
||||
d3_horizonId = 0;
|
||||
|
||||
function d3_horizonX(d) {
|
||||
return d[0];
|
||||
}
|
||||
|
||||
function d3_horizonY(d) {
|
||||
return d[1];
|
||||
}
|
||||
|
||||
function d3_horizonTransform(bands, h, mode) {
|
||||
return mode == "offset"
|
||||
? function(d) { return "translate(0," + (d + (d < 0) - bands) * h + ")"; }
|
||||
: function(d) { return (d < 0 ? "scale(1,-1)" : "") + "translate(0," + (d - bands) * h + ")"; };
|
||||
}
|
||||
})();
|
||||
@@ -0,0 +1,292 @@
|
||||
d3.sankey = function() {
|
||||
var sankey = {},
|
||||
nodeWidth = 24,
|
||||
nodePadding = 8,
|
||||
size = [1, 1],
|
||||
nodes = [],
|
||||
links = [];
|
||||
|
||||
sankey.nodeWidth = function(_) {
|
||||
if (!arguments.length) return nodeWidth;
|
||||
nodeWidth = +_;
|
||||
return sankey;
|
||||
};
|
||||
|
||||
sankey.nodePadding = function(_) {
|
||||
if (!arguments.length) return nodePadding;
|
||||
nodePadding = +_;
|
||||
return sankey;
|
||||
};
|
||||
|
||||
sankey.nodes = function(_) {
|
||||
if (!arguments.length) return nodes;
|
||||
nodes = _;
|
||||
return sankey;
|
||||
};
|
||||
|
||||
sankey.links = function(_) {
|
||||
if (!arguments.length) return links;
|
||||
links = _;
|
||||
return sankey;
|
||||
};
|
||||
|
||||
sankey.size = function(_) {
|
||||
if (!arguments.length) return size;
|
||||
size = _;
|
||||
return sankey;
|
||||
};
|
||||
|
||||
sankey.layout = function(iterations) {
|
||||
computeNodeLinks();
|
||||
computeNodeValues();
|
||||
computeNodeBreadths();
|
||||
computeNodeDepths(iterations);
|
||||
computeLinkDepths();
|
||||
return sankey;
|
||||
};
|
||||
|
||||
sankey.relayout = function() {
|
||||
computeLinkDepths();
|
||||
return sankey;
|
||||
};
|
||||
|
||||
sankey.link = function() {
|
||||
var curvature = .5;
|
||||
|
||||
function link(d) {
|
||||
var x0 = d.source.x + d.source.dx,
|
||||
x1 = d.target.x,
|
||||
xi = d3.interpolateNumber(x0, x1),
|
||||
x2 = xi(curvature),
|
||||
x3 = xi(1 - curvature),
|
||||
y0 = d.source.y + d.sy + d.dy / 2,
|
||||
y1 = d.target.y + d.ty + d.dy / 2;
|
||||
return "M" + x0 + "," + y0
|
||||
+ "C" + x2 + "," + y0
|
||||
+ " " + x3 + "," + y1
|
||||
+ " " + x1 + "," + y1;
|
||||
}
|
||||
|
||||
link.curvature = function(_) {
|
||||
if (!arguments.length) return curvature;
|
||||
curvature = +_;
|
||||
return link;
|
||||
};
|
||||
|
||||
return link;
|
||||
};
|
||||
|
||||
// Populate the sourceLinks and targetLinks for each node.
|
||||
// Also, if the source and target are not objects, assume they are indices.
|
||||
function computeNodeLinks() {
|
||||
nodes.forEach(function(node) {
|
||||
node.sourceLinks = [];
|
||||
node.targetLinks = [];
|
||||
});
|
||||
links.forEach(function(link) {
|
||||
var source = link.source,
|
||||
target = link.target;
|
||||
if (typeof source === "number") source = link.source = nodes[link.source];
|
||||
if (typeof target === "number") target = link.target = nodes[link.target];
|
||||
source.sourceLinks.push(link);
|
||||
target.targetLinks.push(link);
|
||||
});
|
||||
}
|
||||
|
||||
// Compute the value (size) of each node by summing the associated links.
|
||||
function computeNodeValues() {
|
||||
nodes.forEach(function(node) {
|
||||
node.value = Math.max(
|
||||
d3.sum(node.sourceLinks, value),
|
||||
d3.sum(node.targetLinks, value)
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
// Iteratively assign the breadth (x-position) for each node.
|
||||
// Nodes are assigned the maximum breadth of incoming neighbors plus one;
|
||||
// nodes with no incoming links are assigned breadth zero, while
|
||||
// nodes with no outgoing links are assigned the maximum breadth.
|
||||
function computeNodeBreadths() {
|
||||
var remainingNodes = nodes,
|
||||
nextNodes,
|
||||
x = 0;
|
||||
|
||||
while (remainingNodes.length) {
|
||||
nextNodes = [];
|
||||
remainingNodes.forEach(function(node) {
|
||||
node.x = x;
|
||||
node.dx = nodeWidth;
|
||||
node.sourceLinks.forEach(function(link) {
|
||||
nextNodes.push(link.target);
|
||||
});
|
||||
});
|
||||
remainingNodes = nextNodes;
|
||||
++x;
|
||||
}
|
||||
|
||||
//
|
||||
moveSinksRight(x);
|
||||
scaleNodeBreadths((size[0] - nodeWidth) / (x - 1));
|
||||
}
|
||||
|
||||
function moveSourcesRight() {
|
||||
nodes.forEach(function(node) {
|
||||
if (!node.targetLinks.length) {
|
||||
node.x = d3.min(node.sourceLinks, function(d) { return d.target.x; }) - 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function moveSinksRight(x) {
|
||||
nodes.forEach(function(node) {
|
||||
if (!node.sourceLinks.length) {
|
||||
node.x = x - 1;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function scaleNodeBreadths(kx) {
|
||||
nodes.forEach(function(node) {
|
||||
node.x *= kx;
|
||||
});
|
||||
}
|
||||
|
||||
function computeNodeDepths(iterations) {
|
||||
var nodesByBreadth = d3.nest()
|
||||
.key(function(d) { return d.x; })
|
||||
.sortKeys(d3.ascending)
|
||||
.entries(nodes)
|
||||
.map(function(d) { return d.values; });
|
||||
|
||||
//
|
||||
initializeNodeDepth();
|
||||
resolveCollisions();
|
||||
for (var alpha = 1; iterations > 0; --iterations) {
|
||||
relaxRightToLeft(alpha *= .99);
|
||||
resolveCollisions();
|
||||
relaxLeftToRight(alpha);
|
||||
resolveCollisions();
|
||||
}
|
||||
|
||||
function initializeNodeDepth() {
|
||||
var ky = d3.min(nodesByBreadth, function(nodes) {
|
||||
return (size[1] - (nodes.length - 1) * nodePadding) / d3.sum(nodes, value);
|
||||
});
|
||||
|
||||
nodesByBreadth.forEach(function(nodes) {
|
||||
nodes.forEach(function(node, i) {
|
||||
node.y = i;
|
||||
node.dy = node.value * ky;
|
||||
});
|
||||
});
|
||||
|
||||
links.forEach(function(link) {
|
||||
link.dy = link.value * ky;
|
||||
});
|
||||
}
|
||||
|
||||
function relaxLeftToRight(alpha) {
|
||||
nodesByBreadth.forEach(function(nodes, breadth) {
|
||||
nodes.forEach(function(node) {
|
||||
if (node.targetLinks.length) {
|
||||
var y = d3.sum(node.targetLinks, weightedSource) / d3.sum(node.targetLinks, value);
|
||||
node.y += (y - center(node)) * alpha;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function weightedSource(link) {
|
||||
return center(link.source) * link.value;
|
||||
}
|
||||
}
|
||||
|
||||
function relaxRightToLeft(alpha) {
|
||||
nodesByBreadth.slice().reverse().forEach(function(nodes) {
|
||||
nodes.forEach(function(node) {
|
||||
if (node.sourceLinks.length) {
|
||||
var y = d3.sum(node.sourceLinks, weightedTarget) / d3.sum(node.sourceLinks, value);
|
||||
node.y += (y - center(node)) * alpha;
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
function weightedTarget(link) {
|
||||
return center(link.target) * link.value;
|
||||
}
|
||||
}
|
||||
|
||||
function resolveCollisions() {
|
||||
nodesByBreadth.forEach(function(nodes) {
|
||||
var node,
|
||||
dy,
|
||||
y0 = 0,
|
||||
n = nodes.length,
|
||||
i;
|
||||
|
||||
// Push any overlapping nodes down.
|
||||
nodes.sort(ascendingDepth);
|
||||
for (i = 0; i < n; ++i) {
|
||||
node = nodes[i];
|
||||
dy = y0 - node.y;
|
||||
if (dy > 0) node.y += dy;
|
||||
y0 = node.y + node.dy + nodePadding;
|
||||
}
|
||||
|
||||
// If the bottommost node goes outside the bounds, push it back up.
|
||||
dy = y0 - nodePadding - size[1];
|
||||
if (dy > 0) {
|
||||
y0 = node.y -= dy;
|
||||
|
||||
// Push any overlapping nodes back up.
|
||||
for (i = n - 2; i >= 0; --i) {
|
||||
node = nodes[i];
|
||||
dy = node.y + node.dy + nodePadding - y0;
|
||||
if (dy > 0) node.y -= dy;
|
||||
y0 = node.y;
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function ascendingDepth(a, b) {
|
||||
return a.y - b.y;
|
||||
}
|
||||
}
|
||||
|
||||
function computeLinkDepths() {
|
||||
nodes.forEach(function(node) {
|
||||
node.sourceLinks.sort(ascendingTargetDepth);
|
||||
node.targetLinks.sort(ascendingSourceDepth);
|
||||
});
|
||||
nodes.forEach(function(node) {
|
||||
var sy = 0, ty = 0;
|
||||
node.sourceLinks.forEach(function(link) {
|
||||
link.sy = sy;
|
||||
sy += link.dy;
|
||||
});
|
||||
node.targetLinks.forEach(function(link) {
|
||||
link.ty = ty;
|
||||
ty += link.dy;
|
||||
});
|
||||
});
|
||||
|
||||
function ascendingSourceDepth(a, b) {
|
||||
return a.source.y - b.source.y;
|
||||
}
|
||||
|
||||
function ascendingTargetDepth(a, b) {
|
||||
return a.target.y - b.target.y;
|
||||
}
|
||||
}
|
||||
|
||||
function center(node) {
|
||||
return node.y + node.dy / 2;
|
||||
}
|
||||
|
||||
function value(link) {
|
||||
return link.value;
|
||||
}
|
||||
|
||||
return sankey;
|
||||
};
|
||||
Reference in new issue
Block a user