Socket
Socket
Sign inDemoInstall

d3-scale

Package Overview
Dependencies
Maintainers
1
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

d3-scale - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

8

build/scale.js

@@ -12,3 +12,9 @@ if (typeof Map === "undefined") {

};
}
} else (function() {
var m = new Map;
if (m.set(0, 0) !== m) {
m = m.set;
Map.prototype.set = function() { m.apply(this, arguments); return this; };
}
})();

@@ -15,0 +21,0 @@ (function (global, factory) {

2

build/scale.min.js

@@ -1,1 +0,1 @@

"undefined"==typeof Map&&(Map=function(){this.clear()},Map.prototype={set:function(t,n){return this._[t]=n,this},get:function(t){return this._[t]},has:function(t){return t in this._},"delete":function(t){return t in this._&&delete this._[t]},clear:function(){this._=Object.create(null)},get size(){var t=0;for(var n in this._)++t;return t},forEach:function(t){for(var n in this._)t(this._[n],n,this)}}),function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(t.scale={})}(this,function(t){"use strict";function n(t,n){return n>t?-1:t>n?1:t>=n?0:0/0}function e(t){return function(e,r){return n(t(e),r)}}function r(t){return 1===t.length&&(t=e(t)),{left:function(n,e,r,i){for(arguments.length<3&&(r=0),arguments.length<4&&(i=n.length);i>r;){var u=r+i>>>1;t(n[u],e)<0?r=u+1:i=u}return r},right:function(n,e,r,i){for(arguments.length<3&&(r=0),arguments.length<4&&(i=n.length);i>r;){var u=r+i>>>1;t(n[u],e)>0?i=u:r=u+1}return r}}}function i(t,n,e){function r(r){return r>=r?n[bt(t,r,0,e)]:void 0}return r.domain=function(i){return arguments.length?(t=i.slice(),e=Math.min(t.length,n.length-1),r):t.slice()},r.range=function(i){return arguments.length?(n=i.slice(),e=Math.min(t.length,n.length-1),r):n.slice()},r.invertExtent=function(e){return e=n.indexOf(e),[t[e-1],t[e]]},r.copy=function(){return i(t,n)},r}function u(){return i([.5],[0,1],1)}function a(t,n){return t=+t,n-=t,function(e){return t+n*e}}function o(t,n){var e,r={},i={};for(e in t)e in n?r[e]=x(t[e],n[e]):i[e]=t[e];for(e in n)e in t||(i[e]=n[e]);return function(t){for(e in r)i[e]=r[e](t);return i}}function s(t,n){var e,r=[],i=[],u=t.length,a=n.length,o=Math.min(t.length,n.length);for(e=0;o>e;++e)r.push(x(t[e],n[e]));for(;u>e;++e)i[e]=t[e];for(;a>e;++e)i[e]=n[e];return function(t){for(e=0;o>e;++e)i[e]=r[e](t);return i}}function c(t,n,e){return isNaN(t)&&(t=0),isNaN(n)&&(n=0),isNaN(e)&&(e=0),"#"+(16>t?"0"+t.toString(16):t.toString(16))+(16>n?"0"+n.toString(16):n.toString(16))+(16>e?"0"+e.toString(16):e.toString(16))}function l(t,n,e){this.r=Math.max(0,Math.min(255,Math.round(t))),this.g=Math.max(0,Math.min(255,Math.round(n))),this.b=Math.max(0,Math.min(255,Math.round(e)))}function h(){}function f(t){return b(t>>16&255,t>>8&255,255&t)}function g(t,n,e){this.h=+t,this.s=Math.max(0,Math.min(1,+n)),this.l=Math.max(0,Math.min(1,+e))}function d(t,n,e){return 255*(60>t?n+(e-n)*t/60:180>t?e:240>t?n+(e-n)*(240-t)/60:n)}function m(t,n,e){if(1===arguments.length)if(t instanceof g)e=t.l,n=t.s,t=t.h;else if(t instanceof h||(t=p(t)),t){if(t instanceof g)return t;t=t.rgb();var r=t.r/255,i=t.g/255,u=t.b/255,a=Math.min(r,i,u),o=Math.max(r,i,u),s=o-a;e=(o+a)/2,s?(n=.5>e?s/(o+a):s/(2-o-a),t=r===o?(i-u)/s+6*(u>i):i===o?(u-r)/s+2:(r-i)/s+4,t*=60):(t=0/0,n=e>0&&1>e?0:t)}else t=n=e=0/0;return new g(t,n,e)}function p(t){var n;return t=(t+"").trim().toLowerCase(),(n=At.exec(t))?(n=parseInt(n[1],16),b(n>>8&15|n>>4&240,n>>4&15|240&n,(15&n)<<4|15&n)):(n=jt.exec(t))?f(parseInt(n[1],16)):(n=St.exec(t))?b(n[1],n[2],n[3]):(n=qt.exec(t))?b(2.55*n[1],2.55*n[2],2.55*n[3]):(n=Nt.exec(t))?m(n[1],.01*n[2],.01*n[3]):wt.has(t)?f(wt.get(t)):null}function b(t,n,e){return 1===arguments.length&&(t instanceof h||(t=p(t)),t?(t=t.rgb(),e=t.b,n=t.g,t=t.r):t=n=e=0/0),new l(t,n,e)}function M(t,n){t=b(t),n=b(n);var e=t.r,r=t.g,i=t.b,u=n.r-e,a=n.g-r,o=n.b-i;return function(t){return c(Math.round(e+u*t),Math.round(r+a*t),Math.round(i+o*t))}}function v(t){return function(){return t}}function y(t){return function(n){return t(n)+""}}function w(t,n){var e,r,i,u=Et.lastIndex=$t.lastIndex=0,o=-1,s=[],c=[];for(t+="",n+="";(e=Et.exec(t))&&(r=$t.exec(n));)(i=r.index)>u&&(i=n.slice(u,i),s[o]?s[o]+=i:s[++o]=i),(e=e[0])===(r=r[0])?s[o]?s[o]+=r:s[++o]=r:(s[++o]=null,c.push({i:o,x:a(e,r)})),u=$t.lastIndex;return u<n.length&&(i=n.slice(u),s[o]?s[o]+=i:s[++o]=i),s.length<2?c[0]?y(c[0].x):v(n):(n=c.length,function(t){for(var e,r=0;n>r;++r)s[(e=c[r]).i]=e.x(t);return s.join("")})}function x(t,n){for(var e,r=Pt.length;--r>=0&&!(e=Pt[r](t,n)););return e}function k(t,n){null==n&&(n=10);var e=t[0],r=t[t.length-1];e>r&&(a=r,r=e,e=a);var i=r-e,u=Math.pow(10,Math.floor(Math.log(i/n)/Math.LN10)),a=i/n/u;return a>=zt?u*=10:a>=Rt?u*=5:a>=_t&&(u*=2),[Math.ceil(e/u)*u,Math.floor(r/u)*u+u/2,u]}function N(t,n){if(t=t.slice(),!n)return t;var e,r=0,i=t.length-1,u=t[r],a=t[i];return u>a&&(e=r,r=i,i=e,e=u,u=a,a=e),t[r]=Math.floor(u/n)*n,t[i]=Math.ceil(a/n)*n,t}function q(t,n){if((e=(t=t.toExponential(n&&n-1)).indexOf("e"))<0)return null;var e,r=t.slice(0,e);return[r.length>1?r[0]+r.slice(2):r,+t.slice(e+1)]}function S(t){return t=q(Math.abs(t)),t?t[1]:0/0}function j(t,n){var e=q(t,n);if(!e)return t+"";var r=e[0],i=e[1],u=i-(kt=3*Math.max(-8,Math.min(8,Math.floor(i/3))))+1,a=r.length;return u===a?r:u>a?r+new Array(u-a+1).join("0"):u>0?r.slice(0,u)+"."+r.slice(u):"0."+new Array(1-u).join("0")+q(t,n+u-1)[0]}function A(t,n){var e=q(t,n);if(!e)return t+"";var r=e[0],i=e[1];return 0>i?"0."+new Array(-i).join("0")+r:r.length>i+1?r.slice(0,i+1)+"."+r.slice(i+1):r+new Array(i-r.length+2).join("0")}function E(t,n){t=t.toPrecision(n);t:for(var e,r=t.length,i=1,u=-1;r>i;++i)switch(t[i]){case".":u=e=i;break;case"0":0===u&&(u=i),e=i;break;case"e":break t;default:u>0&&(u=0)}return u>0?t.slice(0,u)+t.slice(e+1):t}function $(t){if(!(n=Bt.exec(t)))throw new Error("invalid format: "+t);var n,e=n[1]||" ",r=n[2]||">",i=n[3]||"-",u=n[4]||"",a=!!n[5],o=n[6]&&+n[6],s=!!n[7],c=n[8]&&+n[8].slice(1),l=n[9]||"";"n"===l?(s=!0,l="g"):Ot[l]||(l=""),(a||"0"===e&&"="===r)&&(a=!0,e="0",r="="),this.fill=e,this.align=r,this.sign=i,this.symbol=u,this.zero=a,this.width=o,this.comma=s,this.precision=c,this.type=l}function P(t){return new $(t)}function _(t){return t}function R(t,n){return function(e,r){for(var i=e.length,u=[],a=0,o=t[0],s=0;i>0&&o>0&&(s+o+1>r&&(o=Math.max(1,r-s)),u.push(e.substring(i-=o,i+o)),!((s+=o+1)>r));)o=t[a=(a+1)%t.length];return u.reverse().join(n)}}function z(t){function n(t){t=P(t);var n=t.fill,e=t.align,a=t.sign,o=t.symbol,s=t.zero,c=t.width,l=t.comma,h=t.precision,f=t.type,g="$"===o?i[0]:"#"===o&&/[boxX]/.test(f)?"0"+f.toLowerCase():"",d="$"===o?i[1]:/[%p]/.test(f)?"%":"",m=Ot[f],p=!f||/[defgprs%]/.test(f);return h=null==h?f?6:12:/[gprs]/.test(f)?Math.max(1,Math.min(21,h)):Math.max(0,Math.min(20,h)),function(t){var i=g,o=d;if("c"===f)o=m(t)+o,t="";else{t=+t;var b=(0>t||0>1/t)&&(t*=-1,!0);if(t=m(t,h),i=(b?"("===a?a:"-":"-"===a||"("===a?"":a)+i,o=o+("s"===f?Ft[8+kt/3]:"")+(b&&"("===a?")":""),p)for(var M,v=-1,y=t.length;++v<y;)if(M=t.charCodeAt(v),48>M||M>57){o=(46===M?u+t.slice(v+1):t.slice(v))+o,t=t.slice(0,v);break}}l&&!s&&(t=r(t,1/0));var w=i.length+t.length+o.length,x=c>w?new Array(c-w+1).join(n):"";switch(l&&s&&(t=r(x+t,x.length?c-o.length:1/0),x=""),e){case"<":return i+t+o+x;case"=":return i+x+t+o;case"^":return x.slice(0,w=x.length>>1)+i+t+o+x.slice(w)}return x+i+t+o}}function e(t,e){var r=n((t=P(t),t.type="f",t)),i=3*Math.max(-8,Math.min(8,Math.floor(S(e)/3))),u=Math.pow(10,-i),a=Ft[8+i/3];return function(t){return r(u*t)+a}}var r=t.grouping&&t.thousands?R(t.grouping,t.thousands):_,i=t.currency,u=t.decimal;return{format:n,formatPrefix:e}}function F(t){return Math.max(0,-S(Math.abs(t)))}function O(t,n){return Math.max(0,S(Math.abs(n))-S(Math.abs(t)))+1}function B(t,n){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(S(n)/3)))-S(Math.abs(t)))}function I(t,n,e){var r=k(t,n);if(null==e)e=",."+F(r[2])+"f";else switch(e=P(e),e.type){case"s":var i=Math.max(Math.abs(r[0]),Math.abs(r[1]));return null==e.precision&&(e.precision=B(r[2],i)),Lt(e,i);case"":case"e":case"g":case"p":case"r":null==e.precision&&(e.precision=O(r[2],Math.max(Math.abs(r[0]),Math.abs(r[1])))-("e"===e.type));break;case"f":case"%":null==e.precision&&(e.precision=F(r[2])-2*("%"===e.type))}return Ct(e)}function C(t){for(var n=1;t*n%1;)n*=10;return n}function L(t,n,e){(i=arguments.length)<3&&(e=1,2>i&&(n=t,t=0));var r=-1,i=0|Math.max(0,Math.ceil((n-t)/e)),u=C(Math.abs(e)),a=new Array(i);for(t*=u,e*=u;++r<i;)a[r]=(t+r*e)/u;return a}function X(t,n){return L.apply(null,k(t,n))}function G(t,n){return t=+t,n-=t,function(e){return Math.round(t+n*e)}}function T(t,n){return n=(n-=t=+t)||1/n,function(e){return(e-t)/n}}function U(t,n){return n=(n-=t=+t)||1/n,function(e){return Math.max(0,Math.min(1,(e-t)/n))}}function Y(t,n,e,r){var i=e(t[0],t[1]),u=r(n[0],n[1]);return function(t){return u(i(t))}}function Z(t,n,e,r){var i=Math.min(t.length,n.length)-1,u=new Array(i),a=new Array(i),o=-1;for(t[i]<t[0]&&(t=t.slice().reverse(),n=n.slice().reverse());++o<i;)u[o]=e(t[o],t[o+1]),a[o]=r(n[o],n[o+1]);return function(n){var e=bt(t,n,1,i)-1;return a[e](u[e](n))}}function D(t,n,e,r){function i(){var i=Math.min(t.length,n.length)>2?Z:Y,c=r?U:T;return o=i(t,n,c,e),s=i(n,t,c,a),u}function u(t){return o(t)}var o,s;return u.invert=function(t){return s(t)},u.domain=function(n){return arguments.length?(t=n.map(Number),i()):t.slice()},u.range=function(t){return arguments.length?(n=t.slice(),i()):n.slice()},u.rangeRound=function(t){return u.range(t).interpolate(G)},u.clamp=function(t){return arguments.length?(r=!!t,i()):r},u.interpolate=function(t){return arguments.length?(e=t,i()):e},u.ticks=function(n){return X(t,n)},u.tickFormat=function(n,e){return I(t,n,e)},u.nice=function(n){return t=N(t,k(t,n)[2]),i()},u.copy=function(){return D(t,n,e,r)},i()}function H(){return D([0,1],[0,1],x,!1)}function J(t,n){return t.range=function(){var e=n.range.apply(n,arguments);return e===n?t:e},t.rangeRound=function(){var e=n.rangeRound.apply(n,arguments);return e===n?t:e},t.clamp=function(){var e=n.clamp.apply(n,arguments);return e===n?t:e},t.interpolate=function(){var e=n.interpolate.apply(n,arguments);return e===n?t:e},t}function K(t,n,e){function r(t){return 0>t?-Math.pow(-t,n):Math.pow(t,n)}function i(t){return 0>t?-Math.pow(-t,1/n):Math.pow(t,1/n)}function u(n){return t(r(n))}return u.invert=function(n){return i(t.invert(n))},u.exponent=function(t){return arguments.length?(n=+t,u.domain(e)):n},u.domain=function(n){return arguments.length?(e=n.map(Number),t.domain(e.map(r)),u):e.slice()},u.ticks=function(t){return X(e,t)},u.tickFormat=function(t,n){return I(e,t,n)},u.nice=function(t){return u.domain(N(e,k(e,t)[2]))},u.copy=function(){return K(t.copy(),n,e)},J(u,t)}function Q(){return K(H(),.5,[0,1])}function V(t,n,e){function r(n){return e[Math.max(0,Math.min(a,Math.floor(u*(n-t))))]}function i(){return u=e.length/(n-t),a=e.length-1,r}var u,a;return r.domain=function(e){return arguments.length?(t=+e[0],n=+e[e.length-1],i()):[t,n]},r.range=function(t){return arguments.length?(e=t.slice(),i()):e.slice()},r.invertExtent=function(n){return n=e.indexOf(n),n=0>n?0/0:n/u+t,[n,n+1/u]},r.copy=function(){return V(t,n,e)},i()}function W(){return V(0,1,[0,1])}function tt(t,n){var e=(t.length-1)*n+1,r=Math.floor(e),i=+t[r-1],u=e-r;return u?i+u*(t[r]-i):i}function nt(t,e){function r(){var n=0,r=e.length;for(u=[];++n<r;)u[n-1]=tt(t,n/r);return i}function i(t){return isNaN(t=+t)?void 0:e[bt(u,t)]}var u;return i.domain=function(e){if(!arguments.length)return t;t=[];for(var i,u=0,a=e.length;a>u;++u)i=e[u],null==i||isNaN(i=+i)||t.push(i);return t.sort(n),r()},i.range=function(t){return arguments.length?(e=t.slice(),r()):e.slice()},i.quantiles=function(){return u},i.invertExtent=function(n){return n=e.indexOf(n),0>n?[0/0,0/0]:[n>0?u[n-1]:t[0],n<u.length?u[n]:t[t.length-1]]},i.copy=function(){return nt(t,e)},r()}function et(){return nt([],[])}function rt(){return K(H(),1,[0,1])}function it(t,n,e){for(var r=new Array(t),i=-1;++i<t;)r[i]=n+e*i;return r}function ut(t,n){function e(e){var u=e+"",a=r.get(u);if(!a){if("range"!==n.t)return;r.set(u,a=t.push(e))}return i[(a-1)%i.length]}var r,i,u;return e.domain=function(i){if(!arguments.length)return t.slice();t=[],r=new Map;for(var u,a,o=-1,s=i.length;++o<s;)r.has(a=(u=i[o])+"")||r.set(a,t.push(u));return e[n.t].apply(e,n.a)},e.range=function(t){return arguments.length?(i=t.slice(),u=0,n={t:"range",a:arguments},e):i.slice()},e.rangePoints=function(r,a){a=arguments.length<2?0:+a;var o=+r[0],s=+r[1],c=t.length<2?(o=(o+s)/2,0):(s-o)/(t.length-1+a);return i=it(t.length,o+c*a/2,c),u=0,n={t:"rangePoints",a:arguments},e},e.rangeRoundPoints=function(r,a){a=arguments.length<2?0:+a;var o=+r[0],s=+r[1],c=t.length<2?(o=s=Math.round((o+s)/2),0):(s-o)/(t.length-1+a)|0;return i=it(t.length,o+Math.round(c*a/2+(s-o-(t.length-1+a)*c)/2),c),u=0,n={t:"rangeRoundPoints",a:arguments},e},e.rangeBands=function(r,a,o){a=arguments.length<2?0:+a,o=arguments.length<3?a:+o;var s=+r[1]<+r[0],c=+r[s-0],l=+r[1-s],h=(l-c)/(t.length-a+2*o);return i=it(t.length,c+h*o,h),s&&i.reverse(),u=h*(1-a),n={t:"rangeBands",a:arguments},e},e.rangeRoundBands=function(r,a,o){a=arguments.length<2?0:+a,o=arguments.length<3?a:+o;var s=+r[1]<+r[0],c=+r[s-0],l=+r[1-s],h=Math.floor((l-c)/(t.length-a+2*o));return i=it(t.length,c+Math.round((l-c-(t.length-a)*h)/2),h),s&&i.reverse(),u=Math.round(h*(1-a)),n={t:"rangeRoundBands",a:arguments},e},e.rangeBand=function(){return u},e.rangeExtent=function(){var t=n.a[0],e=t[0],r=t[t.length-1];return e>r&&(t=r,r=e,e=t),[e,r]},e.copy=function(){return ut(t,n)},e.domain(t)}function at(){return ut([],{t:"range",a:[[]]})}function ot(t,n,e){function r(t){return(e[0]<0?-Math.log(t>0?0:-t):Math.log(0>t?0:t))/Math.log(n)}function i(t){return e[0]<0?-Math.pow(n,-t):Math.pow(n,t)}function u(n){return t(r(n))}return u.invert=function(n){return i(t.invert(n))},u.base=function(t){return arguments.length?(n=+t,u.domain(e)):n},u.domain=function(n){return arguments.length?(e=n.map(Number),t.domain(e.map(r)),u):e.slice()},u.nice=function(){var n=N(t.domain(),1);return t.domain(n),e=n.map(i),u},u.ticks=function(){var t=e[0],u=e[e.length-1];t>u&&(s=t,t=u,u=s);var a,o,s=Math.floor(r(t)),c=Math.ceil(r(u)),l=n%1?2:n,h=[];if(isFinite(c-s))if(t>0){for(--c,a=1;l>a;++a){if((o=i(s)*a)<t)continue;h.push(o)}for(;++s<c;)for(a=1;l>a;++a)h.push(i(s)*a);for(a=1;l>a&&!((o=i(s)*a)>u);++a)h.push(o)}else{for(++s,a=l-1;a>=1;--a){if((o=i(s)*a)<t)continue;h.push(o)}for(;++s<c;)for(a=l-1;a>=1;--a)h.push(i(s)*a);for(a=l-1;a>=1&&!((o=i(s)*a)>u);--a)h.push(o)}return h},u.tickFormat=function(t,a){if(null==a?a=10===n?Gt:Xt:"function"!=typeof a&&(a=Ct(a)),null==t)return a;var o,s=Math.min(n,u.ticks().length/t),c=e[0]>0?(o=1e-12,Math.ceil):(o=-1e-12,Math.floor);return function(t){return i(c(r(t)+o))/t>=s?a(t):""}},u.copy=function(){return ot(t.copy(),n,e)},J(u,t)}function st(){return ot(H(),10,[1,10])}function ct(t){function n(t){return+t}return n.invert=n,n.domain=n.range=function(e){return arguments.length?(t=e.map(Number),n):t.slice()},n.ticks=function(n){return X(t,n)},n.tickFormat=function(n,e){return I(t,n,e)},n.copy=function(){return ct(t)},n}function lt(){return ct([0,1])}function ht(){return at().range(["#3182bd","#6baed6","#9ecae1","#c6dbef","#e6550d","#fd8d3c","#fdae6b","#fdd0a2","#31a354","#74c476","#a1d99b","#c7e9c0","#756bb1","#9e9ac8","#bcbddc","#dadaeb","#636363","#969696","#bdbdbd","#d9d9d9"])}function ft(){return at().range(["#393b79","#5254a3","#6b6ecf","#9c9ede","#637939","#8ca252","#b5cf6b","#cedb9c","#8c6d31","#bd9e39","#e7ba52","#e7cb94","#843c39","#ad494a","#d6616b","#e7969c","#7b4173","#a55194","#ce6dbd","#de9ed6"])}function gt(){return at().range(["#1f77b4","#aec7e8","#ff7f0e","#ffbb78","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5","#8c564b","#c49c94","#e377c2","#f7b6d2","#7f7f7f","#c7c7c7","#bcbd22","#dbdb8d","#17becf","#9edae5"])}function dt(){return at().range(["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"])}var mt=r(n),pt=mt.right,bt=pt;h.prototype={toString:function(){return this.rgb()+""}};var Mt=l.prototype=new h,vt=.7;Mt.darker=function(t){return t=null==t?vt:Math.pow(vt,t),new l(this.r*t,this.g*t,this.b*t)};var yt=1/vt;Mt.brighter=function(t){return t=null==t?yt:Math.pow(yt,t),new l(this.r*t,this.g*t,this.b*t)},Mt.rgb=function(){return this},Mt.toString=function(){return c(this.r,this.g,this.b)};var wt=(new Map).set("aliceblue",15792383).set("antiquewhite",16444375).set("aqua",65535).set("aquamarine",8388564).set("azure",15794175).set("beige",16119260).set("bisque",16770244).set("black",0).set("blanchedalmond",16772045).set("blue",255).set("blueviolet",9055202).set("brown",10824234).set("burlywood",14596231).set("cadetblue",6266528).set("chartreuse",8388352).set("chocolate",13789470).set("coral",16744272).set("cornflowerblue",6591981).set("cornsilk",16775388).set("crimson",14423100).set("cyan",65535).set("darkblue",139).set("darkcyan",35723).set("darkgoldenrod",12092939).set("darkgray",11119017).set("darkgreen",25600).set("darkgrey",11119017).set("darkkhaki",12433259).set("darkmagenta",9109643).set("darkolivegreen",5597999).set("darkorange",16747520).set("darkorchid",10040012).set("darkred",9109504).set("darksalmon",15308410).set("darkseagreen",9419919).set("darkslateblue",4734347).set("darkslategray",3100495).set("darkslategrey",3100495).set("darkturquoise",52945).set("darkviolet",9699539).set("deeppink",16716947).set("deepskyblue",49151).set("dimgray",6908265).set("dimgrey",6908265).set("dodgerblue",2003199).set("firebrick",11674146).set("floralwhite",16775920).set("forestgreen",2263842).set("fuchsia",16711935).set("gainsboro",14474460).set("ghostwhite",16316671).set("gold",16766720).set("goldenrod",14329120).set("gray",8421504).set("green",32768).set("greenyellow",11403055).set("grey",8421504).set("honeydew",15794160).set("hotpink",16738740).set("indianred",13458524).set("indigo",4915330).set("ivory",16777200).set("khaki",15787660).set("lavender",15132410).set("lavenderblush",16773365).set("lawngreen",8190976).set("lemonchiffon",16775885).set("lightblue",11393254).set("lightcoral",15761536).set("lightcyan",14745599).set("lightgoldenrodyellow",16448210).set("lightgray",13882323).set("lightgreen",9498256).set("lightgrey",13882323).set("lightpink",16758465).set("lightsalmon",16752762).set("lightseagreen",2142890).set("lightskyblue",8900346).set("lightslategray",7833753).set("lightslategrey",7833753).set("lightsteelblue",11584734).set("lightyellow",16777184).set("lime",65280).set("limegreen",3329330).set("linen",16445670).set("magenta",16711935).set("maroon",8388608).set("mediumaquamarine",6737322).set("mediumblue",205).set("mediumorchid",12211667).set("mediumpurple",9662683).set("mediumseagreen",3978097).set("mediumslateblue",8087790).set("mediumspringgreen",64154).set("mediumturquoise",4772300).set("mediumvioletred",13047173).set("midnightblue",1644912).set("mintcream",16121850).set("mistyrose",16770273).set("moccasin",16770229).set("navajowhite",16768685).set("navy",128).set("oldlace",16643558).set("olive",8421376).set("olivedrab",7048739).set("orange",16753920).set("orangered",16729344).set("orchid",14315734).set("palegoldenrod",15657130).set("palegreen",10025880).set("paleturquoise",11529966).set("palevioletred",14381203).set("papayawhip",16773077).set("peachpuff",16767673).set("peru",13468991).set("pink",16761035).set("plum",14524637).set("powderblue",11591910).set("purple",8388736).set("rebeccapurple",6697881).set("red",16711680).set("rosybrown",12357519).set("royalblue",4286945).set("saddlebrown",9127187).set("salmon",16416882).set("sandybrown",16032864).set("seagreen",3050327).set("seashell",16774638).set("sienna",10506797).set("silver",12632256).set("skyblue",8900331).set("slateblue",6970061).set("slategray",7372944).set("slategrey",7372944).set("snow",16775930).set("springgreen",65407).set("steelblue",4620980).set("tan",13808780).set("teal",32896).set("thistle",14204888).set("tomato",16737095).set("turquoise",4251856).set("violet",15631086).set("wheat",16113331).set("white",16777215).set("whitesmoke",16119285).set("yellow",16776960).set("yellowgreen",10145074),xt=g.prototype=new h;xt.brighter=function(t){return t=null==t?yt:Math.pow(yt,t),new g(this.h,this.s,this.l*t)},xt.darker=function(t){return t=null==t?vt:Math.pow(vt,t),new g(this.h,this.s,this.l*t)},xt.rgb=function(){var t=this.h%360+360*(this.h<0),n=isNaN(t)||isNaN(this.s)?0:this.s,e=this.l,r=.5>=e?e*(1+n):e+n-e*n,i=2*e-r;return new l(d(t>=240?t-240:t+120,i,r),d(t,i,r),d(120>t?t+240:t-120,i,r))};var kt,Nt=/^hsl\(\s*([-+]?\d+(?:\.\d+)?)\s*,\s*([-+]?\d+(?:\.\d+)?)%\s*,\s*([-+]?\d+(?:\.\d+)?)%\s*\)$/,qt=/^rgb\(\s*([-+]?\d+(?:\.\d+)?)%\s*,\s*([-+]?\d+(?:\.\d+)?)%\s*,\s*([-+]?\d+(?:\.\d+)?)%\s*\)$/,St=/^rgb\(\s*([-+]?\d+)\s*,\s*([-+]?\d+)\s*,\s*([-+]?\d+)\s*\)$/,jt=/^#([0-9a-f]{6})$/,At=/^#([0-9a-f]{3})$/,Et=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,$t=new RegExp(Et.source,"g"),Pt=[function(t,n){var e,r=typeof n;return("string"===r?(e=p(n))?(n=e,M):w:n instanceof p?M:Array.isArray(n)?s:"object"===r&&isNaN(n)?o:a)(t,n)}],_t=Math.sqrt(2),Rt=Math.sqrt(10),zt=Math.sqrt(50),Ft=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"],Ot={"":E,"%":function(t,n){return(100*t).toFixed(n)},b:function(t){return Math.round(t).toString(2)},c:function(t){return t+""},d:function(t){return Math.round(t).toString(10)},e:function(t,n){return t.toExponential(n)},f:function(t,n){return t.toFixed(n)},g:function(t,n){return t.toPrecision(n)},o:function(t){return Math.round(t).toString(8)},p:function(t,n){return A(100*t,n)},r:A,s:j,X:function(t){return Math.round(t).toString(16).toUpperCase()},x:function(t){return Math.round(t).toString(16)}},Bt=/^(?:(.)?([<>=^]))?([+\-\( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?([a-z%])?$/i;$.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(null==this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(null==this.precision?"":"."+Math.max(0,0|this.precision))+this.type};var It=z({decimal:".",thousands:",",grouping:[3],currency:["$",""]}),Ct=It.format,Lt=It.formatPrefix,Xt=Ct(","),Gt=Ct(".0e");t.category10=dt,t.category20=gt,t.category20b=ft,t.category20c=ht,t.identity=lt,t.linear=H,t.log=st,t.ordinal=at,t.pow=rt,t.quantile=et,t.quantize=W,t.sqrt=Q,t.threshold=u});
"undefined"==typeof Map?(Map=function(){this.clear()},Map.prototype={set:function(t,n){return this._[t]=n,this},get:function(t){return this._[t]},has:function(t){return t in this._},"delete":function(t){return t in this._&&delete this._[t]},clear:function(){this._=Object.create(null)},get size(){var t=0;for(var n in this._)++t;return t},forEach:function(t){for(var n in this._)t(this._[n],n,this)}}):function(){var t=new Map;t.set(0,0)!==t&&(t=t.set,Map.prototype.set=function(){return t.apply(this,arguments),this})}(),function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(t.scale={})}(this,function(t){"use strict";function n(t,n){return n>t?-1:t>n?1:t>=n?0:0/0}function e(t){return function(e,r){return n(t(e),r)}}function r(t){return 1===t.length&&(t=e(t)),{left:function(n,e,r,i){for(arguments.length<3&&(r=0),arguments.length<4&&(i=n.length);i>r;){var a=r+i>>>1;t(n[a],e)<0?r=a+1:i=a}return r},right:function(n,e,r,i){for(arguments.length<3&&(r=0),arguments.length<4&&(i=n.length);i>r;){var a=r+i>>>1;t(n[a],e)>0?i=a:r=a+1}return r}}}function i(t,n,e){function r(r){return r>=r?n[bt(t,r,0,e)]:void 0}return r.domain=function(i){return arguments.length?(t=i.slice(),e=Math.min(t.length,n.length-1),r):t.slice()},r.range=function(i){return arguments.length?(n=i.slice(),e=Math.min(t.length,n.length-1),r):n.slice()},r.invertExtent=function(e){return e=n.indexOf(e),[t[e-1],t[e]]},r.copy=function(){return i(t,n)},r}function a(){return i([.5],[0,1],1)}function u(t,n){return t=+t,n-=t,function(e){return t+n*e}}function o(t,n){var e,r={},i={};for(e in t)e in n?r[e]=x(t[e],n[e]):i[e]=t[e];for(e in n)e in t||(i[e]=n[e]);return function(t){for(e in r)i[e]=r[e](t);return i}}function s(t,n){var e,r=[],i=[],a=t.length,u=n.length,o=Math.min(t.length,n.length);for(e=0;o>e;++e)r.push(x(t[e],n[e]));for(;a>e;++e)i[e]=t[e];for(;u>e;++e)i[e]=n[e];return function(t){for(e=0;o>e;++e)i[e]=r[e](t);return i}}function c(t,n,e){return isNaN(t)&&(t=0),isNaN(n)&&(n=0),isNaN(e)&&(e=0),"#"+(16>t?"0"+t.toString(16):t.toString(16))+(16>n?"0"+n.toString(16):n.toString(16))+(16>e?"0"+e.toString(16):e.toString(16))}function l(t,n,e){this.r=Math.max(0,Math.min(255,Math.round(t))),this.g=Math.max(0,Math.min(255,Math.round(n))),this.b=Math.max(0,Math.min(255,Math.round(e)))}function h(){}function f(t){return b(t>>16&255,t>>8&255,255&t)}function g(t,n,e){this.h=+t,this.s=Math.max(0,Math.min(1,+n)),this.l=Math.max(0,Math.min(1,+e))}function d(t,n,e){return 255*(60>t?n+(e-n)*t/60:180>t?e:240>t?n+(e-n)*(240-t)/60:n)}function m(t,n,e){if(1===arguments.length)if(t instanceof g)e=t.l,n=t.s,t=t.h;else if(t instanceof h||(t=p(t)),t){if(t instanceof g)return t;t=t.rgb();var r=t.r/255,i=t.g/255,a=t.b/255,u=Math.min(r,i,a),o=Math.max(r,i,a),s=o-u;e=(o+u)/2,s?(n=.5>e?s/(o+u):s/(2-o-u),t=r===o?(i-a)/s+6*(a>i):i===o?(a-r)/s+2:(r-i)/s+4,t*=60):(t=0/0,n=e>0&&1>e?0:t)}else t=n=e=0/0;return new g(t,n,e)}function p(t){var n;return t=(t+"").trim().toLowerCase(),(n=At.exec(t))?(n=parseInt(n[1],16),b(n>>8&15|n>>4&240,n>>4&15|240&n,(15&n)<<4|15&n)):(n=jt.exec(t))?f(parseInt(n[1],16)):(n=St.exec(t))?b(n[1],n[2],n[3]):(n=qt.exec(t))?b(2.55*n[1],2.55*n[2],2.55*n[3]):(n=Nt.exec(t))?m(n[1],.01*n[2],.01*n[3]):wt.has(t)?f(wt.get(t)):null}function b(t,n,e){return 1===arguments.length&&(t instanceof h||(t=p(t)),t?(t=t.rgb(),e=t.b,n=t.g,t=t.r):t=n=e=0/0),new l(t,n,e)}function M(t,n){t=b(t),n=b(n);var e=t.r,r=t.g,i=t.b,a=n.r-e,u=n.g-r,o=n.b-i;return function(t){return c(Math.round(e+a*t),Math.round(r+u*t),Math.round(i+o*t))}}function v(t){return function(){return t}}function y(t){return function(n){return t(n)+""}}function w(t,n){var e,r,i,a=Et.lastIndex=$t.lastIndex=0,o=-1,s=[],c=[];for(t+="",n+="";(e=Et.exec(t))&&(r=$t.exec(n));)(i=r.index)>a&&(i=n.slice(a,i),s[o]?s[o]+=i:s[++o]=i),(e=e[0])===(r=r[0])?s[o]?s[o]+=r:s[++o]=r:(s[++o]=null,c.push({i:o,x:u(e,r)})),a=$t.lastIndex;return a<n.length&&(i=n.slice(a),s[o]?s[o]+=i:s[++o]=i),s.length<2?c[0]?y(c[0].x):v(n):(n=c.length,function(t){for(var e,r=0;n>r;++r)s[(e=c[r]).i]=e.x(t);return s.join("")})}function x(t,n){for(var e,r=Pt.length;--r>=0&&!(e=Pt[r](t,n)););return e}function k(t,n){null==n&&(n=10);var e=t[0],r=t[t.length-1];e>r&&(u=r,r=e,e=u);var i=r-e,a=Math.pow(10,Math.floor(Math.log(i/n)/Math.LN10)),u=i/n/a;return u>=zt?a*=10:u>=Rt?a*=5:u>=_t&&(a*=2),[Math.ceil(e/a)*a,Math.floor(r/a)*a+a/2,a]}function N(t,n){if(t=t.slice(),!n)return t;var e,r=0,i=t.length-1,a=t[r],u=t[i];return a>u&&(e=r,r=i,i=e,e=a,a=u,u=e),t[r]=Math.floor(a/n)*n,t[i]=Math.ceil(u/n)*n,t}function q(t,n){if((e=(t=t.toExponential(n&&n-1)).indexOf("e"))<0)return null;var e,r=t.slice(0,e);return[r.length>1?r[0]+r.slice(2):r,+t.slice(e+1)]}function S(t){return t=q(Math.abs(t)),t?t[1]:0/0}function j(t,n){var e=q(t,n);if(!e)return t+"";var r=e[0],i=e[1],a=i-(kt=3*Math.max(-8,Math.min(8,Math.floor(i/3))))+1,u=r.length;return a===u?r:a>u?r+new Array(a-u+1).join("0"):a>0?r.slice(0,a)+"."+r.slice(a):"0."+new Array(1-a).join("0")+q(t,n+a-1)[0]}function A(t,n){var e=q(t,n);if(!e)return t+"";var r=e[0],i=e[1];return 0>i?"0."+new Array(-i).join("0")+r:r.length>i+1?r.slice(0,i+1)+"."+r.slice(i+1):r+new Array(i-r.length+2).join("0")}function E(t,n){t=t.toPrecision(n);t:for(var e,r=t.length,i=1,a=-1;r>i;++i)switch(t[i]){case".":a=e=i;break;case"0":0===a&&(a=i),e=i;break;case"e":break t;default:a>0&&(a=0)}return a>0?t.slice(0,a)+t.slice(e+1):t}function $(t){if(!(n=Bt.exec(t)))throw new Error("invalid format: "+t);var n,e=n[1]||" ",r=n[2]||">",i=n[3]||"-",a=n[4]||"",u=!!n[5],o=n[6]&&+n[6],s=!!n[7],c=n[8]&&+n[8].slice(1),l=n[9]||"";"n"===l?(s=!0,l="g"):Ot[l]||(l=""),(u||"0"===e&&"="===r)&&(u=!0,e="0",r="="),this.fill=e,this.align=r,this.sign=i,this.symbol=a,this.zero=u,this.width=o,this.comma=s,this.precision=c,this.type=l}function P(t){return new $(t)}function _(t){return t}function R(t,n){return function(e,r){for(var i=e.length,a=[],u=0,o=t[0],s=0;i>0&&o>0&&(s+o+1>r&&(o=Math.max(1,r-s)),a.push(e.substring(i-=o,i+o)),!((s+=o+1)>r));)o=t[u=(u+1)%t.length];return a.reverse().join(n)}}function z(t){function n(t){t=P(t);var n=t.fill,e=t.align,u=t.sign,o=t.symbol,s=t.zero,c=t.width,l=t.comma,h=t.precision,f=t.type,g="$"===o?i[0]:"#"===o&&/[boxX]/.test(f)?"0"+f.toLowerCase():"",d="$"===o?i[1]:/[%p]/.test(f)?"%":"",m=Ot[f],p=!f||/[defgprs%]/.test(f);return h=null==h?f?6:12:/[gprs]/.test(f)?Math.max(1,Math.min(21,h)):Math.max(0,Math.min(20,h)),function(t){var i=g,o=d;if("c"===f)o=m(t)+o,t="";else{t=+t;var b=(0>t||0>1/t)&&(t*=-1,!0);if(t=m(t,h),i=(b?"("===u?u:"-":"-"===u||"("===u?"":u)+i,o=o+("s"===f?Ft[8+kt/3]:"")+(b&&"("===u?")":""),p)for(var M,v=-1,y=t.length;++v<y;)if(M=t.charCodeAt(v),48>M||M>57){o=(46===M?a+t.slice(v+1):t.slice(v))+o,t=t.slice(0,v);break}}l&&!s&&(t=r(t,1/0));var w=i.length+t.length+o.length,x=c>w?new Array(c-w+1).join(n):"";switch(l&&s&&(t=r(x+t,x.length?c-o.length:1/0),x=""),e){case"<":return i+t+o+x;case"=":return i+x+t+o;case"^":return x.slice(0,w=x.length>>1)+i+t+o+x.slice(w)}return x+i+t+o}}function e(t,e){var r=n((t=P(t),t.type="f",t)),i=3*Math.max(-8,Math.min(8,Math.floor(S(e)/3))),a=Math.pow(10,-i),u=Ft[8+i/3];return function(t){return r(a*t)+u}}var r=t.grouping&&t.thousands?R(t.grouping,t.thousands):_,i=t.currency,a=t.decimal;return{format:n,formatPrefix:e}}function F(t){return Math.max(0,-S(Math.abs(t)))}function O(t,n){return Math.max(0,S(Math.abs(n))-S(Math.abs(t)))+1}function B(t,n){return Math.max(0,3*Math.max(-8,Math.min(8,Math.floor(S(n)/3)))-S(Math.abs(t)))}function I(t,n,e){var r=k(t,n);if(null==e)e=",."+F(r[2])+"f";else switch(e=P(e),e.type){case"s":var i=Math.max(Math.abs(r[0]),Math.abs(r[1]));return null==e.precision&&(e.precision=B(r[2],i)),Lt(e,i);case"":case"e":case"g":case"p":case"r":null==e.precision&&(e.precision=O(r[2],Math.max(Math.abs(r[0]),Math.abs(r[1])))-("e"===e.type));break;case"f":case"%":null==e.precision&&(e.precision=F(r[2])-2*("%"===e.type))}return Ct(e)}function C(t){for(var n=1;t*n%1;)n*=10;return n}function L(t,n,e){(i=arguments.length)<3&&(e=1,2>i&&(n=t,t=0));var r=-1,i=0|Math.max(0,Math.ceil((n-t)/e)),a=C(Math.abs(e)),u=new Array(i);for(t*=a,e*=a;++r<i;)u[r]=(t+r*e)/a;return u}function X(t,n){return L.apply(null,k(t,n))}function G(t,n){return t=+t,n-=t,function(e){return Math.round(t+n*e)}}function T(t,n){return n=(n-=t=+t)||1/n,function(e){return(e-t)/n}}function U(t,n){return n=(n-=t=+t)||1/n,function(e){return Math.max(0,Math.min(1,(e-t)/n))}}function Y(t,n,e,r){var i=e(t[0],t[1]),a=r(n[0],n[1]);return function(t){return a(i(t))}}function Z(t,n,e,r){var i=Math.min(t.length,n.length)-1,a=new Array(i),u=new Array(i),o=-1;for(t[i]<t[0]&&(t=t.slice().reverse(),n=n.slice().reverse());++o<i;)a[o]=e(t[o],t[o+1]),u[o]=r(n[o],n[o+1]);return function(n){var e=bt(t,n,1,i)-1;return u[e](a[e](n))}}function D(t,n,e,r){function i(){var i=Math.min(t.length,n.length)>2?Z:Y,c=r?U:T;return o=i(t,n,c,e),s=i(n,t,c,u),a}function a(t){return o(t)}var o,s;return a.invert=function(t){return s(t)},a.domain=function(n){return arguments.length?(t=n.map(Number),i()):t.slice()},a.range=function(t){return arguments.length?(n=t.slice(),i()):n.slice()},a.rangeRound=function(t){return a.range(t).interpolate(G)},a.clamp=function(t){return arguments.length?(r=!!t,i()):r},a.interpolate=function(t){return arguments.length?(e=t,i()):e},a.ticks=function(n){return X(t,n)},a.tickFormat=function(n,e){return I(t,n,e)},a.nice=function(n){return t=N(t,k(t,n)[2]),i()},a.copy=function(){return D(t,n,e,r)},i()}function H(){return D([0,1],[0,1],x,!1)}function J(t,n){return t.range=function(){var e=n.range.apply(n,arguments);return e===n?t:e},t.rangeRound=function(){var e=n.rangeRound.apply(n,arguments);return e===n?t:e},t.clamp=function(){var e=n.clamp.apply(n,arguments);return e===n?t:e},t.interpolate=function(){var e=n.interpolate.apply(n,arguments);return e===n?t:e},t}function K(t,n,e){function r(t){return 0>t?-Math.pow(-t,n):Math.pow(t,n)}function i(t){return 0>t?-Math.pow(-t,1/n):Math.pow(t,1/n)}function a(n){return t(r(n))}return a.invert=function(n){return i(t.invert(n))},a.exponent=function(t){return arguments.length?(n=+t,a.domain(e)):n},a.domain=function(n){return arguments.length?(e=n.map(Number),t.domain(e.map(r)),a):e.slice()},a.ticks=function(t){return X(e,t)},a.tickFormat=function(t,n){return I(e,t,n)},a.nice=function(t){return a.domain(N(e,k(e,t)[2]))},a.copy=function(){return K(t.copy(),n,e)},J(a,t)}function Q(){return K(H(),.5,[0,1])}function V(t,n,e){function r(n){return e[Math.max(0,Math.min(u,Math.floor(a*(n-t))))]}function i(){return a=e.length/(n-t),u=e.length-1,r}var a,u;return r.domain=function(e){return arguments.length?(t=+e[0],n=+e[e.length-1],i()):[t,n]},r.range=function(t){return arguments.length?(e=t.slice(),i()):e.slice()},r.invertExtent=function(n){return n=e.indexOf(n),n=0>n?0/0:n/a+t,[n,n+1/a]},r.copy=function(){return V(t,n,e)},i()}function W(){return V(0,1,[0,1])}function tt(t,n){var e=(t.length-1)*n+1,r=Math.floor(e),i=+t[r-1],a=e-r;return a?i+a*(t[r]-i):i}function nt(t,e){function r(){var n=0,r=e.length;for(a=[];++n<r;)a[n-1]=tt(t,n/r);return i}function i(t){return isNaN(t=+t)?void 0:e[bt(a,t)]}var a;return i.domain=function(e){if(!arguments.length)return t;t=[];for(var i,a=0,u=e.length;u>a;++a)i=e[a],null==i||isNaN(i=+i)||t.push(i);return t.sort(n),r()},i.range=function(t){return arguments.length?(e=t.slice(),r()):e.slice()},i.quantiles=function(){return a},i.invertExtent=function(n){return n=e.indexOf(n),0>n?[0/0,0/0]:[n>0?a[n-1]:t[0],n<a.length?a[n]:t[t.length-1]]},i.copy=function(){return nt(t,e)},r()}function et(){return nt([],[])}function rt(){return K(H(),1,[0,1])}function it(t,n,e){for(var r=new Array(t),i=-1;++i<t;)r[i]=n+e*i;return r}function at(t,n){function e(e){var a=e+"",u=r.get(a);if(!u){if("range"!==n.t)return;r.set(a,u=t.push(e))}return i[(u-1)%i.length]}var r,i,a;return e.domain=function(i){if(!arguments.length)return t.slice();t=[],r=new Map;for(var a,u,o=-1,s=i.length;++o<s;)r.has(u=(a=i[o])+"")||r.set(u,t.push(a));return e[n.t].apply(e,n.a)},e.range=function(t){return arguments.length?(i=t.slice(),a=0,n={t:"range",a:arguments},e):i.slice()},e.rangePoints=function(r,u){u=arguments.length<2?0:+u;var o=+r[0],s=+r[1],c=t.length<2?(o=(o+s)/2,0):(s-o)/(t.length-1+u);return i=it(t.length,o+c*u/2,c),a=0,n={t:"rangePoints",a:arguments},e},e.rangeRoundPoints=function(r,u){u=arguments.length<2?0:+u;var o=+r[0],s=+r[1],c=t.length<2?(o=s=Math.round((o+s)/2),0):(s-o)/(t.length-1+u)|0;return i=it(t.length,o+Math.round(c*u/2+(s-o-(t.length-1+u)*c)/2),c),a=0,n={t:"rangeRoundPoints",a:arguments},e},e.rangeBands=function(r,u,o){u=arguments.length<2?0:+u,o=arguments.length<3?u:+o;var s=+r[1]<+r[0],c=+r[s-0],l=+r[1-s],h=(l-c)/(t.length-u+2*o);return i=it(t.length,c+h*o,h),s&&i.reverse(),a=h*(1-u),n={t:"rangeBands",a:arguments},e},e.rangeRoundBands=function(r,u,o){u=arguments.length<2?0:+u,o=arguments.length<3?u:+o;var s=+r[1]<+r[0],c=+r[s-0],l=+r[1-s],h=Math.floor((l-c)/(t.length-u+2*o));return i=it(t.length,c+Math.round((l-c-(t.length-u)*h)/2),h),s&&i.reverse(),a=Math.round(h*(1-u)),n={t:"rangeRoundBands",a:arguments},e},e.rangeBand=function(){return a},e.rangeExtent=function(){var t=n.a[0],e=t[0],r=t[t.length-1];return e>r&&(t=r,r=e,e=t),[e,r]},e.copy=function(){return at(t,n)},e.domain(t)}function ut(){return at([],{t:"range",a:[[]]})}function ot(t,n,e){function r(t){return(e[0]<0?-Math.log(t>0?0:-t):Math.log(0>t?0:t))/Math.log(n)}function i(t){return e[0]<0?-Math.pow(n,-t):Math.pow(n,t)}function a(n){return t(r(n))}return a.invert=function(n){return i(t.invert(n))},a.base=function(t){return arguments.length?(n=+t,a.domain(e)):n},a.domain=function(n){return arguments.length?(e=n.map(Number),t.domain(e.map(r)),a):e.slice()},a.nice=function(){var n=N(t.domain(),1);return t.domain(n),e=n.map(i),a},a.ticks=function(){var t=e[0],a=e[e.length-1];t>a&&(s=t,t=a,a=s);var u,o,s=Math.floor(r(t)),c=Math.ceil(r(a)),l=n%1?2:n,h=[];if(isFinite(c-s))if(t>0){for(--c,u=1;l>u;++u){if((o=i(s)*u)<t)continue;h.push(o)}for(;++s<c;)for(u=1;l>u;++u)h.push(i(s)*u);for(u=1;l>u&&!((o=i(s)*u)>a);++u)h.push(o)}else{for(++s,u=l-1;u>=1;--u){if((o=i(s)*u)<t)continue;h.push(o)}for(;++s<c;)for(u=l-1;u>=1;--u)h.push(i(s)*u);for(u=l-1;u>=1&&!((o=i(s)*u)>a);--u)h.push(o)}return h},a.tickFormat=function(t,u){if(null==u?u=10===n?Gt:Xt:"function"!=typeof u&&(u=Ct(u)),null==t)return u;var o,s=Math.min(n,a.ticks().length/t),c=e[0]>0?(o=1e-12,Math.ceil):(o=-1e-12,Math.floor);return function(t){return i(c(r(t)+o))/t>=s?u(t):""}},a.copy=function(){return ot(t.copy(),n,e)},J(a,t)}function st(){return ot(H(),10,[1,10])}function ct(t){function n(t){return+t}return n.invert=n,n.domain=n.range=function(e){return arguments.length?(t=e.map(Number),n):t.slice()},n.ticks=function(n){return X(t,n)},n.tickFormat=function(n,e){return I(t,n,e)},n.copy=function(){return ct(t)},n}function lt(){return ct([0,1])}function ht(){return ut().range(["#3182bd","#6baed6","#9ecae1","#c6dbef","#e6550d","#fd8d3c","#fdae6b","#fdd0a2","#31a354","#74c476","#a1d99b","#c7e9c0","#756bb1","#9e9ac8","#bcbddc","#dadaeb","#636363","#969696","#bdbdbd","#d9d9d9"])}function ft(){return ut().range(["#393b79","#5254a3","#6b6ecf","#9c9ede","#637939","#8ca252","#b5cf6b","#cedb9c","#8c6d31","#bd9e39","#e7ba52","#e7cb94","#843c39","#ad494a","#d6616b","#e7969c","#7b4173","#a55194","#ce6dbd","#de9ed6"])}function gt(){return ut().range(["#1f77b4","#aec7e8","#ff7f0e","#ffbb78","#2ca02c","#98df8a","#d62728","#ff9896","#9467bd","#c5b0d5","#8c564b","#c49c94","#e377c2","#f7b6d2","#7f7f7f","#c7c7c7","#bcbd22","#dbdb8d","#17becf","#9edae5"])}function dt(){return ut().range(["#1f77b4","#ff7f0e","#2ca02c","#d62728","#9467bd","#8c564b","#e377c2","#7f7f7f","#bcbd22","#17becf"])}var mt=r(n),pt=mt.right,bt=pt;h.prototype={toString:function(){return this.rgb()+""}};var Mt=l.prototype=new h,vt=.7;Mt.darker=function(t){return t=null==t?vt:Math.pow(vt,t),new l(this.r*t,this.g*t,this.b*t)};var yt=1/vt;Mt.brighter=function(t){return t=null==t?yt:Math.pow(yt,t),new l(this.r*t,this.g*t,this.b*t)},Mt.rgb=function(){return this},Mt.toString=function(){return c(this.r,this.g,this.b)};var wt=(new Map).set("aliceblue",15792383).set("antiquewhite",16444375).set("aqua",65535).set("aquamarine",8388564).set("azure",15794175).set("beige",16119260).set("bisque",16770244).set("black",0).set("blanchedalmond",16772045).set("blue",255).set("blueviolet",9055202).set("brown",10824234).set("burlywood",14596231).set("cadetblue",6266528).set("chartreuse",8388352).set("chocolate",13789470).set("coral",16744272).set("cornflowerblue",6591981).set("cornsilk",16775388).set("crimson",14423100).set("cyan",65535).set("darkblue",139).set("darkcyan",35723).set("darkgoldenrod",12092939).set("darkgray",11119017).set("darkgreen",25600).set("darkgrey",11119017).set("darkkhaki",12433259).set("darkmagenta",9109643).set("darkolivegreen",5597999).set("darkorange",16747520).set("darkorchid",10040012).set("darkred",9109504).set("darksalmon",15308410).set("darkseagreen",9419919).set("darkslateblue",4734347).set("darkslategray",3100495).set("darkslategrey",3100495).set("darkturquoise",52945).set("darkviolet",9699539).set("deeppink",16716947).set("deepskyblue",49151).set("dimgray",6908265).set("dimgrey",6908265).set("dodgerblue",2003199).set("firebrick",11674146).set("floralwhite",16775920).set("forestgreen",2263842).set("fuchsia",16711935).set("gainsboro",14474460).set("ghostwhite",16316671).set("gold",16766720).set("goldenrod",14329120).set("gray",8421504).set("green",32768).set("greenyellow",11403055).set("grey",8421504).set("honeydew",15794160).set("hotpink",16738740).set("indianred",13458524).set("indigo",4915330).set("ivory",16777200).set("khaki",15787660).set("lavender",15132410).set("lavenderblush",16773365).set("lawngreen",8190976).set("lemonchiffon",16775885).set("lightblue",11393254).set("lightcoral",15761536).set("lightcyan",14745599).set("lightgoldenrodyellow",16448210).set("lightgray",13882323).set("lightgreen",9498256).set("lightgrey",13882323).set("lightpink",16758465).set("lightsalmon",16752762).set("lightseagreen",2142890).set("lightskyblue",8900346).set("lightslategray",7833753).set("lightslategrey",7833753).set("lightsteelblue",11584734).set("lightyellow",16777184).set("lime",65280).set("limegreen",3329330).set("linen",16445670).set("magenta",16711935).set("maroon",8388608).set("mediumaquamarine",6737322).set("mediumblue",205).set("mediumorchid",12211667).set("mediumpurple",9662683).set("mediumseagreen",3978097).set("mediumslateblue",8087790).set("mediumspringgreen",64154).set("mediumturquoise",4772300).set("mediumvioletred",13047173).set("midnightblue",1644912).set("mintcream",16121850).set("mistyrose",16770273).set("moccasin",16770229).set("navajowhite",16768685).set("navy",128).set("oldlace",16643558).set("olive",8421376).set("olivedrab",7048739).set("orange",16753920).set("orangered",16729344).set("orchid",14315734).set("palegoldenrod",15657130).set("palegreen",10025880).set("paleturquoise",11529966).set("palevioletred",14381203).set("papayawhip",16773077).set("peachpuff",16767673).set("peru",13468991).set("pink",16761035).set("plum",14524637).set("powderblue",11591910).set("purple",8388736).set("rebeccapurple",6697881).set("red",16711680).set("rosybrown",12357519).set("royalblue",4286945).set("saddlebrown",9127187).set("salmon",16416882).set("sandybrown",16032864).set("seagreen",3050327).set("seashell",16774638).set("sienna",10506797).set("silver",12632256).set("skyblue",8900331).set("slateblue",6970061).set("slategray",7372944).set("slategrey",7372944).set("snow",16775930).set("springgreen",65407).set("steelblue",4620980).set("tan",13808780).set("teal",32896).set("thistle",14204888).set("tomato",16737095).set("turquoise",4251856).set("violet",15631086).set("wheat",16113331).set("white",16777215).set("whitesmoke",16119285).set("yellow",16776960).set("yellowgreen",10145074),xt=g.prototype=new h;xt.brighter=function(t){return t=null==t?yt:Math.pow(yt,t),new g(this.h,this.s,this.l*t)},xt.darker=function(t){return t=null==t?vt:Math.pow(vt,t),new g(this.h,this.s,this.l*t)},xt.rgb=function(){var t=this.h%360+360*(this.h<0),n=isNaN(t)||isNaN(this.s)?0:this.s,e=this.l,r=.5>=e?e*(1+n):e+n-e*n,i=2*e-r;return new l(d(t>=240?t-240:t+120,i,r),d(t,i,r),d(120>t?t+240:t-120,i,r))};var kt,Nt=/^hsl\(\s*([-+]?\d+(?:\.\d+)?)\s*,\s*([-+]?\d+(?:\.\d+)?)%\s*,\s*([-+]?\d+(?:\.\d+)?)%\s*\)$/,qt=/^rgb\(\s*([-+]?\d+(?:\.\d+)?)%\s*,\s*([-+]?\d+(?:\.\d+)?)%\s*,\s*([-+]?\d+(?:\.\d+)?)%\s*\)$/,St=/^rgb\(\s*([-+]?\d+)\s*,\s*([-+]?\d+)\s*,\s*([-+]?\d+)\s*\)$/,jt=/^#([0-9a-f]{6})$/,At=/^#([0-9a-f]{3})$/,Et=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,$t=new RegExp(Et.source,"g"),Pt=[function(t,n){var e,r=typeof n;return("string"===r?(e=p(n))?(n=e,M):w:n instanceof p?M:Array.isArray(n)?s:"object"===r&&isNaN(n)?o:u)(t,n)}],_t=Math.sqrt(2),Rt=Math.sqrt(10),zt=Math.sqrt(50),Ft=["y","z","a","f","p","n","µ","m","","k","M","G","T","P","E","Z","Y"],Ot={"":E,"%":function(t,n){return(100*t).toFixed(n)},b:function(t){return Math.round(t).toString(2)},c:function(t){return t+""},d:function(t){return Math.round(t).toString(10)},e:function(t,n){return t.toExponential(n)},f:function(t,n){return t.toFixed(n)},g:function(t,n){return t.toPrecision(n)},o:function(t){return Math.round(t).toString(8)},p:function(t,n){return A(100*t,n)},r:A,s:j,X:function(t){return Math.round(t).toString(16).toUpperCase()},x:function(t){return Math.round(t).toString(16)}},Bt=/^(?:(.)?([<>=^]))?([+\-\( ])?([$#])?(0)?(\d+)?(,)?(\.\d+)?([a-z%])?$/i;$.prototype.toString=function(){return this.fill+this.align+this.sign+this.symbol+(this.zero?"0":"")+(null==this.width?"":Math.max(1,0|this.width))+(this.comma?",":"")+(null==this.precision?"":"."+Math.max(0,0|this.precision))+this.type};var It=z({decimal:".",thousands:",",grouping:[3],currency:["$",""]}),Ct=It.format,Lt=It.formatPrefix,Xt=Ct(","),Gt=Ct(".0e");t.category10=dt,t.category20=gt,t.category20b=ft,t.category20c=ht,t.identity=lt,t.linear=H,t.log=st,t.ordinal=ut,t.pow=rt,t.quantile=et,t.quantize=W,t.sqrt=Q,t.threshold=a});
{
"name": "d3-scale",
"version": "0.0.1",
"version": "0.0.2",
"description": "",

@@ -5,0 +5,0 @@ "keywords": [

# d3-scale
Scales are a convenient abstraction for a fundamental task in visualization: mapping a dimension of abstract data to a visual representation. Although most often used for position-encoding quantitative data, such as mapping the height in meters of a sample population to the height in pixels of bars in a bar chart, scales can represent virtually any visual encoding, such as diverging colors, stroke widths, or symbol size. Scales can also be used with virtually any type of data, such as named categorical data or discrete data that needs sensible breaks.
For continuous quantitative data, you often want a [linear scale](#linear-scales). If the distribution calls for it, you may transform data using a [power scale](#power-scales) or [log scale](#log-scales). To aid differentiation, consider a [quantize scale](#quantize-scales), which rounds continuous data to a fixed set of discrete values; similarly, a [quantile scale](#quantile-scales) computes quantiles from a sample population, and a [threshold scale](#threshold-scales) allows you to specify arbitrary thresholds to specify discrete breaks in continuous data.
For ordinal or categorical data, use an [ordinal scale](#ordinal-scales). Ordinal scales can specify an explicit mapping from a discrete set of data values to a discrete set of visual attributes (such as colors), but they are also useful for position-encoding ordinal data, such as bars in a bar chart or dots in an categorical scatterplot. Several built-in [categorical color scales](#category-scales) are also provided; if you don’t like these palettes, try [ColorBrewer](http://colorbrewer2.org/).
Scales have no intrinsic visual representation; for that, consider an [axis](https://github.com/mbostock/d3/wiki/SVG-Axes). However, scales typically provide a ticks method (such as [*linear*.ticks](#linear_ticks)) that can be used to render reference marks.
Want a longer introduction? See these recommended tutorials:

@@ -29,3 +35,3 @@

Linear scales are the most common and a good default choice to map a continuous input [domain](#linear_domain) to a continuous output [range](#linear_range). With a linear scale, each range value *y* can be expressed as a linear function of the domain value *x*: *y* = *mx* + *b*. The domain is typically a dimension of data you want to visualize, such as the height of students in meters. The range is typically a dimension of the desired output visualization, such as the height of bars in pixels in a histogram.
Linear scales are the most common and a good default choice to map a continuous input [domain](#linear_domain) to a continuous output [range](#linear_range). With a linear scale, each range value *y* can be expressed as a linear function of the domain value *x*: *y* = *mx* + *b*. The domain is typically a dimension of data you want to visualize, such as the height in meters of people in a sample population. The range is typically a dimension of the desired output visualization, such as the height in pixels of bars in a bar chart.

@@ -54,5 +60,6 @@ <a name="linear" href="#linear">#</a> <b>linear</b>()

<a name="linear_invert" href="#linear_invert">#</a> <i>linear</i>.<b>invert</b>(<i>y</i>)
Given a value *y* in the [range](#linear_range), returns the corresponding value *x* in the [domain](#linear_domain); the inverse of [*linear*](#_linear). For example:
Given a value *y* in the [range](#linear_range), returns the corresponding value *x* in the [domain](#linear_domain): the inverse of [*linear*](#_linear). For example, a position encoding:

@@ -65,9 +72,10 @@ ```js

This method is only supported if the range is numeric, and will return undefined if the range is non-numeric (such as colors, strings or objects). For a valid value *y* in the range, <i>linear</i>(<i>linear</i>.invert(<i>y</i>)) equals *y*; similarly, for a valid value *x* in the domain, <i>linear</i>.invert(<i>linear</i>(<i>x</i>)) equals *x*. The invert method is useful for interaction, say to determine the value in the domain that corresponds to the pixel location under the mouse.
This method is only supported if the range is numeric, and may return undefined if the range is non-numeric (such as colors). For a valid value *y* in the range, <i>linear</i>(<i>linear</i>.invert(<i>y</i>)) equals *y*; similarly, for a valid value *x* in the domain, <i>linear</i>.invert(<i>linear</i>(<i>x</i>)) equals *x*. The invert method is useful for interaction, say to determine the value in the domain that corresponds to the pixel location under the mouse.
<a name="linear_domain" href="#linear_domain">#</a> <i>linear</i>.<b>domain</b>([<i>domain</i>])
If *domain* is specified, sets the scale’s domain to the specified array of numbers. The array must contain two or more numbers; if the elements in the given array are not numbers, they will be coerced to numbers. (A linear scale may be used to encode [dates](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date); however, a [time scale](https://github.com/d3/d3-scale-time) is recommended for calendar-based ticks.) If *domain* is not specified, returns the scale’s current domain.
If *domain* is specified, sets the scale’s domain to the specified array of numbers. The array must contain two or more numbers. If the elements in the given array are not numbers, they will be coerced to numbers. (A linear scale may thus be used to encode [dates](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date); however, a [time scale](https://github.com/mbostock/d3/wiki/Time-Scales) is recommended for calendar-based ticks.) If *domain* is not specified, returns the scale’s current domain.
Although linear scales typically have only two values in their domain, you may specify more than two values to produce a “polylinear” scale. (There should be an equivalent number of values in the [range](#linear_range).) A polylinear scale represents multiple piecewise linear scales that divide a continuous domain and range. For example, to create a diverging color scale that interpolates between white and red for negative values, and white and green for positive values, say:
Although linear scales typically have two values each in their domain and range, specifying more than two values produces a “polylinear” scale. A polylinear scale represents multiple piecewise linear scales that divide a continuous domain and range. For example, to create a diverging color scale that interpolates between white and red for negative values, and white and green for positive values, say:

@@ -80,16 +88,41 @@ ```js

Internally, polylinear scales perform a [binary search](https://github.com/d3/d3-arrays#bisect) for the range interpolator corresponding to the given domain value. Thus, the domain must be in ascending or descending order.
Internally, a polylinear scale performs a [binary search](https://github.com/d3/d3-arrays#bisect) for the range interpolator corresponding to the given domain value. Thus, the domain must be in ascending or descending order. If the domain and range have different lengths *N* and *M*, only the first *min(N,M)* elements in each are observed.
<a name="linear_range" href="#linear_range">#</a> <i>linear</i>.<b>range</b>([<i>range</i>])
If a *range* is specified, sets the scale’s range to the specified array of values. The array must contain two or more values, matching the cardinality of the [domain](#linear_domain); otherwise, the longer of the two is truncated to match the other. The elements in the given array need not be numbers; any value that is supported by the underlying [interpolator](#linear_interpolate) will work; however, numeric ranges are required for [invert](#linear_invert). If *values* is not specified, returns the scale’s current range.
If *range* is specified, sets the scale’s range to the specified array of values. The array must contain two or more values. Unlike the [domain](#linear_domain), elements in the given array need not be numbers; any value that is supported by the underlying [interpolator](#linear_interpolate) will work; however, numeric ranges are required for [invert](#linear_invert). If *range* is not specified, returns the scale’s current range.
<a name="linear_rangeRound" href="#linear_rangeRound">#</a> <i>linear</i>.<b>rangeRound</b>(<i>range</i>)
Sets the scale’s *range* to the specified array of values while also setting the scale’s [interpolator](#linear_interpolate) to [interpolateRound](https://github.com/d3/d3-interpolate#interpolateRound). This is a convenience routine for when the values output by the scale should be exact integers, such as to avoid antialiasing artifacts. Note that this interpolator can only be used with numeric [ranges](#linear_range).
Sets the scale’s [*range*](#linear_range) to the specified array of values while also setting the scale’s [interpolator](#linear_interpolate) to [interpolateRound](https://github.com/d3/d3-interpolate#interpolateRound). This is a convenience method equivalent to:
```js
s.range(range).interpolate(interpolateRound);
```
The rounding interpolator is sometimes useful for avoiding antialiasing artifacts, though also consider [shape-rendering](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/shape-rendering): crispEdges. Note that this interpolator can only be used with numeric ranges.
<a name="linear_interpolate" href="#linear_interpolate">#</a> <i>linear</i>.<b>interpolate</b>([<i>interpolate</i>])
If *interpolate* is specified, sets the scale’s range interpolator factory. This interpolator factory is used to construct interpolators for each adjacent pair of values from the [range](#linear_range); these interpolators then map a normalized domain parameter *t* in [0,1] to the corresponding value in the range. If *factory* is not specified, returns the scale’s interpolator factory.
If *interpolate* is specified, sets the scale’s [range](#linear_range) interpolator factory. This interpolator factory is used to create interpolators for each adjacent pair of values from the range; these interpolators then map a normalized domain parameter *t* in [0,1] to the corresponding value in the range. If *factory* is not specified, returns the scale’s interpolator factory.
For example, if you create a diverging color scale with three colors in the range, two interpolators are created internally by the scale, equivalent to:
```js
var s = scale.linear().domain([-100, 0, +100]).range(["red", "white", "green"]),
i0 = interpolate("red", "white"),
i1 = interpolate("white", "green");
```
Perhaps the most common reason to specify a custom interpolator is to change the color space of interpolation. For example, to use the [HCL color space](https://github.com/d3/d3-color#interpolateHcl):
```js
var s = scale.linear()
.domain([10, 100])
.range(["brown", "steelblue"])
.interpolate(interpolateHcl);
```
See [d3-color](https://github.com/d3/d3-color) for more color interpolators.
Note: the [default interpolator](https://github.com/d3/d3-interpolate#interpolate) **may reuse return values**. For example, if the domain values are arbitrary objects, then the default interpolator always returns the same object, modifying it in-place. If the scale is used to set an attribute or style, you typically don’t have to worry about this recyling of the scale’s return value; however, if you need to store the scale’s return value, specify your own interpolator or make a copy as appropriate.

@@ -99,4 +132,15 @@

If *clamp* is specified, enables or disables clamping accordingly. If clamping is disabled and the scale is passed a value outside the domain, the scale may return a value outside the range through linear extrapolation. For example, with the default domain and range of [0,1], an input value of 2 will return an output value of 2. If clamping is enabled, the normalized domain parameter *t* is clamped to the range [0,1], such that the return value of the scale is always within the scale’s range. If *clamp* is not specified, returns whether or not the scale currently clamps values to within the range.
If *clamp* is specified, enables or disables clamping accordingly. If clamping is disabled and the scale is passed a value outside the [domain](#linear_domain), the scale may return a value outside the [range](#linear_range) through linear extrapolation. If clamping is enabled, the return value of the scale is always within the scale’s range. Clamping similarly applies to [*linear*.invert](#linear_invert). For example:
```js
var s = linear().domain([10, 100]).range([0, 960]);
s(-10); // -213.33333333333331
s.invert(-213.33333333333331); // -10
s.clamp(true);
s(-10); // 0
s.invert(-213.33333333333331); // 10
```
If *clamp* is not specified, returns whether or not the scale currently clamps values to within the range.
<a name="linear_nice" href="#linear_nice">#</a> <i>linear</i>.<b>nice</b>([<i>count</i>])

@@ -106,3 +150,3 @@

Nicing is useful if the domain is computed from data and may be irregular. For example, for a domain of [0.20147987687960267, 0.996679553296417], the nice domain is [0.2, 1]. If the domain has more than two values, nicing the domain only affects the first and last value.
Nicing is useful if the domain is computed from data, say using [extent](https://github.com/d3/d3-arrays#extent), and may be irregular. For example, for a domain of [0.20147987687960267, 0.996679553296417], a nice domain might be [0.2, 1.0]. If the domain has more than two values, nicing the domain only affects the first and last value.

@@ -135,3 +179,3 @@ <a name="linear_ticks" href="#linear_ticks">#</a> <i>linear</i>.<b>ticks</b>([<i>count</i>])

Identity scales are a special case of linear scales where the [domain](#identity_domain) and [range](#identity_range) are identical; the scale and its invert method are both the identity function. These scales are occasionally useful when working with pixel coordinates, say in conjunction with an axis or brush.
Identity scales are a special case of [linear scales](#linear-scales) where the [domain](#identity_domain) and [range](#identity_range) are identical; the scale and its invert method are both the identity function. These scales are occasionally useful when working with pixel coordinates, say in conjunction with an axis or brush.

@@ -150,3 +194,3 @@ <a name="identity" href="#identity">#</a> <b>identity</b>()

If *domain* is specified, sets the scale’s domain and range to the specified array of numbers. The array must contain two or more numbers; if the elements in the given array are not numbers, they will be coerced to numbers. If *domain* is not specified, returns the scale’s current domain (or equivalently, range).
If *domain* is specified, sets the scale’s domain and range to the specified array of numbers. The array must contain two or more numbers. If the elements in the given array are not numbers, they will be coerced to numbers. If *domain* is not specified, returns the scale’s current domain (or equivalently, range).

@@ -169,7 +213,7 @@ <a name="identity_ticks" href="#identity_ticks">#</a> <i>identity</i>.<b>ticks</b>([<i>count</i>])

Power scales are similar to linear scales, except an exponential transform is applied to the input [domain](#pow_domain) value before the output [range](#pow_range) value is computed. Each range value *y* can be expressed as a function of the domain value *x*: *y* = *mx^k* + *b*, where *k* is the [exponent](#pow_exponent) value. Power scales also support negative domain values, in which case the input value and the resulting output value are multiplied by -1.
Power scales are similar to [linear scales](#linear-scales), except an exponential transform is applied to the input [domain](#pow_domain) value before the output [range](#pow_range) value is computed. Each range value *y* can be expressed as a function of the domain value *x*: *y* = *mx^k* + *b*, where *k* is the [exponent](#pow_exponent) value. Power scales also support negative domain values, in which case the input value and the resulting output value are multiplied by -1.
<a name="pow" href="#pow">#</a> <b>pow</b>()
Constructs a new power scale with the default [domain](#pow_domain) [0,1], the default [range](#pow_range) [0,1], and the default [exponent](#pow_exponent) 1. (Note that this is effectively a [linear](#linear) scale until you set a different exponent.)
Constructs a new power scale with the default [domain](#pow_domain) [0,1], the default [range](#pow_range) [0,1], the default [exponent](#pow_exponent) 1, the default [interpolator](#pow_interpolate) and [clamping](#pow_clamp) disabled. (Note that this is effectively a [linear](#linear) scale until you set a different exponent.)

@@ -196,3 +240,3 @@ <a name="_pow" href="#_pow">#</a> <i>pow</i>(<i>x</i>)

Given a value *y* in the [range](#pow_range), returns the corresponding value *x* in the [domain](#pow_domain); the inverse of [*pow*](#_pow). For example:
Given a value *y* in the [range](#pow_range), returns the corresponding value *x* in the [domain](#pow_domain): the inverse of [*pow*](#_pow). For example, a position encoding:

@@ -205,7 +249,7 @@ ```js

This method is only supported if the range is numeric, and will return undefined if the range is non-numeric (such as colors, strings or objects). For a valid value *y* in the range, <i>pow</i>(<i>pow</i>.invert(<i>y</i>)) equals *y*; similarly, for a valid value *x* in the domain, <i>pow</i>.invert(<i>pow</i>(<i>x</i>)) equals *x*. The invert method is useful for interaction, say to determine the value in the domain that corresponds to the pixel location under the mouse.
This method is only supported if the range is numeric, and may return undefined if the range is non-numeric (such as colors). For a valid value *y* in the range, <i>pow</i>(<i>pow</i>.invert(<i>y</i>)) equals *y*; similarly, for a valid value *x* in the domain, <i>pow</i>.invert(<i>pow</i>(<i>x</i>)) equals *x*. The invert method is useful for interaction, say to determine the value in the domain that corresponds to the pixel location under the mouse.
<a name="pow_exponent" href="#pow_exponent">#</a> <i>pow</i>.<b>exponent</b>([<i>k</i>])
If *k* is specified, sets the current exponent to the given numeric value. If *k* is not specified, returns the current exponent. The default value is 1.
If *k* is specified, sets the current exponent to the given numeric value. If *k* is not specified, returns the current exponent. The default value is 1. (Note that this is effectively a [linear](#linear) scale until you set a different exponent.)

@@ -218,13 +262,19 @@ <a name="pow_domain" href="#pow_domain">#</a> <i>pow</i>.<b>domain</b>([<i>domain</i>])

<a name="pow_range" href="#pow_range">#</a> <i>pow</i>.<b>range</b>([<i>values</i>])
<a name="pow_range" href="#pow_range">#</a> <i>pow</i>.<b>range</b>([<i>range</i>])
If *values* is specified, sets the scale’s range to the specified array of values. The array must contain two or more values, matching the cardinality of the domain; otherwise, the longer of the two is truncated to match the other. The elements in the given array need not be numbers; any value that is supported by the underlying [interpolator](#pow_interpolate) will work; however, numeric ranges are required for [invert](#pow_invert). If *values* is not specified, returns the scale’s current range.
If *range* is specified, sets the scale’s range to the specified array of values. The array must contain two or more values, matching the cardinality of the [domain](#pow_domain); otherwise, the longer of the two is truncated to match the other. The elements in the given array need not be numbers; any value that is supported by the underlying [interpolator](#pow_interpolate) will work; however, numeric ranges are required for [invert](#pow_invert). If *range* is not specified, returns the scale’s current range.
<a name="pow_rangeRound" href="#pow_rangeRound">#</a> <i>pow</i>.<b>rangeRound</b>(<i>range</i>)
Sets the scale’s *range* to the specified array of values while also setting the scale’s [interpolator](#pow_interpolate) to [interpolateRound](https://github.com/d3/d3-interpolate#interpolateRound). This is a convenience routine for when the values output by the scale should be exact integers, such as to avoid antialiasing artifacts. Note that this interpolator can only be used with numeric [ranges](#pow_range).
Sets the scale’s [*range*](#pow_range) to the specified array of values while also setting the scale’s [interpolator](#pow_interpolate) to [interpolateRound](https://github.com/d3/d3-interpolate#interpolateRound). This is a convenience method equivalent to:
```js
s.range(range).interpolate(interpolateRound);
```
The rounding interpolator is sometimes useful for avoiding antialiasing artifacts, though also consider [shape-rendering](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/shape-rendering): crispEdges. Note that this interpolator can only be used with numeric ranges.
<a name="pow_interpolate" href="#pow_interpolate">#</a> <i>pow</i>.<b>interpolate</b>([<i>interpolate</i>])
If *interpolate* is specified, sets the scale’s range interpolator factory. This interpolator factory is used to construct interpolators for each adjacent pair of values from the [range](#pow_range); these interpolators then map a normalized domain parameter *t* in [0,1] to the corresponding value in the range. If *factory* is not specified, returns the scale’s interpolator factory.
If *interpolate* is specified, sets the scale’s [range](#pow_range) interpolator factory. This interpolator factory is used to create interpolators for each adjacent pair of values from the range; these interpolators then map a normalized domain parameter *t* in [0,1] to the corresponding value in the range. If *factory* is not specified, returns the scale’s interpolator factory. See [*linear*.interpolate](#linear_interpolate) for examples.

@@ -235,3 +285,3 @@ Note: the [default interpolator](https://github.com/d3/d3-interpolate#interpolate) **may reuse return values**. For example, if the domain values are arbitrary objects, then the default interpolator always returns the same object, modifying it in-place. If the scale is used to set an attribute or style, you typically don’t have to worry about this recyling of the scale’s return value; however, if you need to store the scale’s return value, specify your own interpolator or make a copy as appropriate.

If *clamp* is specified, enables or disables clamping accordingly. By default, clamping is disabled, such that if a value outside the domain is passed to the scale, the scale may return a value outside the range through linear extrapolation. For example, with the default domain and range of [0,1] and an exponent of 0.5, an input value of 2 will return an output value of ~1.4142. If clamping is enabled, the normalized domain parameter *t* is clamped to the range [0,1], such that the return value of the scale is always within the scale’s range. If *clamp* is not specified, returns whether or not the scale currently clamps values to within the range.
If *clamp* is specified, enables or disables clamping accordingly. If clamping is disabled and the scale is passed a value outside the [domain](#pow_domain), the scale may return a value outside the [range](#pow_range) through extrapolation. If clamping is enabled, the return value of the scale is always within the scale’s range. Clamping similarly applies to [*pow*.invert](#pow_invert). See [*linear*.clamp](#linear_clamp) for examples. If *clamp* is not specified, returns whether or not the scale currently clamps values to within the range.

@@ -242,3 +292,3 @@ <a name="pow_nice" href="#pow_nice">#</a> <i>pow</i>.<b>nice</b>([<i>count</i>])

Nicing is useful if the domain is computed from data and may be irregular. For example, for a domain of [0.20147987687960267, 0.996679553296417], the nice domain is [0.2, 1]. If the domain has more than two values, nicing the domain only affects the first and last value.
Nicing is useful if the domain is computed from data, say using [extent](https://github.com/d3/d3-arrays#extent), and may be irregular. For example, for a domain of [0.20147987687960267, 0.996679553296417], the nice domain is [0.2, 1]. If the domain has more than two values, nicing the domain only affects the first and last value.

@@ -251,3 +301,3 @@ <a name="pow_ticks" href="#pow_ticks">#</a> <i>pow</i>.<b>ticks</b>([<i>count</i>])

Returns a [number format](https://github.com/d3/d3-format) function suitable for displaying a tick value. The specified *count* should have the same value as the count that is used to generate the tick values. You don’t have to use the scale’s built-in tick format, but it automatically computes the appropriate precision based on the fixed interval between tick values.
Returns a [number format](https://github.com/d3/d3-format) function suitable for displaying a tick value. The specified *count* should have the same value as the count that is used to generate the tick values. You don’t have to use the scale’s built-in tick format, but it automatically computes the appropriate precision based on the fixed interval between tick values. See [*linear*.tickFormat](#linear_tickFormat) for examples.

@@ -262,3 +312,3 @@ The optional *specifier* argument allows a [custom format](https://github.com/d3/d3-format#locale_format) to be specified. If the format specifier doesn’t have a defined precision, the precision will be set automatically by the scale, returning the appropriate format. This provides a convenient, declarative way of specifying a format whose precision will be automatically set by the scale.

Constructs a new power scale with the default [domain](#pow_domain) [0,1], the default [range](#pow_range) [0,1], and the [exponent](#pow_exponent) 0.5. This method is shorthand for:
Constructs a new power scale with the default [domain](#pow_domain) [0,1], the default [range](#pow_range) [0,1], and the [exponent](#pow_exponent) 0.5. This is a convenience method equivalent to:

@@ -273,5 +323,5 @@ ```js

Log scales are similar to linear scales, except a logarithmic transform is applied to the input domain value before the output range value is computed. The mapping to the range value *y* can be expressed as a function of the domain value *x*: *y* = *m* log(<i>x</i>) + *b*.
Log scales are similar to [linear scales](#linear-scales), except a logarithmic transform is applied to the input domain value before the output range value is computed. The mapping to the range value *y* can be expressed as a function of the domain value *x*: *y* = *m* log(<i>x</i>) + *b*.
As log(0) = -∞, a log scale must have either an exclusively-positive or exclusively-negative domain; the domain must not include or cross zero. A log scale with a positive domain has a well-defined behavior for positive values, and a log scale with a negative domain has a well-defined behavior for negative values. (For a negative domain, input and output values are implicitly multiplied by -1.) The behavior of the scale is undefined if you pass a negative value to a log scale with a positive domain or vice versa.
As log(0) = -∞, a log scale domain must be **strictly-positive or strictly-negative**; the domain must not include or cross zero. A log scale with a positive domain has a well-defined behavior for positive values, and a log scale with a negative domain has a well-defined behavior for negative values. (For a negative domain, input and output values are implicitly multiplied by -1.) The behavior of the scale is undefined if you pass a negative value to a log scale with a positive domain or vice versa.

@@ -310,3 +360,3 @@ <a name="log" href="#log">#</a> <b>log</b>()

This method is only supported if the range is numeric, and will return undefined if the range is non-numeric (such as colors, strings or objects). For a valid value *y* in the range, <i>log</i>(<i>log</i>.invert(<i>y</i>)) equals *y*; similarly, for a valid value *x* in the domain, <i>log</i>.invert(<i>log</i>(<i>x</i>)) equals *x*. The invert method is useful for interaction, say to determine the value in the domain that corresponds to the pixel location under the mouse.
This method is only supported if the range is numeric, and may return undefined if the range is non-numeric (such as colors). For a valid value *y* in the range, <i>log</i>(<i>log</i>.invert(<i>y</i>)) equals *y*; similarly, for a valid value *x* in the domain, <i>log</i>.invert(<i>log</i>(<i>x</i>)) equals *x*. The invert method is useful for interaction, say to determine the value in the domain that corresponds to the pixel location under the mouse.

@@ -325,11 +375,17 @@ <a name="log_base" href="#log_base">#</a> <i>log</i>.<b>base</b>([<i>base</i>])

If *range* is specified, sets the scale’s range to the specified array of values. The array must contain two or more values, matching the cardinality of the domain; otherwise, the longer of the two is truncated to match the other. The elements in the given array need not be numbers; any value that is supported by the underlying [interpolator](#log_interpolate) will work; however, numeric ranges are required for [invert](#log_invert). If *values* is not specified, returns the scale’s current range.
If *range* is specified, sets the scale’s range to the specified array of values. The array must contain two or more values, matching the cardinality of the [domain](#log_domain); otherwise, the longer of the two is truncated to match the other. The elements in the given array need not be numbers; any value that is supported by the underlying [interpolator](#log_interpolate) will work; however, numeric ranges are required for [invert](#log_invert). If *range* is not specified, returns the scale’s current range.
<a name="log_rangeRound" href="#log_rangeRound">#</a> <i>log</i>.<b>rangeRound</b>(<i>range</i>)
Sets the scale’s *range* to the specified array of values while also setting the scale’s [interpolator](#log_interpolate) to [interpolateRound](https://github.com/d3/d3-interpolate#interpolateRound). This is a convenience routine for when the values output by the scale should be exact integers, such as to avoid antialiasing artifacts. Note that this interpolator can only be used with numeric [ranges](#log_range).
Sets the scale’s [*range*](#log_range) to the specified array of values while also setting the scale’s [interpolator](#log_interpolate) to [interpolateRound](https://github.com/d3/d3-interpolate#interpolateRound). This is a convenience method equivalent to:
```js
s.range(range).interpolate(interpolateRound);
```
The rounding interpolator is sometimes useful for avoiding antialiasing artifacts, though also consider [shape-rendering](https://developer.mozilla.org/en-US/docs/Web/SVG/Attribute/shape-rendering): crispEdges. Note that this interpolator can only be used with numeric ranges.
<a name="log_interpolate" href="#log_interpolate">#</a> <i>log</i>.<b>interpolate</b>([<i>interpolate</i>])
If *interpolate* is specified, sets the scale’s range interpolator factory. This interpolator factory is used to construct interpolators for each adjacent pair of values from the [range](#log_range); these interpolators then map a normalized domain parameter *t* in [0,1] to the corresponding value in the range. If *factory* is not specified, returns the scale’s interpolator factory.
If *interpolate* is specified, sets the scale’s [range](#log_range) interpolator factory. This interpolator factory is used to create interpolators for each adjacent pair of values from the range; these interpolators then map a normalized domain parameter *t* in [0,1] to the corresponding value in the range. If *factory* is not specified, returns the scale’s interpolator factory. See [*linear*.interpolate](#linear_interpolate) for examples.

@@ -340,3 +396,3 @@ Note: the [default interpolator](https://github.com/d3/d3-interpolate#interpolate) **may reuse return values**. For example, if the domain values are arbitrary objects, then the default interpolator always returns the same object, modifying it in-place. If the scale is used to set an attribute or style, you typically don’t have to worry about this recyling of the scale’s return value; however, if you need to store the scale’s return value, specify your own interpolator or make a copy as appropriate.

If *clamp* is specified, enables or disables clamping accordingly. By default, clamping is disabled, such that if a value outside the domain is passed to the scale, the scale may return a value outside the range through linear extrapolation. For example, with the default domain of [1,10], default range of [0,1] and default base of 10, an value of 20 will return an output value of ~1.3010. If clamping is enabled, the normalized domain parameter *t* is clamped to the range [0,1], such that the return value of the scale is always within the scale’s range. If *clamp* is not specified, returns whether or not the scale currently clamps values to within the range.
If *clamp* is specified, enables or disables clamping accordingly. If clamping is disabled and the scale is passed a value outside the [domain](#log_domain), the scale may return a value outside the [range](#log_range) through extrapolation. If clamping is enabled, the return value of the scale is always within the scale’s range. Clamping similarly applies to [*log*.invert](#log_invert). See [*linear*.clamp](#linear_clamp) for examples. If *clamp* is not specified, returns whether or not the scale currently clamps values to within the range.

@@ -347,3 +403,3 @@ <a name="log_nice" href="#log_nice">#</a> <i>log</i>.<b>nice</b>()

Nicing is useful if the domain is computed from data and may be irregular. For example, for a domain of [0.20147987687960267, 0.996679553296417], the nice domain is [0.1, 1]. If the domain has more than two values, nicing the domain only affects the first and last value.
Nicing is useful if the domain is computed from data, say using [extent](https://github.com/d3/d3-arrays#extent), and may be irregular. For example, for a domain of [0.20147987687960267, 0.996679553296417], the nice domain is [0.1, 1]. If the domain has more than two values, nicing the domain only affects the first and last value.

@@ -372,11 +428,11 @@ <a name="log_ticks" href="#log_ticks">#</a> <i>log</i>.<b>ticks</b>()

Quantize scales are a variant of linear scales with a discrete rather than continuous range. The input domain is still continuous, and divided into uniform segments based on the number of values in (the cardinality of) the output range. The mapping is *linear* in that the range value *y* can be expressed as a linear function of the domain value *x*: *y* = *mx* + *b*. The domain is typically a dimension of the data that you want to visualize, such as the height of students in meters in a sample population. The range is typically a dimension of the desired output visualization, such as the height of bars in pixels in a histogram. See [bl.ocks.org/4060606](http://bl.ocks.org/mbostock/4060606) for an example.
Quantize scales are a variant of [linear scales](#linear-scales) with a discrete rather than continuous range. The input domain is still continuous, and divided into uniform segments based on the number of values in (the cardinality of) the output range. Each range value *y* can be expressed as a quantized linear function of the domain value *x*: *y* = *m round(x)* + *b*. See [bl.ocks.org/4060606](http://bl.ocks.org/mbostock/4060606) for an example.
<a name="quantize" href="#quantize">#</a> <b>quantize</b>()
Constructs a new quantize scale with the default domain [0,1] and the default range [0,1]. Thus, the default quantize scale is equivalent to the [round](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Math/round) function for numbers.
Constructs a new quantize scale with the default [domain](#quantize_domain) [0,1] and the default [range](#quantize_range) [0,1]. Thus, the default quantize scale is equivalent to the [Math.round](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Math/round) function.
<a name="_quantize" href="#_quantize">#</a> <i>quantize</i>(<i>x</i>)
Given a value *x* in the input domain, returns the corresponding value *y* in the output range. For example, a color encoding:
Given a value *x* in the input [domain](#quantize_domain), returns the corresponding value *y* in the output [range](#quantize_rangE). For example, a color encoding:

@@ -400,3 +456,3 @@ ```js

Returns the extent of values in the domain [<i>x0</i>, <i>x1</i>] for the corresponding value in the range *y*, representing the inverse mapping from range to domain. This method is useful for interaction, say to determine the value in the domain that corresponds to the pixel location under the mouse.
Returns the extent of values in the [domain](#quantize_domain) [<i>x0</i>, <i>x1</i>] for the corresponding value in the [range](#quantize_range) *y*: the inverse of [*quantize*](#_quantize). This method is useful for interaction, say to determine the value in the domain that corresponds to the pixel location under the mouse.

@@ -410,7 +466,7 @@ ```js

If *domain* is specified, sets the scale’s domain to the specified two-element array of numbers. If the array contains more than two numbers, only the first and last number are used. If the elements in the given array are not numbers, they will be coerced to numbers. If *numbers* is not specified, returns the scale’s current domain.
If *domain* is specified, sets the scale’s domain to the specified two-element array of numbers. If the array contains more than two numbers, only the first and last number are used; if the elements in the given array are not numbers, they will be coerced to numbers. If *domain* is not specified, returns the scale’s current domain.
<a name="quantize_range" href="#quantize_range">#</a> <i>quantize</i>.<b>range</b>([<i>range</i>])
If *range* is specified, sets the scale’s range to the specified array of values. The array may contain any number of discrete values. The elements in the given array need not be numbers; any value or type will work. If *values* is not specified, returns the scale’s current range.
If *range* is specified, sets the scale’s range to the specified array of values. The array may contain any number of discrete values. The elements in the given array need not be numbers; any value or type will work. If *range* is not specified, returns the scale’s current range.

@@ -427,23 +483,23 @@ <a name="quantize_copy" href="#quantize_copy">#</a> <i>quantize</i>.<b>copy</b>()

Constructs a new quantile scale with an empty domain and an empty range. The quantile scale is invalid until both a domain and range are specified.
Constructs a new quantile scale with an empty [domain](#quantile_domain) and an empty [range](#quantile_range). The quantile scale is invalid until both a domain and range are specified.
<a name="_quantile" href="#_quantile">#</a> <i>quantile</i>(<i>x</i>)
Given a value *x* in the input domain, returns the corresponding value *y* in the output range.
Given a value *x* in the input [domain](#quantile_domain), returns the corresponding value *y* in the output [range](#quantile_range).
<a name="quantile_invertExtent" href="#quantile_invertExtent">#</a> <i>quantile</i>.<b>invertExtent</b>(<i>y</i>)
Returns the extent of values in the domain [<i>x0</i>, <i>x1</i>] for the corresponding value in the range *y*, representing the inverse mapping from range to domain. This method is useful for interaction, say to determine the value in the domain that corresponds to the pixel location under the mouse.
Returns the extent of values in the [domain](#quantile_domain) [<i>x0</i>, <i>x1</i>] for the corresponding value in the [range](#quantile_range) *y*: the inverse of [*quantile*](#_quantile). This method is useful for interaction, say to determine the value in the domain that corresponds to the pixel location under the mouse.
<a name="quantile_domain" href="#quantile_domain">#</a> <i>quantile</i>.<b>domain</b>([<i>numbers</i>])
<a name="quantile_domain" href="#quantile_domain">#</a> <i>quantile</i>.<b>domain</b>([<i>domain</i>])
If *numbers* is specified, sets the domain of the quantile scale to the specified set of discrete numeric values. The array must not be empty, and must contain at least one numeric value; NaN, null and undefined values are ignored and not considered part of the sample population. If the elements in the given array are not numbers, they will be coerced to numbers. A copy of the input array is sorted and stored internally. If *numbers* is not specified, returns the scale’s current domain.
If *domain* is specified, sets the domain of the quantile scale to the specified set of discrete numeric values. The array must not be empty, and must contain at least one numeric value; NaN, null and undefined values are ignored and not considered part of the sample population. If the elements in the given array are not numbers, they will be coerced to numbers. A copy of the input array is sorted and stored internally. If *domain* is not specified, returns the scale’s current domain.
<a name="quantile_range" href="#quantile_range">#</a> <i>quantile</i>.<b>range</b>([<i>values</i>])
<a name="quantile_range" href="#quantile_range">#</a> <i>quantile</i>.<b>range</b>([<i>range</i>])
If *values* is specified, sets the discrete values in the range. The array must not be empty, and may contain any type of value. The number of values in (the cardinality, or length, of) the *values* array determines the number of quantiles that are computed. For example, to compute quartiles, *values* must be an array of four elements such as [0, 1, 2, 3]. If *values* is not specified, returns the current range.
If *range* is specified, sets the discrete values in the range. The array must not be empty, and may contain any type of value. The number of values in (the cardinality, or length, of) the *range* array determines the number of quantiles that are computed. For example, to compute quartiles, *range* must be an array of four elements such as [0, 1, 2, 3]. If *range* is not specified, returns the current range.
<a name="quantile_quantiles" href="#quantile_quantiles">#</a> <i>quantile</i>.<b>quantiles</b>()
Returns the quantile thresholds. If the range contains *n* discrete values, the returned threshold array will contain *n* - 1 values. Values less than the first element in the thresholds array, quantiles()[0], are considered in the first quantile; greater values less than the second threshold are in the second quantile, and so on. Internally, the thresholds array is used with [bisect](https://github.com/d3/d3-arrays#bisect) to find the output quantile associated with the given input value.
Returns the quantile thresholds. If the [range](#quantile_range) contains *n* discrete values, the returned threshold array will contain *n* - 1 values. Values less than the first element in the thresholds array, quantiles()[0], are considered in the first quantile; greater values less than the second threshold are in the second quantile, and so on. Internally, the thresholds array is used with [bisect](https://github.com/d3/d3-arrays#bisect) to find the output quantile associated with the given input value.

@@ -456,8 +512,12 @@ <a name="quantile_copy" href="#quantile_copy">#</a> <i>quantile</i>.<b>copy</b>()

Threshold scales are similar to quantize scales, except they allow you to map arbitrary subsets of the domain to discrete values in the range. The input domain is still continuous, and divided into slices based on a set of threshold values. The domain is typically a dimension of the data that you want to visualize, such as the height of students in meters in a sample population. The range is typically a dimension of the desired output visualization, such as a set of colors. See [bl.ocks.org/3306362](http://bl.ocks.org/mbostock/3306362) for an example.
Threshold scales are similar to [quantize scales](#quantize-scales), except they allow you to map arbitrary subsets of the domain to discrete values in the range. The input domain is still continuous, and divided into slices based on a set of threshold values. The domain is typically a dimension of the data that you want to visualize, such as the height of students in meters in a sample population. The range is typically a dimension of the desired output visualization, such as a set of colors. See [bl.ocks.org/3306362](http://bl.ocks.org/mbostock/3306362) for an example.
<a name="threshold" href="#threshold">#</a> <b>threshold</b>()
Constructs a new threshold scale with the default domain [.5] and the default range [0,1]. Thus, the default threshold scale is equivalent to the [round](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Math/round) function for numbers; for example threshold(0.49) returns 0, and threshold(0.51) returns 1.
Constructs a new threshold scale with the default [domain](#threshold_domain) [.5] and the default [range](#threshold_range) [0,1]. Thus, the default threshold scale is equivalent to the [Math.round](https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Math/round) function for numbers; for example threshold(0.49) returns 0, and threshold(0.51) returns 1.
<a name="_threshold" href="#_threshold">#</a> <i>threshold</i>(<i>x</i>)
Given a value *x* in the input [domain](#threshold_domain), returns the corresponding value *y* in the output [range](#threshold_range). For example:
```js

@@ -470,2 +530,10 @@ var s = threshold().domain([0, 1]).range(["a", "b", "c"]);

s(1000); // "c"
```
<a name="threshold_invertExtent" href="#threshold_invertExtent">#</a> <i>threshold</i>.<b>invertExtent</b>(<i>y</i>)
Returns the extent of values in the [domain](#threshold_domain) [<i>x0</i>, <i>x1</i>] for the corresponding value in the [range](#threshold_range) *y*, representing the inverse mapping from range to domain. This method is useful for interaction, say to determine the value in the domain that corresponds to the pixel location under the mouse. For example:
```js
var s = threshold().domain([0, 1]).range(["a", "b", "c"]);
s.invertExtent("a"); // [undefined, 0]

@@ -476,10 +544,2 @@ s.invertExtent("b"); // [0, 1]

<a name="_threshold" href="#_threshold">#</a> <i>threshold</i>(<i>x</i>)
Given a value *x* in the input domain, returns the corresponding value *y* in the output range.
<a name="threshold_invertExtent" href="#threshold_invertExtent">#</a> <i>threshold</i>.<b>invertExtent</b>(<i>y</i>)
Returns the extent of values in the domain [<i>x0</i>, <i>x1</i>] for the corresponding value in the range *y*, representing the inverse mapping from range to domain. This method is useful for interaction, say to determine the value in the domain that corresponds to the pixel location under the mouse.
<a name="threshold_domain" href="#threshold_domain">#</a> <i>threshold</i>.<b>domain</b>([<i>domain</i>])

@@ -489,5 +549,5 @@

<a name="threshold_range" href="#threshold_range">#</a> <i>threshold</i>.<b>range</b>([<i>values</i>])
<a name="threshold_range" href="#threshold_range">#</a> <i>threshold</i>.<b>range</b>([<i>range</i>])
If *values* is specified, sets the scale’s range to the specified array of values. If the number of values in the scale’s domain is N, the number of values in the scale’s range must be N+1. If there are fewer than N+1 elements in the range, the scale may return undefined for some inputs. If there are more than N+1 elements in the range, the additional values are ignored. The elements in the given array need not be numbers; any value or type will work. If *values* is not specified, returns the scale’s current range.
If *range* is specified, sets the scale’s range to the specified array of values. If the number of values in the scale’s domain is N, the number of values in the scale’s range must be N+1. If there are fewer than N+1 elements in the range, the scale may return undefined for some inputs. If there are more than N+1 elements in the range, the additional values are ignored. The elements in the given array need not be numbers; any value or type will work. If *range* is not specified, returns the scale’s current range.

@@ -500,23 +560,23 @@ <a name="threshold_copy" href="#threshold_copy">#</a> <i>threshold</i>.<b>copy</b>()

Unlike quantitative scales, ordinal scales have a discrete domain and range. For example, an ordinal scale might map a set of named categories to a set of colors, or determine the horizontal positions of columns in a column chart.
Unlike [linear](#linear-scales) and other quantitative scales, ordinal scales have a discrete domain and range. For example, an ordinal scale might map a set of named categories to a set of colors, or determine the horizontal positions of columns in a column chart.
<a name="ordinal" href="#ordinal">#</a> <b>ordinal</b>()
Constructs a new ordinal scale with an empty domain and an empty range. The ordinal scale is invalid (always returning undefined) until a range is specified.
Constructs a new ordinal scale with an empty [domain](#ordinal_domain) and an empty [range](#ordinal_range). The ordinal scale is invalid (always returning undefined) until a range is specified.
<a name="_ordinal" href="#_ordinal">#</a> <i>ordinal</i>(<i>x</i>)
Given a value *x* in the input domain, returns the corresponding value *y* in the output range.
Given a value *x* in the input [domain](#ordinal_domain), returns the corresponding value *y* in the output [range](#ordinal_range).
If the range was specified explicitly (as by [range](#ordinal_range), but not [rangeBands](#ordinal_rangeBands), [rangeRoundBands](#ordinal_rangeRoundBands) or [rangePoints](#ordinal_rangePoints)), _and_ the given value *x* is not in the scale’s [domain](#ordinal_domain), then *x* is implicitly added to the domain; subsequent invocations of the scale given the same value *x* will return the same value *y* from the range.
If the given value *x* is not in the scale’s [domain](#ordinal_domain), and the range was specified explicitly (as by [range](#ordinal_range) but not [rangeBands](#ordinal_rangeBands), [rangeRoundBands](#ordinal_rangeRoundBands) or [rangePoints](#ordinal_rangePoints)), then *x* is implicitly added to the domain and the next-available value *y* in the range is assigned to *x*, such that this and subsequent invocations of the scale given the same *x* return the same *y*.
<a name="ordinal_domain" href="#ordinal_domain">#</a> <i>ordinal</i>.<b>domain</b>([<i>values</i>])
<a name="ordinal_domain" href="#ordinal_domain">#</a> <i>ordinal</i>.<b>domain</b>([<i>domain</i>])
If *values* is specified, sets the domain of the ordinal scale to the specified array of values. The first element in *values* will be mapped to the first element in the range, the second domain value to the second range value, and so on. Domain values are stored internally in an associative array as a mapping from value to index; the resulting index is then used to retrieve a value from the range. Thus, an ordinal scale's values must be coercible to a string, and the stringified version of the domain value uniquely identifies the corresponding range value. If *values* is not specified, this method returns the current domain.
If *domain* is specified, sets the domain of the ordinal scale to the specified array of values. The first element in *domain* will be mapped to the first element in the range, the second domain value to the second range value, and so on. Domain values are stored internally in an associative array as a mapping from value to index; the resulting index is then used to retrieve a value from the range. Thus, an ordinal scale's values must be coercible to a string, and the stringified version of the domain value uniquely identifies the corresponding range value. If *domain* is not specified, this method returns the current domain.
Setting the domain on an ordinal scale is optional. If no domain is set, a [range](#ordinal_range) must be set explicitly. Then, each unique value that is passed to the scale function will be assigned a new value from the range; in other words, the domain will be inferred implicitly from usage. Although domains may thus be constructed implicitly, it is still a good idea to assign the ordinal scale's domain explicitly to ensure deterministic behavior, as inferring the domain from usage will be dependent on ordering.
<a name="ordinal_range" href="#ordinal_range">#</a> <i>ordinal</i>.<b>range</b>([<i>values</i>])
<a name="ordinal_range" href="#ordinal_range">#</a> <i>ordinal</i>.<b>range</b>([<i>range</i>])
If *values* is specified, sets the range of the ordinal scale to the specified array of values. The first element in the domain will be mapped to the first element in *values*, the second domain value to the second range value, and so on. If there are fewer elements in the range than in the domain, the scale will recycle values from the start of the range. If *values* is not specified, this method returns the current range.
If *range* is specified, sets the range of the ordinal scale to the specified array of values. The first element in the domain will be mapped to the first element in *range*, the second domain value to the second range value, and so on. If there are fewer elements in the range than in the domain, the scale will recycle values from the start of the range. If *range* is not specified, this method returns the current range.

@@ -697,2 +757,4 @@ This method is intended for when the set of discrete output values is computed explicitly, such as a set of categorical colors. In other cases, such as determining the layout of an ordinal scatterplot or bar chart, you may find the [rangePoints](#ordinal_rangePoints) or [rangeBands](#ordinal_rangeBands) operators more convenient.

* More precise tick thresholds for linear scales.
* Better ticks for log scales that are not base-10.
* Make defensive copies of domains and ranges.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc