Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Test (and fixes) for d3.format.

  • Loading branch information...
commit 50ebc155cb66a2d941e82c401bc7af96f9940b01 1 parent 7df63b3
@mbostock mbostock authored
View
10 Makefile
@@ -133,6 +133,9 @@ d3.geom.js: \
src/geom/quadtree.js \
src/end.js
+tests: \
+ tests/test-format.test
+
%.min.js: %.js Makefile
@rm -f $@
$(JS_COMPILER) --js $< --js_output_file $@
@@ -142,5 +145,12 @@ d3.js d3%.js: Makefile
cat $(filter %.js,$^) > $@
@chmod a-w $@
+%.test: %.js %.out d3.js
+ @/bin/echo -n "test: $* "
+ @node $< > $*.actual
+ @diff -U 3 $*.out $*.actual && rm -f $*.actual \
+ && echo '\033[1;32mPASS\033[0m' \
+ || echo test: $* '\033[1;31mFAIL\033[0m'
+
clean:
rm -f d3*.js
View
54 d3.js
@@ -1,4 +1,4 @@
-(function(){d3 = {version: "1.5.0"}; // semver
+(function(){d3 = {version: "1.5.1"}; // semver
if (!Date.now) Date.now = function() {
return +new Date();
};
@@ -335,30 +335,45 @@ function d3_dispatch(type) {
d3.format = function(specifier) {
var match = d3_format_re.exec(specifier),
fill = match[1] || " ",
- sign = d3_format_signs[match[3]] || d3_format_signs["-"],
+ sign = match[3] || "",
zfill = match[5],
width = +match[6],
comma = match[7],
precision = match[8],
type = match[9];
if (precision) precision = precision.substring(1);
- if (zfill) fill = "0"; // TODO align = "=";
+ if (zfill) {
+ fill = "0"; // TODO align = "=";
+ if (comma) width -= Math.floor((width - 1) / 4);
+ }
if (type == "d") precision = "0";
return function(value) {
var number = +value,
- negative = (number < 0) && (number = -number);
+ negative = (number < 0) && (number = -number) ? "\u2212" : sign;
+
+ // Return the empty string for floats formatted as ints.
if ((type == "d") && (number % 1)) return "";
+
+ // Convert the input value to the desired precision.
if (precision) value = number.toFixed(precision);
else value = "" + number;
- if (comma) {
- var i = value.lastIndexOf("."),
- f = i >= 0 ? value.substring(i) : (i = value.length, ""),
- t = [];
- while (i > 0) t.push(value.substring(i -= 3, i + 3));
- value = t.reverse().join(",") + f;
- }
- var length = (value = sign(negative, value)).length;
- if (length < width) value = new Array(width - length + 1).join(fill) + value;
+
+ // If the fill character is 0, the sign and group is applied after the fill.
+ if (zfill) {
+ var length = value.length + negative.length;
+ if (length < width) value = new Array(width - length + 1).join(fill) + value;
+ if (comma) value = d3_format_group(value);
+ value = negative + value;
+ }
+
+ // Otherwise (e.g., space-filling), the sign and group is applied before.
+ else {
+ if (comma) value = d3_format_group(value);
+ value = negative + value;
+ var length = value.length;
+ if (length < width) value = new Array(width - length + 1).join(fill) + value;
+ }
+
return value;
};
};
@@ -366,11 +381,14 @@ d3.format = function(specifier) {
// [[fill]align][sign][#][0][width][,][.precision][type]
var d3_format_re = /(?:([^{])?([<>=^]))?([+\- ])?(#)?(0)?([0-9]+)?(,)?(\.[0-9]+)?([a-zA-Z%])?/;
-var d3_format_signs = {
- "+": function(negative, value) { return (negative ? "\u2212" : "+") + value; },
- " ": function(negative, value) { return (negative ? "\u2212" : " ") + value; },
- "-": function(negative, value) { return negative ? "\u2212" + value : value; }
-};
+// Apply comma grouping for thousands.
+function d3_format_group(value) {
+ var i = value.lastIndexOf("."),
+ f = i >= 0 ? value.substring(i) : (i = value.length, ""),
+ t = [];
+ while (i > 0) t.push(value.substring(i -= 3, i + 3));
+ return t.reverse().join(",") + f;
+}
/*
* TERMS OF USE - EASING EQUATIONS
*
View
80 d3.min.js
@@ -1,39 +1,39 @@
(function(){function ua(a){for(var b=-1,d=a.length,g=[];++b<d;)g.push(a[b]);return g}function v(a){return typeof a=="function"?a:function(){return a}}function C(a,b){return function(){var d=b.apply(a,arguments);return arguments.length?a:d}}function va(a){return a==null}function da(a){return a.replace(/(^\s+)|(\s+$)/g,"").replace(/\s+/g," ")}function ea(a){arguments[0]=this;a.apply(this,arguments);return this}function wa(){var a={},b=[];a.add=function(d){for(var g=0;g<b.length;g++)if(b[g].listener==
-d)return a;b.push({listener:d,on:true});return a};a.remove=function(d){for(var g=0;g<b.length;g++){var e=b[g];if(e.listener==d){e.on=false;b=b.slice(0,g).concat(b.slice(g+1));break}}return a};a.dispatch=function(){for(var d=b,g=0,e=d.length;g<e;g++){var c=d[g];c.on&&c.listener.apply(this,arguments)}};return a}function fa(a){return function(b){return 1-a(1-b)}}function ga(a){return function(b){return 0.5*(b<0.5?a(2*b):2-a(2-2*b))}}function xa(a){return a}function R(a){return function(b){return Math.pow(b,
-a)}}function ya(a){return 1-Math.cos(a*Math.PI/2)}function za(a){return a?Math.pow(2,10*(a-1))-0.0010:0}function Aa(a){return 1-Math.sqrt(1-a*a)}function Ba(a){return a<1/2.75?7.5625*a*a:a<2/2.75?7.5625*(a-=1.5/2.75)*a+0.75:a<2.5/2.75?7.5625*(a-=2.25/2.75)*a+0.9375:7.5625*(a-=2.625/2.75)*a+0.984375}function J(a,b,d){return{r:a,g:b,b:d,toString:Ca}}function Ca(){return"#"+S(this.r)+S(this.g)+S(this.b)}function S(a){return a<16?"0"+a.toString(16):a.toString(16)}function T(a,b,d){var g=0,e=0,c=0,f,h;
-if(f=/([a-z]+)\((.*)\)/i.exec(a)){h=f[2].split(",");switch(f[1]){case "hsl":return d(parseFloat(h[0]),parseFloat(h[1])/100,parseFloat(h[2])/100);case "rgb":return b(U(h[0]),U(h[1]),U(h[2]))}}if(d=G[a])return b(d.r,d.g,d.b);if(a!=null&&a.charAt(0)=="#"){if(a.length==4){g=a.charAt(1);g+=g;e=a.charAt(2);e+=e;c=a.charAt(3);c+=c}else if(a.length==7){g=a.substring(1,3);e=a.substring(3,5);c=a.substring(5,7)}g=parseInt(g,16);e=parseInt(e,16);c=parseInt(c,16)}return b(g,e,c)}function Da(a,b,d){var g=Math.min(a/=
-255,b/=255,d/=255),e=Math.max(a,b,d),c=e-g,f=(e+g)/2;if(c){g=f<0.5?c/(e+g):c/(2-e-g);a=a==e?(b-d)/c+(b<d?6:0):b==e?(d-a)/c+2:(a-b)/c+4;a*=60}else g=a=0;return V(a,g,f)}function U(a){var b=parseFloat(a);return a.charAt(a.length-1)=="%"?Math.round(b*2.55):b}function V(a,b,d){return{h:a,s:b,l:d,toString:Ea}}function Ea(){return"hsl("+this.h+","+this.s*100+"%,"+this.l*100+"%)"}function W(a,b,d){function g(f){if(f>360)f-=360;else if(f<0)f+=360;if(f<60)return e+(c-e)*f/60;if(f<180)return c;if(f<240)return e+
-(c-e)*(240-f)/60;return e}var e,c;a%=360;if(a<0)a+=360;b=b<0?0:b>1?1:b;d=d<0?0:d>1?1:d;c=d<=0.5?d*(1+b):d+b-d*b;e=2*d-c;return J(Math.round(g(a+120)*255),Math.round(g(a)*255),Math.round(g(a-120)*255))}function y(a){function b(e){for(var c=[],f,h,i,k,j=0,o=a.length;j<o;j++){i=a[j];c.push(f=[]);f.parentNode=i.parentNode;f.parentData=i.parentData;for(var p=0,m=i.length;p<m;p++)if(k=i[p]){f.push(h=e(k));if(h&&"__data__"in k)h.__data__=k.__data__}else f.push(null)}return y(c)}function d(e){for(var c=[],
-f,h,i,k=0,j=a.length;k<j;k++){h=a[k];for(var o=0,p=h.length;o<p;o++)if(i=h[o]){c.push(f=e(i));f.parentNode=i;f.parentData=i.__data__}}return y(c)}function g(e){for(var c=0,f=a.length;c<f;c++)for(var h=a[c],i=0,k=h.length;i<k;i++){var j=h[i];if(j)return e.call(j,j.__data__,i)}return null}a.select=function(e){return b(function(c){return D(e,c)})};a.selectAll=function(e){return d(function(c){return ha(e,c)})};a.filter=function(e){for(var c=[],f,h,i,k=0,j=a.length;k<j;k++){h=a[k];c.push(f=[]);f.parentNode=
-h.parentNode;f.parentData=h.parentData;for(var o=0,p=h.length;o<p;o++)if((i=h[o])&&e.call(i,i.__data__,o))f.push(i)}return y(c)};a.map=function(e){for(var c,f,h=0,i=a.length;h<i;h++){c=a[h];for(var k=0,j=c.length;k<j;k++)if(f=c[k])f.__data__=e.call(f,f.__data__,k)}return a};a.data=function(e,c){function f(m,n){var l=0,q=m.length,r=n.length,t=Math.min(q,r),u=Math.max(q,r),s=[],z=[],w=[],x,A;if(c){t={};u=[];var E;A=n.length;for(l=0;l<q;l++){E=c.call(x=m[l],x.__data__,l);if(E in t)w[A++]=m[l];else{t[E]=
-x;u.push(E)}}for(l=0;l<r;l++){if(x=t[E=c.call(n,A=n[l],l)]){x.__data__=A;s[l]=x;z[l]=w[l]=null}else{z[l]={__data__:A};s[l]=w[l]=null}delete t[E]}for(l=0;l<q;l++)if(u[l]in t)w[l]=m[l]}else{for(;l<t;l++){x=m[l];A=n[l];if(x){x.__data__=A;s[l]=x;z[l]=w[l]=null}else{z[l]={__data__:A};s[l]=w[l]=null}}for(;l<r;l++){z[l]={__data__:n[l]};s[l]=w[l]=null}for(;l<u;l++){w[l]=m[l];z[l]=s[l]=null}}z.parentNode=s.parentNode=w.parentNode=m.parentNode;z.parentData=s.parentData=w.parentData=m.parentData;h.push(z);i.push(s);
-k.push(w)}var h=[],i=[],k=[],j=-1,o=a.length,p;if(typeof e=="function")for(;++j<o;)f(p=a[j],e.call(p,p.parentData,j));else for(;++j<o;)f(p=a[j],e);j=y(i);j.enter=function(){return Fa(h)};j.exit=function(){return y(k)};return j};a.each=function(e){for(var c=0,f=a.length;c<f;c++)for(var h=a[c],i=0,k=h.length;i<k;i++){var j=h[i];j&&e.call(j,j.__data__,i)}return a};a.empty=function(){return!g(function(){return true})};a.node=function(){return g(function(){return this})};a.attr=function(e,c){function f(){this.removeAttribute(e)}
-function h(){this.removeAttributeNS(e.space,e.local)}function i(){this.setAttribute(e,c)}function k(){this.setAttributeNS(e.space,e.local,c)}function j(){var p=c.apply(this,arguments);p==null?this.removeAttribute(e):this.setAttribute(e,p)}function o(){var p=c.apply(this,arguments);p==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,p)}e=d3.ns.qualify(e);if(arguments.length<2)return g(e.local?function(){return this.getAttributeNS(e.space,e.local)}:function(){return this.getAttribute(e)});
-return a.each(c==null?e.local?h:f:typeof c=="function"?e.local?o:j:e.local?k:i)};a.classed=function(e,c){function f(){var j=this.className;k.lastIndex=0;if(!k.test(j))this.className=da(j+" "+e)}function h(){var j=da(this.className.replace(k," "));this.className=j.length?j:null}function i(){(c.apply(this,arguments)?f:h).call(this)}var k=RegExp("(^|\\s+)"+d3.requote(e)+"(\\s+|$)","g");if(arguments.length<2)return g(function(){k.lastIndex=0;return k.test(this.className)});return a.each(typeof c=="function"?
-i:c?f:h)};a.style=function(e,c,f){function h(){this.style.removeProperty(e)}function i(){this.style.setProperty(e,c,f)}function k(){var j=c.apply(this,arguments);j==null?this.style.removeProperty(e):this.style.setProperty(e,j,f)}if(arguments.length<3)f=null;if(arguments.length<2)return g(function(){return window.getComputedStyle(this,null).getPropertyValue(e)});return a.each(c==null?h:typeof c=="function"?k:i)};a.property=function(e,c){function f(){delete this[e]}function h(){this[e]=c}function i(){var k=
-c.apply(this,arguments);if(k==null)delete this[e];else this[e]=k}e=d3.ns.qualify(e);if(arguments.length<2)return g(function(){return this[e]});return a.each(c==null?f:typeof c=="function"?i:h)};a.text=function(e){function c(){this.appendChild(document.createTextNode(e))}function f(){var h=e.apply(this,arguments);h!=null&&this.appendChild(document.createTextNode(h))}if(arguments.length<1)return g(function(){return this.textContent});a.each(function(){for(;this.lastChild;)this.removeChild(this.lastChild)});
-return e==null?a:a.each(typeof e=="function"?f:c)};a.html=function(e){function c(){this.innerHTML=e}function f(){this.innerHTML=e.apply(this,arguments)}if(arguments.length<1)return g(function(){return this.innerHTML});return a.each(typeof e=="function"?f:c)};a.append=function(e){function c(h){return h.appendChild(document.createElement(e))}function f(h){return h.appendChild(document.createElementNS(e.space,e.local))}e=d3.ns.qualify(e);return b(e.local?f:c)};a.insert=function(e,c){function f(i){return i.insertBefore(document.createElement(e),
-D(c,i))}function h(i){return i.insertBefore(document.createElementNS(e.space,e.local),D(c,i))}e=d3.ns.qualify(e);return b(e.local?h:f)};a.remove=function(){return b(function(e){var c=e.parentNode;c.removeChild(e);return c})};a.sort=function(e){e=Ga.apply(this,arguments);for(var c=0,f=a.length;c<f;c++){var h=a[c];h.sort(e);for(var i=1,k=h.length,j=h[0];i<k;i++){var o=h[i];if(o){j&&j.parentNode.insertBefore(o,j.nextSibling);j=o}}}return a};a.on=function(e,c){var f=e.indexOf("."),h=f==-1?e:e.substring(0,
-f),i="__on"+e;return a.each(function(k,j){function o(p){var m=d3.event;d3.event=p;try{c.call(this,k,j)}finally{d3.event=m}}this[i]&&this.removeEventListener(h,this[i],false);if(c)this.addEventListener(h,this[i]=o,false)})};a.transition=function(){return X(a)};a.call=ea;return a}function Fa(a){function b(d){for(var g=[],e,c,f,h,i=0,k=a.length;i<k;i++){f=a[i];g.push(e=[]);e.parentNode=f.parentNode;e.parentData=f.parentData;for(var j=0,o=f.length;j<o;j++)if(h=f[j]){e.push(c=d(f.parentNode));c.__data__=
-h.__data__}else e.push(null)}return y(g)}a.append=function(d){function g(c){return c.appendChild(document.createElement(d))}function e(c){return c.appendChild(document.createElementNS(d.space,d.local))}d=d3.ns.qualify(d);return b(d.local?e:g)};a.insert=function(d,g){function e(f){return f.insertBefore(document.createElement(d),D(g,f))}function c(f){return f.insertBefore(document.createElementNS(d.space,d.local),D(g,f))}d=d3.ns.qualify(d);return b(d.local?c:e)};return a}function Ga(a){if(!arguments.length)a=
-d3.ascending;return function(b,d){return a(b&&b.__data__,d&&d.__data__)}}function X(a){function b(m){var n=true,l=-1;a.each(function(){if(i[++l]!=2){var q=(m-k[l])/j[l],r=this.__transition__,t,u,s=c[l];if(q<1){n=false;if(q<0)return}else q=1;if(i[l]){if(!r||r.active!=g){i[l]=2;return}}else if(!r||r.active>g){i[l]=2;return}else{i[l]=1;h.start.dispatch.apply(this,arguments);s=c[l]={};r.active=g;for(u in e)s[u]=e[u].apply(this,arguments)}t=p(q);for(u in e)s[u].call(this,t);if(q==1){i[l]=2;if(r.active==
-g){q=r.owner;if(q==g){delete this.__transition__;f&&this.parentNode.removeChild(this)}Y=g;h.end.dispatch.apply(this,arguments);Y=0;r.owner=q}}}});return n}var d={},g=Y||++Ha,e={},c=[],f=false,h=d3.dispatch("start","end"),i=[],k=[],j=[],o,p=d3.ease("cubic-in-out");a.each(function(){(this.__transition__||(this.__transition__={})).owner=g});d.delay=function(m){var n=Infinity,l=-1;if(typeof m=="function")a.each(function(){var q=k[++l]=+m.apply(this,arguments);if(q<n)n=q});else{n=+m;a.each(function(){k[++l]=
-n})}Ia(b,n);return d};d.duration=function(m){var n=-1;if(typeof m=="function"){o=0;a.each(function(){var l=j[++n]=+m.apply(this,arguments);if(l>o)o=l})}else{o=+m;a.each(function(){j[++n]=o})}return d};d.ease=function(m){p=typeof m=="string"?d3.ease(m):m;return d};d.attrTween=function(m,n){function l(r,t){var u=n.call(this,r,t,this.getAttribute(m));return function(s){this.setAttribute(m,u(s))}}function q(r,t){var u=n.call(this,r,t,this.getAttributeNS(m.space,m.local));return function(s){this.setAttributeNS(m.space,
-m.local,u(s))}}e["attr."+m]=m.local?q:l;return d};d.attr=function(m,n){return d.attrTween(m,ia(n))};d.styleTween=function(m,n,l){if(arguments.length<3)l=null;e["style."+m]=function(q,r){var t=n.call(this,q,r,window.getComputedStyle(this,null).getPropertyValue(m));return function(u){this.style.setProperty(m,t(u),l)}};return d};d.style=function(m,n,l){if(arguments.length<3)l=null;return d.styleTween(m,ia(n),l)};d.select=function(m){var n;m=X(a.select(m)).ease(p);n=-1;m.delay(function(){return k[++n]});
-n=-1;m.duration(function(){return j[++n]});return m};d.selectAll=function(m){var n;m=X(a.selectAll(m)).ease(p);n=-1;m.delay(function(l,q){return k[q?n:++n]});n=-1;m.duration(function(l,q){return j[q?n:++n]});return m};d.remove=function(){f=true;return d};d.each=function(m,n){h[m].add(n);return d};d.call=ea;return d.delay(0).duration(250)}function ia(a){return typeof a=="function"?function(b,d,g){return d3.interpolate(g,String(a.call(this,b,d)))}:(a=String(a),function(b,d,g){return d3.interpolate(g,
-a)})}function Ia(a,b){var d=Date.now(),g=false,e=d+b,c=F;if(isFinite(b)){for(;c;){if(c.callback==a){c.then=d;c.delay=b;g=true}else{var f=c.then+c.delay;if(f<e)e=f}c=c.next}g||(F={callback:a,then:d,delay:b,next:F});if(!K){clearTimeout(Z);Z=setTimeout(Ja,Math.max(24,e-d))}}}function Ja(){K=setInterval(Ka,24);Z=0}function Ka(){for(var a,b=Date.now(),d=F;d;){a=b-d.then;if(a>d.delay)d.flush=d.callback(a);d=d.next}a=null;for(b=F;b;)b=b.flush?a?a.next=b.next:F=b.next:(a=b).next;a||(K=clearInterval(K))}function La(a){return a.innerRadius}
-function Ma(a){return a.outerRadius}function ja(a){return a.startAngle}function ka(a){return a.endAngle}function $(a,b,d,g){var e=[],c=-1,f=b.length,h=typeof d=="function",i=typeof g=="function",k;if(h&&i)for(;++c<f;)e.push([d.call(a,k=b[c],c),g.call(a,k,c)]);else if(h)for(;++c<f;)e.push([d.call(a,b[c],c),g]);else if(i)for(;++c<f;)e.push([d,g.call(a,b[c],c)]);else for(;++c<f;)e.push([d,g]);return e}function la(a){return a[0]}function ma(a){return a[1]}function H(a){var b=[],d=0,g=a.length,e=a[0];
-for(b.push(e[0],",",e[1]);++d<g;)b.push("L",(e=a[d])[0],",",e[1]);return b.join("")}function na(a,b){if(b.length<1||a.length!=b.length&&a.length!=b.length+2)return H(a);var d=a.length!=b.length,g="",e=a[0],c=a[1],f=b[0],h=f,i=1;if(d){g+="Q"+(c[0]-f[0]*2/3)+","+(c[1]-f[1]*2/3)+","+c[0]+","+c[1];e=a[1];i=2}if(b.length>1){h=b[1];c=a[i];i++;g+="C"+(e[0]+f[0])+","+(e[1]+f[1])+","+(c[0]-h[0])+","+(c[1]-h[1])+","+c[0]+","+c[1];for(e=2;e<b.length;e++,i++){c=a[i];h=b[e];g+="S"+(c[0]-h[0])+","+(c[1]-h[1])+
-","+c[0]+","+c[1]}}if(d){d=a[i];g+="Q"+(c[0]+h[0]*2/3)+","+(c[1]+h[1]*2/3)+","+d[0]+","+d[1]}return g}function oa(a,b){for(var d=[],g=(1-b)/2,e=a[0],c=a[1],f=a[2],h=2,i=a.length;++h<i;){d.push([g*(f[0]-e[0]),g*(f[1]-e[1])]);e=c;c=f;f=a[h]}d.push([g*(f[0]-e[0]),g*(f[1]-e[1])]);return d}function B(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]+a[3]*b[3]}function L(a,b,d){a.push("C",B(pa,b),",",B(pa,d),",",B(qa,b),",",B(qa,d),",",B(M,b),",",B(M,d))}function Na(){return 0}function Oa(a){return a.source}function Pa(a){return a.target}
-function Qa(a){return a.radius}function Ra(){return 64}function Sa(){return"circle"}d3={version:"1.5.0"};if(!Date.now)Date.now=function(){return+new Date};if(!Object.create)Object.create=function(a){function b(){}b.prototype=a;return new b};var N=function(a){return Array.prototype.slice.call(a)};try{N(document.documentElement.childNodes)}catch(eb){N=ua}d3.ascending=function(a,b){return a<b?-1:a>b?1:0};d3.descending=function(a,b){return b<a?-1:b>a?1:0};d3.min=function(a,b){var d=0,g=a.length,e=a[0],
-c;if(arguments.length==1)for(;++d<g;){if(e>(c=a[d]))e=c}else for(e=b(a[0]);++d<g;)if(e>(c=b(a[d])))e=c;return e};d3.max=function(a,b){var d=0,g=a.length,e=a[0],c;if(arguments.length==1)for(;++d<g;){if(e<(c=a[d]))e=c}else for(e=b(e);++d<g;)if(e<(c=b(a[d])))e=c;return e};d3.nest=function(){function a(h,i){if(i>=g.length)return f?f.call(d,h):c?h.sort(c):h;for(var k=-1,j=h.length,o=g[i++],p,m,n={};++k<j;)if((p=o(m=h[k]))in n)n[p].push(m);else n[p]=[m];for(p in n)n[p]=a(n[p],i);return n}function b(h,i){if(i>=
-g.length)return h;var k=[],j=e[i++],o;for(o in h)k.push({key:o,values:b(h[o],i)});j&&k.sort(function(p,m){return j(p.key,m.key)});return k}var d={},g=[],e=[],c,f;d.map=function(h){return a(h,0)};d.entries=function(h){return b(a(h,0),0)};d.key=function(h){g.push(h);return d};d.sortKeys=function(h){e[g.length-1]=h;return d};d.sortValues=function(h){c=h;return d};d.rollup=function(h){f=h;return d};return d};d3.keys=function(a){var b=[],d;for(d in a)b.push(d);return b};d3.values=function(a){var b=[],
-d;for(d in a)b.push(a[d]);return b};d3.entries=function(a){var b=[],d;for(d in a)b.push({key:d,value:a[d]});return b};d3.merge=function(a){return Array.prototype.concat.apply([],a)};d3.split=function(a,b){var d=[],g=[],e,c=-1,f=a.length;if(arguments.length<2)b=va;for(;++c<f;)if(b.call(g,e=a[c],c))g=[];else{g.length||d.push(g);g.push(e)}return d};d3.range=function(a,b,d){if(arguments.length==1){b=a;a=0}if(d==null)d=1;if((b-a)/d==Infinity)throw Error("infinite range");var g=[],e=-1,c;if(d<0)for(;(c=
-a+d*++e)>b;)g.push(c);else for(;(c=a+d*++e)<b;)g.push(c);return g};d3.requote=function(a){return a.replace(Ta,"\\$&")};var Ta=/[\\\^\$\*\+\?\[\]\(\)\.\{\}]/g;d3.xhr=function(a,b,d){var g=new XMLHttpRequest;if(arguments.length<3)d=b;else b&&g.overrideMimeType(b);g.open("GET",a,true);g.onreadystatechange=function(){if(g.readyState==4)d(g.status<300?g:null)};g.send(null)};d3.text=function(a,b,d){if(arguments.length<3){d=b;b=null}d3.xhr(a,b,function(g){d(g&&g.responseText)})};d3.json=function(a,b){d3.text(a,
-"application/json",function(d){b(d?JSON.parse(d):null)})};d3.html=function(a,b){d3.text(a,"text/html",function(d){if(d!=null){var g=document.createRange();g.selectNode(document.body);d=g.createContextualFragment(d)}b(d)})};d3.xml=function(a,b,d){if(arguments.length<3){d=b;b=null}d3.xhr(a,b,function(g){d(g&&g.responseXML)})};d3.ns={prefix:{svg:"http://www.w3.org/2000/svg",xhtml:"http://www.w3.org/1999/xhtml",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"},
-qualify:function(a){var b=a.indexOf(":");return b<0?a:{space:d3.ns.prefix[a.substring(0,b)],local:a.substring(b+1)}}};d3.dispatch=function(){for(var a={},b,d=0,g=arguments.length;d<g;d++){b=arguments[d];a[b]=wa(b)}return a};d3.format=function(a){a=Ua.exec(a);var b=a[1]||" ",d=ra[a[3]]||ra["-"],g=a[5],e=+a[6],c=a[7],f=a[8],h=a[9];if(f)f=f.substring(1);if(g)b="0";if(h=="d")f="0";return function(i){i=+i;var k=i<0&&(i=-i);if(h=="d"&&i%1)return"";i=f?i.toFixed(f):""+i;if(c){for(var j=i.lastIndexOf("."),
-o=j>=0?i.substring(j):(j=i.length,""),p=[];j>0;)p.push(i.substring(j-=3,j+3));i=p.reverse().join(",")+o}k=(i=d(k,i)).length;if(k<e)i=Array(e-k+1).join(b)+i;return i}};var Ua=/(?:([^{])?([<>=^]))?([+\- ])?(#)?(0)?([0-9]+)?(,)?(\.[0-9]+)?([a-zA-Z%])?/,ra={"+":function(a,b){return(a?"−":"+")+b}," ":function(a,b){return(a?"−":" ")+b},"-":function(a,b){return a?""+b:b}},Va=R(2),Wa=R(3),Xa={linear:function(){return xa},poly:R,quad:function(){return Va},cubic:function(){return Wa},sin:function(){return ya},
-exp:function(){return za},circle:function(){return Aa},elastic:function(a,b){var d;if(arguments.length<2)b=0.45;if(arguments.length<1){a=1;d=b/4}else d=b/(2*Math.PI)*Math.asin(1/a);return function(g){return 1+a*Math.pow(2,10*-g)*Math.sin((g-d)*2*Math.PI/b)}},back:function(a){a||(a=1.70158);return function(b){return b*b*((a+1)*b-a)}},bounce:function(){return Ba}},Ya={"in":function(a){return a},out:fa,"in-out":ga,"out-in":function(a){return ga(fa(a))}};d3.ease=function(a){var b=a.indexOf("-"),d=b>=
+d)return a;b.push({listener:d,on:true});return a};a.remove=function(d){for(var g=0;g<b.length;g++){var e=b[g];if(e.listener==d){e.on=false;b=b.slice(0,g).concat(b.slice(g+1));break}}return a};a.dispatch=function(){for(var d=b,g=0,e=d.length;g<e;g++){var c=d[g];c.on&&c.listener.apply(this,arguments)}};return a}function fa(a){for(var b=a.lastIndexOf("."),d=b>=0?a.substring(b):(b=a.length,""),g=[];b>0;)g.push(a.substring(b-=3,b+3));return g.reverse().join(",")+d}function ga(a){return function(b){return 1-
+a(1-b)}}function ha(a){return function(b){return 0.5*(b<0.5?a(2*b):2-a(2-2*b))}}function xa(a){return a}function R(a){return function(b){return Math.pow(b,a)}}function ya(a){return 1-Math.cos(a*Math.PI/2)}function za(a){return a?Math.pow(2,10*(a-1))-0.0010:0}function Aa(a){return 1-Math.sqrt(1-a*a)}function Ba(a){return a<1/2.75?7.5625*a*a:a<2/2.75?7.5625*(a-=1.5/2.75)*a+0.75:a<2.5/2.75?7.5625*(a-=2.25/2.75)*a+0.9375:7.5625*(a-=2.625/2.75)*a+0.984375}function J(a,b,d){return{r:a,g:b,b:d,toString:Ca}}
+function Ca(){return"#"+S(this.r)+S(this.g)+S(this.b)}function S(a){return a<16?"0"+a.toString(16):a.toString(16)}function T(a,b,d){var g=0,e=0,c=0,f,h;if(f=/([a-z]+)\((.*)\)/i.exec(a)){h=f[2].split(",");switch(f[1]){case "hsl":return d(parseFloat(h[0]),parseFloat(h[1])/100,parseFloat(h[2])/100);case "rgb":return b(U(h[0]),U(h[1]),U(h[2]))}}if(d=G[a])return b(d.r,d.g,d.b);if(a!=null&&a.charAt(0)=="#"){if(a.length==4){g=a.charAt(1);g+=g;e=a.charAt(2);e+=e;c=a.charAt(3);c+=c}else if(a.length==7){g=
+a.substring(1,3);e=a.substring(3,5);c=a.substring(5,7)}g=parseInt(g,16);e=parseInt(e,16);c=parseInt(c,16)}return b(g,e,c)}function Da(a,b,d){var g=Math.min(a/=255,b/=255,d/=255),e=Math.max(a,b,d),c=e-g,f=(e+g)/2;if(c){g=f<0.5?c/(e+g):c/(2-e-g);a=a==e?(b-d)/c+(b<d?6:0):b==e?(d-a)/c+2:(a-b)/c+4;a*=60}else g=a=0;return V(a,g,f)}function U(a){var b=parseFloat(a);return a.charAt(a.length-1)=="%"?Math.round(b*2.55):b}function V(a,b,d){return{h:a,s:b,l:d,toString:Ea}}function Ea(){return"hsl("+this.h+","+
+this.s*100+"%,"+this.l*100+"%)"}function W(a,b,d){function g(f){if(f>360)f-=360;else if(f<0)f+=360;if(f<60)return e+(c-e)*f/60;if(f<180)return c;if(f<240)return e+(c-e)*(240-f)/60;return e}var e,c;a%=360;if(a<0)a+=360;b=b<0?0:b>1?1:b;d=d<0?0:d>1?1:d;c=d<=0.5?d*(1+b):d+b-d*b;e=2*d-c;return J(Math.round(g(a+120)*255),Math.round(g(a)*255),Math.round(g(a-120)*255))}function y(a){function b(e){for(var c=[],f,h,i,k,j=0,o=a.length;j<o;j++){i=a[j];c.push(f=[]);f.parentNode=i.parentNode;f.parentData=i.parentData;
+for(var p=0,m=i.length;p<m;p++)if(k=i[p]){f.push(h=e(k));if(h&&"__data__"in k)h.__data__=k.__data__}else f.push(null)}return y(c)}function d(e){for(var c=[],f,h,i,k=0,j=a.length;k<j;k++){h=a[k];for(var o=0,p=h.length;o<p;o++)if(i=h[o]){c.push(f=e(i));f.parentNode=i;f.parentData=i.__data__}}return y(c)}function g(e){for(var c=0,f=a.length;c<f;c++)for(var h=a[c],i=0,k=h.length;i<k;i++){var j=h[i];if(j)return e.call(j,j.__data__,i)}return null}a.select=function(e){return b(function(c){return D(e,c)})};
+a.selectAll=function(e){return d(function(c){return ia(e,c)})};a.filter=function(e){for(var c=[],f,h,i,k=0,j=a.length;k<j;k++){h=a[k];c.push(f=[]);f.parentNode=h.parentNode;f.parentData=h.parentData;for(var o=0,p=h.length;o<p;o++)if((i=h[o])&&e.call(i,i.__data__,o))f.push(i)}return y(c)};a.map=function(e){for(var c,f,h=0,i=a.length;h<i;h++){c=a[h];for(var k=0,j=c.length;k<j;k++)if(f=c[k])f.__data__=e.call(f,f.__data__,k)}return a};a.data=function(e,c){function f(m,n){var l=0,q=m.length,r=n.length,
+t=Math.min(q,r),u=Math.max(q,r),s=[],z=[],w=[],x,A;if(c){t={};u=[];var E;A=n.length;for(l=0;l<q;l++){E=c.call(x=m[l],x.__data__,l);if(E in t)w[A++]=m[l];else{t[E]=x;u.push(E)}}for(l=0;l<r;l++){if(x=t[E=c.call(n,A=n[l],l)]){x.__data__=A;s[l]=x;z[l]=w[l]=null}else{z[l]={__data__:A};s[l]=w[l]=null}delete t[E]}for(l=0;l<q;l++)if(u[l]in t)w[l]=m[l]}else{for(;l<t;l++){x=m[l];A=n[l];if(x){x.__data__=A;s[l]=x;z[l]=w[l]=null}else{z[l]={__data__:A};s[l]=w[l]=null}}for(;l<r;l++){z[l]={__data__:n[l]};s[l]=w[l]=
+null}for(;l<u;l++){w[l]=m[l];z[l]=s[l]=null}}z.parentNode=s.parentNode=w.parentNode=m.parentNode;z.parentData=s.parentData=w.parentData=m.parentData;h.push(z);i.push(s);k.push(w)}var h=[],i=[],k=[],j=-1,o=a.length,p;if(typeof e=="function")for(;++j<o;)f(p=a[j],e.call(p,p.parentData,j));else for(;++j<o;)f(p=a[j],e);j=y(i);j.enter=function(){return Fa(h)};j.exit=function(){return y(k)};return j};a.each=function(e){for(var c=0,f=a.length;c<f;c++)for(var h=a[c],i=0,k=h.length;i<k;i++){var j=h[i];j&&e.call(j,
+j.__data__,i)}return a};a.empty=function(){return!g(function(){return true})};a.node=function(){return g(function(){return this})};a.attr=function(e,c){function f(){this.removeAttribute(e)}function h(){this.removeAttributeNS(e.space,e.local)}function i(){this.setAttribute(e,c)}function k(){this.setAttributeNS(e.space,e.local,c)}function j(){var p=c.apply(this,arguments);p==null?this.removeAttribute(e):this.setAttribute(e,p)}function o(){var p=c.apply(this,arguments);p==null?this.removeAttributeNS(e.space,
+e.local):this.setAttributeNS(e.space,e.local,p)}e=d3.ns.qualify(e);if(arguments.length<2)return g(e.local?function(){return this.getAttributeNS(e.space,e.local)}:function(){return this.getAttribute(e)});return a.each(c==null?e.local?h:f:typeof c=="function"?e.local?o:j:e.local?k:i)};a.classed=function(e,c){function f(){var j=this.className;k.lastIndex=0;if(!k.test(j))this.className=da(j+" "+e)}function h(){var j=da(this.className.replace(k," "));this.className=j.length?j:null}function i(){(c.apply(this,
+arguments)?f:h).call(this)}var k=RegExp("(^|\\s+)"+d3.requote(e)+"(\\s+|$)","g");if(arguments.length<2)return g(function(){k.lastIndex=0;return k.test(this.className)});return a.each(typeof c=="function"?i:c?f:h)};a.style=function(e,c,f){function h(){this.style.removeProperty(e)}function i(){this.style.setProperty(e,c,f)}function k(){var j=c.apply(this,arguments);j==null?this.style.removeProperty(e):this.style.setProperty(e,j,f)}if(arguments.length<3)f=null;if(arguments.length<2)return g(function(){return window.getComputedStyle(this,
+null).getPropertyValue(e)});return a.each(c==null?h:typeof c=="function"?k:i)};a.property=function(e,c){function f(){delete this[e]}function h(){this[e]=c}function i(){var k=c.apply(this,arguments);if(k==null)delete this[e];else this[e]=k}e=d3.ns.qualify(e);if(arguments.length<2)return g(function(){return this[e]});return a.each(c==null?f:typeof c=="function"?i:h)};a.text=function(e){function c(){this.appendChild(document.createTextNode(e))}function f(){var h=e.apply(this,arguments);h!=null&&this.appendChild(document.createTextNode(h))}
+if(arguments.length<1)return g(function(){return this.textContent});a.each(function(){for(;this.lastChild;)this.removeChild(this.lastChild)});return e==null?a:a.each(typeof e=="function"?f:c)};a.html=function(e){function c(){this.innerHTML=e}function f(){this.innerHTML=e.apply(this,arguments)}if(arguments.length<1)return g(function(){return this.innerHTML});return a.each(typeof e=="function"?f:c)};a.append=function(e){function c(h){return h.appendChild(document.createElement(e))}function f(h){return h.appendChild(document.createElementNS(e.space,
+e.local))}e=d3.ns.qualify(e);return b(e.local?f:c)};a.insert=function(e,c){function f(i){return i.insertBefore(document.createElement(e),D(c,i))}function h(i){return i.insertBefore(document.createElementNS(e.space,e.local),D(c,i))}e=d3.ns.qualify(e);return b(e.local?h:f)};a.remove=function(){return b(function(e){var c=e.parentNode;c.removeChild(e);return c})};a.sort=function(e){e=Ga.apply(this,arguments);for(var c=0,f=a.length;c<f;c++){var h=a[c];h.sort(e);for(var i=1,k=h.length,j=h[0];i<k;i++){var o=
+h[i];if(o){j&&j.parentNode.insertBefore(o,j.nextSibling);j=o}}}return a};a.on=function(e,c){var f=e.indexOf("."),h=f==-1?e:e.substring(0,f),i="__on"+e;return a.each(function(k,j){function o(p){var m=d3.event;d3.event=p;try{c.call(this,k,j)}finally{d3.event=m}}this[i]&&this.removeEventListener(h,this[i],false);if(c)this.addEventListener(h,this[i]=o,false)})};a.transition=function(){return X(a)};a.call=ea;return a}function Fa(a){function b(d){for(var g=[],e,c,f,h,i=0,k=a.length;i<k;i++){f=a[i];g.push(e=
+[]);e.parentNode=f.parentNode;e.parentData=f.parentData;for(var j=0,o=f.length;j<o;j++)if(h=f[j]){e.push(c=d(f.parentNode));c.__data__=h.__data__}else e.push(null)}return y(g)}a.append=function(d){function g(c){return c.appendChild(document.createElement(d))}function e(c){return c.appendChild(document.createElementNS(d.space,d.local))}d=d3.ns.qualify(d);return b(d.local?e:g)};a.insert=function(d,g){function e(f){return f.insertBefore(document.createElement(d),D(g,f))}function c(f){return f.insertBefore(document.createElementNS(d.space,
+d.local),D(g,f))}d=d3.ns.qualify(d);return b(d.local?c:e)};return a}function Ga(a){if(!arguments.length)a=d3.ascending;return function(b,d){return a(b&&b.__data__,d&&d.__data__)}}function X(a){function b(m){var n=true,l=-1;a.each(function(){if(i[++l]!=2){var q=(m-k[l])/j[l],r=this.__transition__,t,u,s=c[l];if(q<1){n=false;if(q<0)return}else q=1;if(i[l]){if(!r||r.active!=g){i[l]=2;return}}else if(!r||r.active>g){i[l]=2;return}else{i[l]=1;h.start.dispatch.apply(this,arguments);s=c[l]={};r.active=g;
+for(u in e)s[u]=e[u].apply(this,arguments)}t=p(q);for(u in e)s[u].call(this,t);if(q==1){i[l]=2;if(r.active==g){q=r.owner;if(q==g){delete this.__transition__;f&&this.parentNode.removeChild(this)}Y=g;h.end.dispatch.apply(this,arguments);Y=0;r.owner=q}}}});return n}var d={},g=Y||++Ha,e={},c=[],f=false,h=d3.dispatch("start","end"),i=[],k=[],j=[],o,p=d3.ease("cubic-in-out");a.each(function(){(this.__transition__||(this.__transition__={})).owner=g});d.delay=function(m){var n=Infinity,l=-1;if(typeof m==
+"function")a.each(function(){var q=k[++l]=+m.apply(this,arguments);if(q<n)n=q});else{n=+m;a.each(function(){k[++l]=n})}Ia(b,n);return d};d.duration=function(m){var n=-1;if(typeof m=="function"){o=0;a.each(function(){var l=j[++n]=+m.apply(this,arguments);if(l>o)o=l})}else{o=+m;a.each(function(){j[++n]=o})}return d};d.ease=function(m){p=typeof m=="string"?d3.ease(m):m;return d};d.attrTween=function(m,n){function l(r,t){var u=n.call(this,r,t,this.getAttribute(m));return function(s){this.setAttribute(m,
+u(s))}}function q(r,t){var u=n.call(this,r,t,this.getAttributeNS(m.space,m.local));return function(s){this.setAttributeNS(m.space,m.local,u(s))}}e["attr."+m]=m.local?q:l;return d};d.attr=function(m,n){return d.attrTween(m,ja(n))};d.styleTween=function(m,n,l){if(arguments.length<3)l=null;e["style."+m]=function(q,r){var t=n.call(this,q,r,window.getComputedStyle(this,null).getPropertyValue(m));return function(u){this.style.setProperty(m,t(u),l)}};return d};d.style=function(m,n,l){if(arguments.length<
+3)l=null;return d.styleTween(m,ja(n),l)};d.select=function(m){var n;m=X(a.select(m)).ease(p);n=-1;m.delay(function(){return k[++n]});n=-1;m.duration(function(){return j[++n]});return m};d.selectAll=function(m){var n;m=X(a.selectAll(m)).ease(p);n=-1;m.delay(function(l,q){return k[q?n:++n]});n=-1;m.duration(function(l,q){return j[q?n:++n]});return m};d.remove=function(){f=true;return d};d.each=function(m,n){h[m].add(n);return d};d.call=ea;return d.delay(0).duration(250)}function ja(a){return typeof a==
+"function"?function(b,d,g){return d3.interpolate(g,String(a.call(this,b,d)))}:(a=String(a),function(b,d,g){return d3.interpolate(g,a)})}function Ia(a,b){var d=Date.now(),g=false,e=d+b,c=F;if(isFinite(b)){for(;c;){if(c.callback==a){c.then=d;c.delay=b;g=true}else{var f=c.then+c.delay;if(f<e)e=f}c=c.next}g||(F={callback:a,then:d,delay:b,next:F});if(!K){clearTimeout(Z);Z=setTimeout(Ja,Math.max(24,e-d))}}}function Ja(){K=setInterval(Ka,24);Z=0}function Ka(){for(var a,b=Date.now(),d=F;d;){a=b-d.then;if(a>
+d.delay)d.flush=d.callback(a);d=d.next}a=null;for(b=F;b;)b=b.flush?a?a.next=b.next:F=b.next:(a=b).next;a||(K=clearInterval(K))}function La(a){return a.innerRadius}function Ma(a){return a.outerRadius}function ka(a){return a.startAngle}function la(a){return a.endAngle}function $(a,b,d,g){var e=[],c=-1,f=b.length,h=typeof d=="function",i=typeof g=="function",k;if(h&&i)for(;++c<f;)e.push([d.call(a,k=b[c],c),g.call(a,k,c)]);else if(h)for(;++c<f;)e.push([d.call(a,b[c],c),g]);else if(i)for(;++c<f;)e.push([d,
+g.call(a,b[c],c)]);else for(;++c<f;)e.push([d,g]);return e}function ma(a){return a[0]}function na(a){return a[1]}function H(a){var b=[],d=0,g=a.length,e=a[0];for(b.push(e[0],",",e[1]);++d<g;)b.push("L",(e=a[d])[0],",",e[1]);return b.join("")}function oa(a,b){if(b.length<1||a.length!=b.length&&a.length!=b.length+2)return H(a);var d=a.length!=b.length,g="",e=a[0],c=a[1],f=b[0],h=f,i=1;if(d){g+="Q"+(c[0]-f[0]*2/3)+","+(c[1]-f[1]*2/3)+","+c[0]+","+c[1];e=a[1];i=2}if(b.length>1){h=b[1];c=a[i];i++;g+="C"+
+(e[0]+f[0])+","+(e[1]+f[1])+","+(c[0]-h[0])+","+(c[1]-h[1])+","+c[0]+","+c[1];for(e=2;e<b.length;e++,i++){c=a[i];h=b[e];g+="S"+(c[0]-h[0])+","+(c[1]-h[1])+","+c[0]+","+c[1]}}if(d){d=a[i];g+="Q"+(c[0]+h[0]*2/3)+","+(c[1]+h[1]*2/3)+","+d[0]+","+d[1]}return g}function pa(a,b){for(var d=[],g=(1-b)/2,e=a[0],c=a[1],f=a[2],h=2,i=a.length;++h<i;){d.push([g*(f[0]-e[0]),g*(f[1]-e[1])]);e=c;c=f;f=a[h]}d.push([g*(f[0]-e[0]),g*(f[1]-e[1])]);return d}function B(a,b){return a[0]*b[0]+a[1]*b[1]+a[2]*b[2]+a[3]*b[3]}
+function L(a,b,d){a.push("C",B(qa,b),",",B(qa,d),",",B(ra,b),",",B(ra,d),",",B(M,b),",",B(M,d))}function Na(){return 0}function Oa(a){return a.source}function Pa(a){return a.target}function Qa(a){return a.radius}function Ra(){return 64}function Sa(){return"circle"}d3={version:"1.5.1"};if(!Date.now)Date.now=function(){return+new Date};if(!Object.create)Object.create=function(a){function b(){}b.prototype=a;return new b};var N=function(a){return Array.prototype.slice.call(a)};try{N(document.documentElement.childNodes)}catch(eb){N=
+ua}d3.ascending=function(a,b){return a<b?-1:a>b?1:0};d3.descending=function(a,b){return b<a?-1:b>a?1:0};d3.min=function(a,b){var d=0,g=a.length,e=a[0],c;if(arguments.length==1)for(;++d<g;){if(e>(c=a[d]))e=c}else for(e=b(a[0]);++d<g;)if(e>(c=b(a[d])))e=c;return e};d3.max=function(a,b){var d=0,g=a.length,e=a[0],c;if(arguments.length==1)for(;++d<g;){if(e<(c=a[d]))e=c}else for(e=b(e);++d<g;)if(e<(c=b(a[d])))e=c;return e};d3.nest=function(){function a(h,i){if(i>=g.length)return f?f.call(d,h):c?h.sort(c):
+h;for(var k=-1,j=h.length,o=g[i++],p,m,n={};++k<j;)if((p=o(m=h[k]))in n)n[p].push(m);else n[p]=[m];for(p in n)n[p]=a(n[p],i);return n}function b(h,i){if(i>=g.length)return h;var k=[],j=e[i++],o;for(o in h)k.push({key:o,values:b(h[o],i)});j&&k.sort(function(p,m){return j(p.key,m.key)});return k}var d={},g=[],e=[],c,f;d.map=function(h){return a(h,0)};d.entries=function(h){return b(a(h,0),0)};d.key=function(h){g.push(h);return d};d.sortKeys=function(h){e[g.length-1]=h;return d};d.sortValues=function(h){c=
+h;return d};d.rollup=function(h){f=h;return d};return d};d3.keys=function(a){var b=[],d;for(d in a)b.push(d);return b};d3.values=function(a){var b=[],d;for(d in a)b.push(a[d]);return b};d3.entries=function(a){var b=[],d;for(d in a)b.push({key:d,value:a[d]});return b};d3.merge=function(a){return Array.prototype.concat.apply([],a)};d3.split=function(a,b){var d=[],g=[],e,c=-1,f=a.length;if(arguments.length<2)b=va;for(;++c<f;)if(b.call(g,e=a[c],c))g=[];else{g.length||d.push(g);g.push(e)}return d};d3.range=
+function(a,b,d){if(arguments.length==1){b=a;a=0}if(d==null)d=1;if((b-a)/d==Infinity)throw Error("infinite range");var g=[],e=-1,c;if(d<0)for(;(c=a+d*++e)>b;)g.push(c);else for(;(c=a+d*++e)<b;)g.push(c);return g};d3.requote=function(a){return a.replace(Ta,"\\$&")};var Ta=/[\\\^\$\*\+\?\[\]\(\)\.\{\}]/g;d3.xhr=function(a,b,d){var g=new XMLHttpRequest;if(arguments.length<3)d=b;else b&&g.overrideMimeType(b);g.open("GET",a,true);g.onreadystatechange=function(){if(g.readyState==4)d(g.status<300?g:null)};
+g.send(null)};d3.text=function(a,b,d){if(arguments.length<3){d=b;b=null}d3.xhr(a,b,function(g){d(g&&g.responseText)})};d3.json=function(a,b){d3.text(a,"application/json",function(d){b(d?JSON.parse(d):null)})};d3.html=function(a,b){d3.text(a,"text/html",function(d){if(d!=null){var g=document.createRange();g.selectNode(document.body);d=g.createContextualFragment(d)}b(d)})};d3.xml=function(a,b,d){if(arguments.length<3){d=b;b=null}d3.xhr(a,b,function(g){d(g&&g.responseXML)})};d3.ns={prefix:{svg:"http://www.w3.org/2000/svg",
+xhtml:"http://www.w3.org/1999/xhtml",xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"},qualify:function(a){var b=a.indexOf(":");return b<0?a:{space:d3.ns.prefix[a.substring(0,b)],local:a.substring(b+1)}}};d3.dispatch=function(){for(var a={},b,d=0,g=arguments.length;d<g;d++){b=arguments[d];a[b]=wa(b)}return a};d3.format=function(a){a=Ua.exec(a);var b=a[1]||" ",d=a[3]||"",g=a[5],e=+a[6],c=a[7],f=a[8],h=a[9];if(f)f=f.substring(1);if(g){b=
+"0";if(c)e-=Math.floor((e-1)/4)}if(h=="d")f="0";return function(i){i=+i;var k=i<0&&(i=-i)?"":d;if(h=="d"&&i%1)return"";i=f?i.toFixed(f):""+i;if(g){var j=i.length+k.length;if(j<e)i=Array(e-j+1).join(b)+i;if(c)i=fa(i);i=k+i}else{if(c)i=fa(i);i=k+i;j=i.length;if(j<e)i=Array(e-j+1).join(b)+i}return i}};var Ua=/(?:([^{])?([<>=^]))?([+\- ])?(#)?(0)?([0-9]+)?(,)?(\.[0-9]+)?([a-zA-Z%])?/,Va=R(2),Wa=R(3),Xa={linear:function(){return xa},poly:R,quad:function(){return Va},cubic:function(){return Wa},sin:function(){return ya},
+exp:function(){return za},circle:function(){return Aa},elastic:function(a,b){var d;if(arguments.length<2)b=0.45;if(arguments.length<1){a=1;d=b/4}else d=b/(2*Math.PI)*Math.asin(1/a);return function(g){return 1+a*Math.pow(2,10*-g)*Math.sin((g-d)*2*Math.PI/b)}},back:function(a){a||(a=1.70158);return function(b){return b*b*((a+1)*b-a)}},bounce:function(){return Ba}},Ya={"in":function(a){return a},out:ga,"in-out":ha,"out-in":function(a){return ha(ga(a))}};d3.ease=function(a){var b=a.indexOf("-"),d=b>=
0?a.substring(0,b):a;b=b>=0?a.substring(b+1):"in";return Ya[b](Xa[d].apply(null,Array.prototype.slice.call(arguments,1)))};d3.event=null;d3.interpolate=function(a,b){if(typeof b=="number")return d3.interpolateNumber(+a,b);if(typeof b=="string")return b in G||/^(#|rgb\(|hsl\()/.test(b)?d3.interpolateRgb(String(a),b):d3.interpolateString(String(a),b);if(b instanceof Array)return d3.interpolateArray(a,b);return d3.interpolateObject(a,b)};d3.interpolateNumber=function(a,b){b-=a;return function(d){return a+
b*d}};d3.interpolateRound=function(a,b){b-=a;return function(d){return Math.round(a+b*d)}};d3.interpolateString=function(a,b){var d,g,e=0,c=[],f=[],h,i;for(g=0;d=aa.exec(b);++g){d.index&&c.push(b.substring(e,d.index));f.push({i:c.length,x:d[0]});c.push(null);e=aa.lastIndex}e<b.length&&c.push(b.substring(e));g=0;for(h=f.length;(d=aa.exec(a))&&g<h;++g){i=f[g];if(i.x==d[0]){if(i.i)if(c[i.i+1]==null){c[i.i-1]+=i.x;c.splice(i.i,1);for(d=g+1;d<h;++d)f[d].i--}else{c[i.i-1]+=i.x+c[i.i+1];c.splice(i.i,2);
for(d=g+1;d<h;++d)f[d].i-=2}else if(c[i.i+1]==null)c[i.i]=i.x;else{c[i.i]=i.x+c[i.i+1];c.splice(i.i+1,1);for(d=g+1;d<h;++d)f[d].i--}f.splice(g,1);h--;g--}else i.x=d3.interpolateNumber(parseFloat(d[0]),parseFloat(i.x))}for(;g<h;){i=f.pop();if(c[i.i+1]==null)c[i.i]=i.x;else{c[i.i]=i.x+c[i.i+1];c.splice(i.i+1,1)}h--}if(c.length==1)return c[0]==null?f[0].x:function(){return b};return function(k){for(g=0;g<h;++g)c[(i=f[g]).i]=i.x(k);return c.join("")}};d3.interpolateRgb=function(a,b){a=d3.rgb(a);b=d3.rgb(b);
@@ -45,7 +45,7 @@ goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#
lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",
navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",
silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"},ba;for(ba in G)G[ba]=T(G[ba],J,W);d3.hsl=function(a,b,d){return arguments.length==1?T(""+a,Da,V):V(+a,+b,+d)};var D=function(a,b){return b.querySelector(a)},
-ha=function(a,b){return N(b.querySelectorAll(a))};if(typeof Sizzle=="function"){D=function(a,b){return Sizzle(a,b)[0]};ha=Sizzle}var O=y([[document]]);O[0].parentNode=document.documentElement;d3.select=function(a){return typeof a=="string"?O.select(a):y([[a]])};d3.selectAll=function(a){return typeof a=="string"?O.selectAll(a):y([N(a)])};d3.transition=O.transition;var Ha=0,Y=0,F=null,Z=0,K;d3.scale={};d3.scale.linear=function(){function a(j){return k((j-d)*f)}function b(j){var o=Math.min(d,g),p=Math.max(d,
+ia=function(a,b){return N(b.querySelectorAll(a))};if(typeof Sizzle=="function"){D=function(a,b){return Sizzle(a,b)[0]};ia=Sizzle}var O=y([[document]]);O[0].parentNode=document.documentElement;d3.select=function(a){return typeof a=="string"?O.select(a):y([[a]])};d3.selectAll=function(a){return typeof a=="string"?O.selectAll(a):y([N(a)])};d3.transition=O.transition;var Ha=0,Y=0,F=null,Z=0,K;d3.scale={};d3.scale.linear=function(){function a(j){return k((j-d)*f)}function b(j){var o=Math.min(d,g),p=Math.max(d,
g),m=p-o,n=Math.pow(10,Math.floor(Math.log(m/j)/Math.LN10));j=j/(m/n);if(j<=0.15)n*=10;else if(j<=0.35)n*=5;else if(j<=0.75)n*=2;return{start:Math.ceil(o/n)*n,stop:Math.floor(p/n)*n+n*0.5,step:n}}var d=0,g=1,e=0,c=1,f=1/(g-d),h=(g-d)/(c-e),i=d3.interpolate,k=i(e,c);a.invert=function(j){return(j-e)*h+d};a.domain=function(j){if(!arguments.length)return[d,g];d=j[0];g=j[1];f=1/(g-d);h=(g-d)/(c-e);return a};a.range=function(j){if(!arguments.length)return[e,c];e=j[0];c=j[1];h=(g-d)/(c-e);k=i(e,c);return a};
a.rangeRound=function(j){return a.range(j).interpolate(d3.interpolateRound)};a.interpolate=function(j){if(!arguments.length)return i;k=(i=j)(e,c);return a};a.ticks=function(j){j=b(j);return d3.range(j.start,j.stop,j.step)};a.tickFormat=function(j){j=Math.max(0,-Math.floor(Math.log(b(j).step)/Math.LN10+0.01));return d3.format(",."+j+"f")};return a};d3.scale.log=function(){function a(c){return(e?-Math.log(-c):Math.log(c))/Math.LN10}function b(c){return e?-Math.pow(10,-c):Math.pow(10,c)}function d(c){return g(a(c))}
var g=d3.scale.linear(),e=false;d.invert=function(c){return b(g.invert(c))};d.domain=function(c){if(!arguments.length)return g.domain().map(b);e=(c[0]||c[1])<0;g.domain(c.map(a));return d};d.range=C(d,g.range);d.rangeRound=C(d,g.rangeRound);d.interpolate=C(d,g.interpolate);d.ticks=function(){var c=g.domain(),f=[];if(c.every(isFinite)){var h=Math.floor(c[0]),i=Math.ceil(c[1]),k=b(c[0]);c=b(c[1]);if(e)for(f.push(b(h));h++<i;)for(var j=9;j>0;j--)f.push(b(h)*j);else{for(;h<i;h++)for(j=1;j<10;j++)f.push(b(h)*
@@ -57,12 +57,12 @@ c[0],i=c[1],k=i-h,j=Math.floor(k/(b.length+f));g=d3.range(h+Math.round((k-(b.len
"#e6550d","#fd8d3c","#fdae6b","#fdd0a2","#31a354","#74c476","#a1d99b","#c7e9c0","#756bb1","#9e9ac8","#bcbddc","#dadaeb","#636363","#969696","#bdbdbd","#d9d9d9"];d3.scale.quantile=function(){function a(){for(var f=-1,h=c.length=e.length,i=g.length/h;++f<h;)c[f]=g[~~(f*i)]}function b(f){if(isNaN(f=+f))return NaN;for(var h=0,i=c.length-1;h<=i;){var k=h+i>>1,j=c[k];if(j<f)h=k+1;else if(j>f)i=k-1;else return k}return i<0?0:i}function d(f){return e[b(f)]}var g=[],e=[],c=[];d.domain=function(f){if(!arguments.length)return g;
g=f.filter(function(h){return!isNaN(h)}).sort(d3.ascending);a();return d};d.range=function(f){if(!arguments.length)return e;e=f;a();return d};d.quantiles=function(){return c};return d};d3.scale.quantize=function(){function a(f){return c[Math.max(0,Math.min(e,Math.floor(g*(f-b))))]}var b=0,d=1,g=2,e=1,c=[0,1];a.domain=function(f){if(!arguments.length)return[b,d];b=f[0];d=f[1];g=c.length/(d-b);return a};a.range=function(f){if(!arguments.length)return c;c=f;g=c.length/(d-b);e=c.length-1;return a};return a};
d3.svg={};d3.svg.arc=function(){function a(){var c=b.apply(this,arguments),f=d.apply(this,arguments),h=g.apply(this,arguments)+I,i=e.apply(this,arguments)+I,k=i-h,j=k<Math.PI?"0":"1",o=Math.cos(h);h=Math.sin(h);var p=Math.cos(i);i=Math.sin(i);return k>=db?c?"M0,"+f+"A"+f+","+f+" 0 1,1 0,"+-f+"A"+f+","+f+" 0 1,1 0,"+f+"M0,"+c+"A"+c+","+c+" 0 1,1 0,"+-c+"A"+c+","+c+" 0 1,1 0,"+c+"Z":"M0,"+f+"A"+f+","+f+" 0 1,1 0,"+-f+"A"+f+","+f+" 0 1,1 0,"+f+"Z":c?"M"+f*o+","+f*h+"A"+f+","+f+" 0 "+j+",1 "+f*p+","+
-f*i+"L"+c*p+","+c*i+"A"+c+","+c+" 0 "+j+",0 "+c*o+","+c*h+"Z":"M"+f*o+","+f*h+"A"+f+","+f+" 0 "+j+",1 "+f*p+","+f*i+"L0,0Z"}var b=La,d=Ma,g=ja,e=ka;a.innerRadius=function(c){if(!arguments.length)return b;b=v(c);return a};a.outerRadius=function(c){if(!arguments.length)return d;d=v(c);return a};a.startAngle=function(c){if(!arguments.length)return g;g=v(c);return a};a.endAngle=function(c){if(!arguments.length)return e;e=v(c);return a};a.centroid=function(){var c=(b.apply(this,arguments)+d.apply(this,
-arguments))/2,f=(g.apply(this,arguments)+e.apply(this,arguments))/2+I;return[Math.cos(f)*c,Math.sin(f)*c]};return a};var I=-Math.PI/2,db=2*Math.PI-1.0E-6;d3.svg.line=function(){function a(f){return f.length<1?null:"M"+e($(this,f,b,d),c)}var b=la,d=ma,g="linear",e=P[g],c=0.7;a.x=function(f){if(!arguments.length)return b;b=f;return a};a.y=function(f){if(!arguments.length)return d;d=f;return a};a.interpolate=function(f){if(!arguments.length)return g;e=P[g=f];return a};a.tension=function(f){if(!arguments.length)return c;
+f*i+"L"+c*p+","+c*i+"A"+c+","+c+" 0 "+j+",0 "+c*o+","+c*h+"Z":"M"+f*o+","+f*h+"A"+f+","+f+" 0 "+j+",1 "+f*p+","+f*i+"L0,0Z"}var b=La,d=Ma,g=ka,e=la;a.innerRadius=function(c){if(!arguments.length)return b;b=v(c);return a};a.outerRadius=function(c){if(!arguments.length)return d;d=v(c);return a};a.startAngle=function(c){if(!arguments.length)return g;g=v(c);return a};a.endAngle=function(c){if(!arguments.length)return e;e=v(c);return a};a.centroid=function(){var c=(b.apply(this,arguments)+d.apply(this,
+arguments))/2,f=(g.apply(this,arguments)+e.apply(this,arguments))/2+I;return[Math.cos(f)*c,Math.sin(f)*c]};return a};var I=-Math.PI/2,db=2*Math.PI-1.0E-6;d3.svg.line=function(){function a(f){return f.length<1?null:"M"+e($(this,f,b,d),c)}var b=ma,d=na,g="linear",e=P[g],c=0.7;a.x=function(f){if(!arguments.length)return b;b=f;return a};a.y=function(f){if(!arguments.length)return d;d=f;return a};a.interpolate=function(f){if(!arguments.length)return g;e=P[g=f];return a};a.tension=function(f){if(!arguments.length)return c;
c=f;return a};return a};var P={linear:H,basis:function(a){if(a.length<3)return H(a);var b=[],d=1,g=a.length,e=a[0],c=e[0],f=e[1],h=[c,c,c,(e=a[1])[0]],i=[f,f,f,e[1]];b.push(c,",",f);for(L(b,h,i);++d<g;){e=a[d];h.shift();h.push(e[0]);i.shift();i.push(e[1]);L(b,h,i)}for(d=-1;++d<2;){h.shift();h.push(e[0]);i.shift();i.push(e[1]);L(b,h,i)}return b.join("")},"basis-closed":function(a){for(var b,d=-1,g=a.length,e=g+4,c,f=[],h=[];++d<4;){c=a[d%g];f.push(c[0]);h.push(c[1])}b=[B(M,f),",",B(M,h)];for(--d;++d<
-e;){c=a[d%g];f.shift();f.push(c[0]);h.shift();h.push(c[1]);L(b,f,h)}return b.join("")},cardinal:function(a,b){if(a.length<3)return H(a);return a[0]+na(a,oa(a,b))},"cardinal-closed":function(a,b){if(a.length<3)return H(a);return a[0]+na(a,oa([a[a.length-2]].concat(a,[a[1]]),b))}},pa=[0,2/3,1/3,0],qa=[0,1/3,2/3,0],M=[0,1/6,2/3,1/6];d3.svg.area=function(){function a(h){return h.length<1?null:"M"+c($(this,h,b,g),f)+"L"+c($(this,h,b,d).reverse(),f)+"Z"}var b=la,d=Na,g=ma,e="linear",c=P[e],f=0.7;a.x=function(h){if(!arguments.length)return b;
+e;){c=a[d%g];f.shift();f.push(c[0]);h.shift();h.push(c[1]);L(b,f,h)}return b.join("")},cardinal:function(a,b){if(a.length<3)return H(a);return a[0]+oa(a,pa(a,b))},"cardinal-closed":function(a,b){if(a.length<3)return H(a);return a[0]+oa(a,pa([a[a.length-2]].concat(a,[a[1]]),b))}},qa=[0,2/3,1/3,0],ra=[0,1/3,2/3,0],M=[0,1/6,2/3,1/6];d3.svg.area=function(){function a(h){return h.length<1?null:"M"+c($(this,h,b,g),f)+"L"+c($(this,h,b,d).reverse(),f)+"Z"}var b=ma,d=Na,g=na,e="linear",c=P[e],f=0.7;a.x=function(h){if(!arguments.length)return b;
b=h;return a};a.y0=function(h){if(!arguments.length)return d;d=h;return a};a.y1=function(h){if(!arguments.length)return g;g=h;return a};a.interpolate=function(h){if(!arguments.length)return e;c=P[e=h];return a};a.tension=function(h){if(!arguments.length)return f;f=h;return a};return a};d3.svg.chord=function(){function a(h,i){var k=b(this,d,h,i),j=b(this,g,h,i);return"M"+k.p0+("A"+k.r+","+k.r+" 0 0,1 "+k.p1)+(k.a0==j.a0&&k.a1==j.a1?"Q 0,0 "+k.p0:"Q 0,0 "+j.p0+("A"+j.r+","+j.r+" 0 0,1 "+j.p1)+("Q 0,0 "+
-k.p0))+"Z"}function b(h,i,k,j){var o=i.call(h,k,j);i=e.call(h,o,j);k=c.call(h,o,j)+I;h=f.call(h,o,j)+I;return{r:i,a0:k,a1:h,p0:[i*Math.cos(k),i*Math.sin(k)],p1:[i*Math.cos(h),i*Math.sin(h)]}}var d=Oa,g=Pa,e=Qa,c=ja,f=ka;a.radius=function(h){if(!arguments.length)return e;e=v(h);return a};a.source=function(h){if(!arguments.length)return d;d=v(h);return a};a.target=function(h){if(!arguments.length)return g;g=v(h);return a};a.startAngle=function(h){if(!arguments.length)return c;c=v(h);return a};a.endAngle=
+k.p0))+"Z"}function b(h,i,k,j){var o=i.call(h,k,j);i=e.call(h,o,j);k=c.call(h,o,j)+I;h=f.call(h,o,j)+I;return{r:i,a0:k,a1:h,p0:[i*Math.cos(k),i*Math.sin(k)],p1:[i*Math.cos(h),i*Math.sin(h)]}}var d=Oa,g=Pa,e=Qa,c=ka,f=la;a.radius=function(h){if(!arguments.length)return e;e=v(h);return a};a.source=function(h){if(!arguments.length)return d;d=v(h);return a};a.target=function(h){if(!arguments.length)return g;g=v(h);return a};a.startAngle=function(h){if(!arguments.length)return c;c=v(h);return a};a.endAngle=
function(h){if(!arguments.length)return f;f=v(h);return a};return a};d3.svg.mouse=function(a){var b=(a.ownerSVGElement||a).createSVGPoint();if(ca<0&&(window.scrollX||window.scrollY)){var d=d3.select(document.body).append("svg:svg").style("position","absolute").style("top",0).style("left",0),g=d[0][0].getScreenCTM();ca=!(g.f||g.e);d.remove()}if(ca){b.x=d3.event.pageX;b.y=d3.event.pageY}else{b.x=d3.event.clientX;b.y=d3.event.clientY}b=b.matrixTransform(a.getScreenCTM().inverse());return[b.x,b.y]};var ca=
/WebKit/.test(navigator.userAgent)?-1:0;d3.svg.symbol=function(){function a(g,e){return(sa[b.call(this,g,e)]||sa.circle)(d.call(this,g,e))}var b=Sa,d=Ra;a.type=function(g){if(!arguments.length)return b;b=v(g);return a};a.size=function(g){if(!arguments.length)return d;d=v(g);return a};return a};d3.svg.symbolTypes=["circle","cross","diamond","square","triangle-down","triangle-up"];var sa={circle:function(a){a=Math.sqrt(a/Math.PI);return"M0,"+a+"A"+a+","+a+" 0 1,1 0,"+-a+"A"+a+","+a+" 0 1,1 0,"+a+"Z"},
cross:function(a){a=Math.sqrt(a/5)/2;return"M"+-3*a+","+-a+"H"+-a+"V"+-3*a+"H"+a+"V"+-a+"H"+3*a+"V"+a+"H"+a+"V"+3*a+"H"+-a+"V"+a+"H"+-3*a+"Z"},diamond:function(a){a=Math.sqrt(a/(2*ta));var b=a*ta;return"M0,"+-a+"L"+b+",0 0,"+a+" "+-b+",0Z"},square:function(a){a=Math.sqrt(a)/2;return"M"+-a+","+-a+"L"+a+","+-a+" "+a+","+a+" "+-a+","+a+"Z"},"triangle-down":function(a){a=Math.sqrt(a/Q);var b=a*Q/2;return"M0,"+b+"L"+a+","+-b+" "+-a+","+-b+"Z"},"triangle-up":function(a){a=Math.sqrt(a/Q);var b=a*Q/2;return"M0,"+
View
2  src/core/core.js
@@ -1 +1 @@
-d3 = {version: "1.5.0"}; // semver
+d3 = {version: "1.5.1"}; // semver
View
50 src/core/format.js
@@ -2,30 +2,45 @@
d3.format = function(specifier) {
var match = d3_format_re.exec(specifier),
fill = match[1] || " ",
- sign = d3_format_signs[match[3]] || d3_format_signs["-"],
+ sign = match[3] || "",
zfill = match[5],
width = +match[6],
comma = match[7],
precision = match[8],
type = match[9];
if (precision) precision = precision.substring(1);
- if (zfill) fill = "0"; // TODO align = "=";
+ if (zfill) {
+ fill = "0"; // TODO align = "=";
+ if (comma) width -= Math.floor((width - 1) / 4);
+ }
if (type == "d") precision = "0";
return function(value) {
var number = +value,
- negative = (number < 0) && (number = -number);
+ negative = (number < 0) && (number = -number) ? "\u2212" : sign;
+
+ // Return the empty string for floats formatted as ints.
if ((type == "d") && (number % 1)) return "";
+
+ // Convert the input value to the desired precision.
if (precision) value = number.toFixed(precision);
else value = "" + number;
- if (comma) {
- var i = value.lastIndexOf("."),
- f = i >= 0 ? value.substring(i) : (i = value.length, ""),
- t = [];
- while (i > 0) t.push(value.substring(i -= 3, i + 3));
- value = t.reverse().join(",") + f;
+
+ // If the fill character is 0, the sign and group is applied after the fill.
+ if (zfill) {
+ var length = value.length + negative.length;
+ if (length < width) value = new Array(width - length + 1).join(fill) + value;
+ if (comma) value = d3_format_group(value);
+ value = negative + value;
}
- var length = (value = sign(negative, value)).length;
- if (length < width) value = new Array(width - length + 1).join(fill) + value;
+
+ // Otherwise (e.g., space-filling), the sign and group is applied before.
+ else {
+ if (comma) value = d3_format_group(value);
+ value = negative + value;
+ var length = value.length;
+ if (length < width) value = new Array(width - length + 1).join(fill) + value;
+ }
+
return value;
};
};
@@ -33,8 +48,11 @@ d3.format = function(specifier) {
// [[fill]align][sign][#][0][width][,][.precision][type]
var d3_format_re = /(?:([^{])?([<>=^]))?([+\- ])?(#)?(0)?([0-9]+)?(,)?(\.[0-9]+)?([a-zA-Z%])?/;
-var d3_format_signs = {
- "+": function(negative, value) { return (negative ? "\u2212" : "+") + value; },
- " ": function(negative, value) { return (negative ? "\u2212" : " ") + value; },
- "-": function(negative, value) { return negative ? "\u2212" + value : value; }
-};
+// Apply comma grouping for thousands.
+function d3_format_group(value) {
+ var i = value.lastIndexOf("."),
+ f = i >= 0 ? value.substring(i) : (i = value.length, ""),
+ t = [];
+ while (i > 0) t.push(value.substring(i -= 3, i + 3));
+ return t.reverse().join(",") + f;
+}
View
109 tests/test-format.js
@@ -0,0 +1,109 @@
+require("./../lib/env-js/envjs/node");
+require("./../d3");
+
+console.log("zero fill:");
+console.log(" ", d3.format("08d")(0));
+console.log(" ", d3.format("08d")(42));
+console.log(" ", d3.format("08d")(42000000));
+console.log(" ", d3.format("08d")(420000000));
+console.log(" ", d3.format("08d")(-4));
+console.log(" ", d3.format("08d")(-42));
+console.log(" ", d3.format("08d")(-4200000));
+console.log(" ", d3.format("08d")(-42000000));
+console.log("");
+
+console.log("space fill:");
+console.log(" ", d3.format("8d")(0));
+console.log(" ", d3.format("8d")(42));
+console.log(" ", d3.format("8d")(42000000));
+console.log(" ", d3.format("8d")(420000000));
+console.log(" ", d3.format("8d")(-4));
+console.log(" ", d3.format("8d")(-42));
+console.log(" ", d3.format("8d")(-4200000));
+console.log(" ", d3.format("8d")(-42000000));
+console.log("");
+
+// TODO fill with other characters (requires align support)
+
+console.log("grouping:");
+console.log(" ", d3.format(",d")(0));
+console.log(" ", d3.format(",d")(42));
+console.log(" ", d3.format(",d")(42000000));
+console.log(" ", d3.format(",d")(420000000));
+console.log(" ", d3.format(",d")(-4));
+console.log(" ", d3.format(",d")(-42));
+console.log(" ", d3.format(",d")(-4200000));
+console.log(" ", d3.format(",d")(-42000000));
+console.log("");
+
+console.log("grouping with zero fill:");
+console.log(" ", d3.format("01,d")(0));
+console.log(" ", d3.format("01,d")(0));
+console.log(" ", d3.format("02,d")(0));
+console.log(" ", d3.format("03,d")(0));
+console.log(" ", d3.format("05,d")(0));
+console.log(" ", d3.format("08,d")(0));
+console.log(" ", d3.format("013,d")(0));
+console.log(" ", d3.format("021,d")(0));
+console.log("");
+
+console.log("grouping with zero fill (overflow):");
+console.log(" ", d3.format("01,d")(1));
+console.log(" ", d3.format("01,d")(1));
+console.log(" ", d3.format("02,d")(12));
+console.log(" ", d3.format("03,d")(123));
+console.log(" ", d3.format("05,d")(12345));
+console.log(" ", d3.format("08,d")(12345678));
+console.log(" ", d3.format("013,d")(1234567890123));
+console.log("");
+
+console.log("grouping with space fill:");
+console.log(" ", d3.format("1,d")(0));
+console.log(" ", d3.format("1,d")(0));
+console.log(" ", d3.format("2,d")(0));
+console.log(" ", d3.format("3,d")(0));
+console.log(" ", d3.format("5,d")(0));
+console.log(" ", d3.format("8,d")(0));
+console.log(" ", d3.format("13,d")(0));
+console.log(" ", d3.format("21,d")(0));
+console.log("");
+
+console.log("grouping with space fill (overflow):");
+console.log(" ", d3.format("1,d")(1));
+console.log(" ", d3.format("1,d")(1));
+console.log(" ", d3.format("2,d")(12));
+console.log(" ", d3.format("3,d")(123));
+console.log(" ", d3.format("5,d")(12345));
+console.log(" ", d3.format("8,d")(12345678));
+console.log(" ", d3.format("13,d")(1234567890123));
+console.log("");
+
+console.log("precision:");
+console.log(" ", d3.format(".1f")(0.49));
+console.log(" ", d3.format(".2f")(0.449));
+console.log(" ", d3.format(".3f")(0.4449));
+console.log(" ", d3.format(".5f")(0.444449));
+console.log(" ", d3.format(".1f")(100));
+console.log(" ", d3.format(".2f")(100));
+console.log(" ", d3.format(".3f")(100));
+console.log(" ", d3.format(".5f")(100));
+console.log("");
+
+console.log("precision and grouping with space fill:");
+console.log(" ", d3.format("10,.1f")(123456.49));
+console.log(" ", d3.format("10,.2f")(1234567.449));
+console.log(" ", d3.format("10,.3f")(12345678.4449));
+console.log(" ", d3.format("10,.5f")(123456789.444449));
+console.log(" ", d3.format("10,.1f")(123456));
+console.log(" ", d3.format("10,.2f")(1234567));
+console.log(" ", d3.format("10,.3f")(12345678));
+console.log(" ", d3.format("10,.5f")(123456789));
+console.log("");
+
+console.log("float type passed int:");
+console.log(" ", d3.format("f")(42));
+console.log("");
+
+console.log("int type passed float:");
+console.log(" ", d3.format("d")(4.2));
+console.log("");
View
94 tests/test-format.out
@@ -0,0 +1,94 @@
+zero fill:
+ 00000000
+ 00000042
+ 42000000
+ 420000000
+ −0000004
+ −0000042
+ −4200000
+ −42000000
+
+space fill:
+ 0
+ 42
+ 42000000
+ 420000000
+ −4
+ −42
+ −4200000
+ −42000000
+
+grouping:
+ 0
+ 42
+ 42,000,000
+ 420,000,000
+ −4
+ −42
+ −4,200,000
+ −42,000,000
+
+grouping with zero fill:
+ 0
+ 0
+ 00
+ 000
+ 0,000
+ 0,000,000
+ 0,000,000,000
+ 0,000,000,000,000,000
+
+grouping with zero fill (overflow):
+ 1
+ 1
+ 12
+ 123
+ 12,345
+ 12,345,678
+ 1,234,567,890,123
+
+grouping with space fill:
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+ 0
+
+grouping with space fill (overflow):
+ 1
+ 1
+ 12
+ 123
+ 12,345
+ 12,345,678
+ 1,234,567,890,123
+
+precision:
+ 0.5
+ 0.45
+ 0.445
+ 0.44445
+ 100.0
+ 100.00
+ 100.000
+ 100.00000
+
+precision and grouping with space fill:
+ 123,456.5
+ 1,234,567.45
+ 12,345,678.445
+ 123,456,789.44445
+ 123,456.0
+ 1,234,567.00
+ 12,345,678.000
+ 123,456,789.00000
+
+float type passed int:
+ 42
+
+int type passed float:
+
+
Please sign in to comment.
Something went wrong with that request. Please try again.