vega-scale
Advanced tools
Comparing version 2.0.0-beta.4 to 2.0.0-beta.5
@@ -125,2 +125,5 @@ (function (global, factory) { | ||
scale.invertRange = function(_$$1) { | ||
// bail if range has null or undefined values | ||
if (_$$1[0] == null || _$$1[1] == null) return; | ||
var lo = +_$$1[0], | ||
@@ -132,5 +135,8 @@ hi = +_$$1[1], | ||
// bail if either range endpoint is invalid | ||
if (lo !== lo || hi !== hi) return; | ||
// order range inputs, bail if outside of scale range | ||
if (hi < lo) t = lo, lo = hi, hi = t; | ||
if (hi < values[0] || lo > range$$1[1-reverse]) return undefined; | ||
if (hi < values[0] || lo > range$$1[1-reverse]) return; | ||
@@ -137,0 +143,0 @@ // binary search to index into scale range |
@@ -1,1 +0,1 @@ | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("d3-array"),require("d3-scale"),require("vega-util"),require("d3-scale-chromatic"),require("d3-interpolate")):"function"==typeof define&&define.amd?define(["exports","d3-array","d3-scale","vega-util","d3-scale-chromatic","d3-interpolate"],n):n(e.vega=e.vega||{},e.d3,e.d3,e.vega,e.d3,e.d3)}(this,function(e,n,r,t,a,i){"use strict";function u(){function e(){var e=o().length,r=l[1]<l[0],i=l[r-0],u=l[1-r],p=k(e,d,g);t=(u-i)/(p||1),f&&(t=Math.floor(t)),i+=(u-i-t*(e-d))*s,a=t*(1-d),f&&(i=Math.round(i),a=Math.round(a));var b=n.range(e).map(function(e){return i+t*e});return c(r?b.reverse():b)}var t,a,i=r.scaleOrdinal().unknown(void 0),o=i.domain,c=i.range,l=[0,1],f=!1,d=0,g=0,s=.5;return delete i.unknown,i.domain=function(n){return arguments.length?(o(n),e()):o()},i.range=function(n){return arguments.length?(l=[+n[0],+n[1]],e()):l.slice()},i.rangeRound=function(n){return l=[+n[0],+n[1]],f=!0,e()},i.bandwidth=function(){return a},i.step=function(){return t},i.round=function(n){return arguments.length?(f=!!n,e()):f},i.padding=function(n){return arguments.length?(d=g=Math.max(0,Math.min(1,n)),e()):d},i.paddingInner=function(n){return arguments.length?(d=Math.max(0,Math.min(1,n)),e()):d},i.paddingOuter=function(n){return arguments.length?(g=Math.max(0,Math.min(1,n)),e()):g},i.align=function(n){return arguments.length?(s=Math.max(0,Math.min(1,n)),e()):s},i.invertRange=function(e){var r,t,i,u=+e[0],f=+e[1],d=l[1]<l[0],g=d?c().reverse():c(),s=g.length-1;if(f<u&&(i=u,u=f,f=i),!(f<g[0]||u>l[1-d]))return r=Math.max(0,n.bisectRight(g,u)-1),t=u===f?r:n.bisectRight(g,f)-1,u-g[r]>a+1e-10&&++r,d&&(i=r,r=s-t,t=s-i),r>t?void 0:o().slice(r,t+1)},i.invert=function(e){var n=i.invertRange([e,e]);return n?n[0]:n},i.copy=function(){return u().domain(o()).range(l).round(f).paddingInner(d).paddingOuter(g).align(s)},e()}function o(e){var n=e.copy;return e.padding=e.paddingOuter,delete e.paddingInner,e.copy=function(){return o(n())},e}function c(){return o(u().paddingInner(1))}function l(e){return O.call(e,function(e){return+e})}function f(){function e(e){return null==e||e!==e?void 0:i(u[Math.max(n.bisect(u,e),1)-1])}function a(e){u=l(e),i.domain([u[0],t.peek(u)])}var i=r.scaleLinear(),u=[];return e.domain=function(n){return arguments.length?(a(n),e):u.slice()},e.range=function(n){return arguments.length?(i.range(n),e):i.range()},e.rangeRound=function(n){return arguments.length?(i.rangeRound(n),e):i.rangeRound()},e.interpolate=function(n){return arguments.length?(i.interpolate(n),e):i.interpolate()},e.invert=function(e){return i.invert(e)},e.ticks=function(n){var r=u.length,t=~~(r/(n||r));return t<2?e.domain():u.filter(function(e,n){return!(n%t)})},e.tickFormat=function(){return i.tickFormat.apply(i,arguments)},e.copy=function(){return f().domain(e.domain()).range(e.range())},e}function d(){function e(e){return null==e||e!==e?void 0:t[(n.bisect(r,e)-1)%t.length]}var r=[],t=[];return e.domain=function(n){return arguments.length?(r=l(n),e):r.slice()},e.range=function(n){return arguments.length?(t=x.call(n),e):t.slice()},e.copy=function(){return d().domain(e.domain()).range(e.range())},e}function g(e){function n(){var e=i.domain();u=e[0],o=t.peek(e)-u}function a(n){var r=(n-u)/o;return e(c?Math.max(0,Math.min(1,r)):r)}var i=r.scaleLinear(),u=0,o=1,c=!1;return a.clamp=function(e){return arguments.length?(c=!!e,a):c},a.domain=function(e){return arguments.length?(i.domain(e),n(),a):i.domain()},a.interpolator=function(n){return arguments.length?(e=n,a):e},a.copy=function(){return g().domain(i.domain()).clamp(c).interpolator(e)},a.ticks=function(e){return i.ticks(e)},a.tickFormat=function(e,n){return i.tickFormat(e,n)},a.nice=function(e){return i.nice(e),n(),a},a}function s(e,n){return function(){var r=n();return r.invertRange||(r.invertRange=r.invert?P(r):r.invertExtent?M(r):void 0),r.type=e,r}}function p(e,n){return arguments.length>1?(B[e]=s(e,n),this):B.hasOwnProperty(e)?B[e]:void 0}function b(e){for(var n=e.length/6|0,r=new Array(n),t=0;t<n;)r[t]="#"+e.slice(6*t,6*++t);return r}function m(e,n){S[e]=a["interpolate"+n],I[e]=a["scheme"+n]}function h(e,n){var r=n[0],a=t.peek(n)-r;return function(n){return e(r+n*a)}}function v(e,n,r){return"linear"===e.type||"sequential"===e.type?function(e){return(e-n)/(r-n)}:e.copy().domain([n,r]).range([0,1]).interpolate(y)}function y(e,n){var r=n-e;return function(n){return e+n*r}}function R(e,n){var r=i[w(e)];return null!=n&&r&&r.gamma?r.gamma(n):r}function w(e){return"interpolate"+e.toLowerCase().split("-").map(function(e){return e[0].toUpperCase()+e.slice(1)}).join("")}var P=function(e){return function(n){var r,t=n[0],a=n[1];return a<t&&(r=t,t=a,a=r),[e.invert(t),e.invert(a)]}},M=function(e){return function(n){var r,t,a,i,u=e.range(),o=n[0],c=n[1],l=-1;for(c<o&&(t=o,o=c,c=t),a=0,i=u.length;a<i;++a)u[a]>=o&&u[a]<=c&&(l<0&&(l=a),r=a);if(!(l<0))return o=e.invertExtent(u[l]),c=e.invertExtent(u[r]),[void 0===o[0]?o[1]:o[0],void 0===c[1]?c[0]:c[1]]}},k=function(e,n,r){var t=e-n+2*r;return e?t>0?t:1:0},O=Array.prototype.map,x=Array.prototype.slice,B={identity:r.scaleIdentity,linear:r.scaleLinear,log:r.scaleLog,ordinal:r.scaleOrdinal,pow:r.scalePow,sqrt:r.scaleSqrt,quantile:r.scaleQuantile,quantize:r.scaleQuantize,threshold:r.scaleThreshold,time:r.scaleTime,utc:r.scaleUtc,band:u,point:c,sequential:g,"bin-linear":f,"bin-ordinal":d};for(var G in B)p(G,B[G]);var q=b("4c78a8f58518e4575672b7b254a24beeca3bb279a2ff9da69d755dbab0ac"),Y=b("4c78a89ecae9f58518ffbf7954a24b88d27ab79a20f2cf5b43989483bcb6e45756ff9d9879706ebab0acd67195fcbfd2b279a2d6a5c99e765fd8b5a5"),C=new Array(3).concat("67a9cff7f7f7f1a340","0571b092c5defdb863e66101","0571b092c5def7f7f7fdb863e66101","2166ac67a9cfd1e5f0fee0b6f1a340b35806","2166ac67a9cfd1e5f0f7f7f7fee0b6f1a340b35806","2166ac4393c392c5ded1e5f0fee0b6fdb863e08214b35806","2166ac4393c392c5ded1e5f0f7f7f7fee0b6fdb863e08214b35806","0530612166ac4393c392c5ded1e5f0fee0b6fdb863e08214b358067f3b08","0530612166ac4393c392c5ded1e5f0f7f7f7fee0b6fdb863e08214b358067f3b08").map(b),I={blueorange:C},S={category10:r.schemeCategory10,category20:r.schemeCategory20,category20b:r.schemeCategory20b,category20c:r.schemeCategory20c,accent:a.schemeAccent,dark2:a.schemeDark2,paired:a.schemePaired,pastel1:a.schemePastel1,pastel2:a.schemePastel2,set1:a.schemeSet1,set2:a.schemeSet2,set3:a.schemeSet3,tableau10:q,tableau20:Y,viridis:r.interpolateViridis,magma:r.interpolateMagma,inferno:r.interpolateInferno,plasma:r.interpolatePlasma,blueorange:i.interpolateRgbBasis(t.peek(C))};m("blues","Blues"),m("greens","Greens"),m("greys","Greys"),m("purples","Purples"),m("reds","Reds"),m("oranges","Oranges"),m("brownbluegreen","BrBG"),m("purplegreen","PRGn"),m("pinkyellowgreen","PiYG"),m("purpleorange","PuOr"),m("redblue","RdBu"),m("redgrey","RdGy"),m("redyellowblue","RdYlBu"),m("redyellowgreen","RdYlGn"),m("spectral","Spectral"),m("bluegreen","BuGn"),m("bluepurple","BuPu"),m("greenblue","GnBu"),m("orangered","OrRd"),m("purplebluegreen","PuBuGn"),m("purpleblue","PuBu"),m("purplered","PuRd"),m("redpurple","RdPu"),m("yellowgreenblue","YlGnBu"),m("yellowgreen","YlGn"),m("yelloworangebrown","YlOrBr"),m("yelloworangered","YlOrRd");var A=function(e,n){if(arguments.length>1)return S[e]=n,this;var r=e.split("-");return e=r[0],r=+r[1]+1,r&&I.hasOwnProperty(e)?I[e][r-1]:!r&&S.hasOwnProperty(e)?S[e]:void 0};e.scale=p,e.scheme=A,e.bandSpace=k,e.interpolate=R,e.interpolateRange=h,e.scaleFraction=v,Object.defineProperty(e,"__esModule",{value:!0})}); | ||
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("d3-array"),require("d3-scale"),require("vega-util"),require("d3-scale-chromatic"),require("d3-interpolate")):"function"==typeof define&&define.amd?define(["exports","d3-array","d3-scale","vega-util","d3-scale-chromatic","d3-interpolate"],n):n(e.vega=e.vega||{},e.d3,e.d3,e.vega,e.d3,e.d3)}(this,function(e,n,r,t,a,i){"use strict";function u(){function e(){var e=o().length,r=l[1]<l[0],i=l[r-0],u=l[1-r],p=k(e,d,g);t=(u-i)/(p||1),f&&(t=Math.floor(t)),i+=(u-i-t*(e-d))*s,a=t*(1-d),f&&(i=Math.round(i),a=Math.round(a));var b=n.range(e).map(function(e){return i+t*e});return c(r?b.reverse():b)}var t,a,i=r.scaleOrdinal().unknown(void 0),o=i.domain,c=i.range,l=[0,1],f=!1,d=0,g=0,s=.5;return delete i.unknown,i.domain=function(n){return arguments.length?(o(n),e()):o()},i.range=function(n){return arguments.length?(l=[+n[0],+n[1]],e()):l.slice()},i.rangeRound=function(n){return l=[+n[0],+n[1]],f=!0,e()},i.bandwidth=function(){return a},i.step=function(){return t},i.round=function(n){return arguments.length?(f=!!n,e()):f},i.padding=function(n){return arguments.length?(d=g=Math.max(0,Math.min(1,n)),e()):d},i.paddingInner=function(n){return arguments.length?(d=Math.max(0,Math.min(1,n)),e()):d},i.paddingOuter=function(n){return arguments.length?(g=Math.max(0,Math.min(1,n)),e()):g},i.align=function(n){return arguments.length?(s=Math.max(0,Math.min(1,n)),e()):s},i.invertRange=function(e){if(null!=e[0]&&null!=e[1]){var r,t,i,u=+e[0],f=+e[1],d=l[1]<l[0],g=d?c().reverse():c(),s=g.length-1;if(u===u&&f===f&&(f<u&&(i=u,u=f,f=i),!(f<g[0]||u>l[1-d])))return r=Math.max(0,n.bisectRight(g,u)-1),t=u===f?r:n.bisectRight(g,f)-1,u-g[r]>a+1e-10&&++r,d&&(i=r,r=s-t,t=s-i),r>t?void 0:o().slice(r,t+1)}},i.invert=function(e){var n=i.invertRange([e,e]);return n?n[0]:n},i.copy=function(){return u().domain(o()).range(l).round(f).paddingInner(d).paddingOuter(g).align(s)},e()}function o(e){var n=e.copy;return e.padding=e.paddingOuter,delete e.paddingInner,e.copy=function(){return o(n())},e}function c(){return o(u().paddingInner(1))}function l(e){return O.call(e,function(e){return+e})}function f(){function e(e){return null==e||e!==e?void 0:i(u[Math.max(n.bisect(u,e),1)-1])}function a(e){u=l(e),i.domain([u[0],t.peek(u)])}var i=r.scaleLinear(),u=[];return e.domain=function(n){return arguments.length?(a(n),e):u.slice()},e.range=function(n){return arguments.length?(i.range(n),e):i.range()},e.rangeRound=function(n){return arguments.length?(i.rangeRound(n),e):i.rangeRound()},e.interpolate=function(n){return arguments.length?(i.interpolate(n),e):i.interpolate()},e.invert=function(e){return i.invert(e)},e.ticks=function(n){var r=u.length,t=~~(r/(n||r));return t<2?e.domain():u.filter(function(e,n){return!(n%t)})},e.tickFormat=function(){return i.tickFormat.apply(i,arguments)},e.copy=function(){return f().domain(e.domain()).range(e.range())},e}function d(){function e(e){return null==e||e!==e?void 0:t[(n.bisect(r,e)-1)%t.length]}var r=[],t=[];return e.domain=function(n){return arguments.length?(r=l(n),e):r.slice()},e.range=function(n){return arguments.length?(t=x.call(n),e):t.slice()},e.copy=function(){return d().domain(e.domain()).range(e.range())},e}function g(e){function n(){var e=i.domain();u=e[0],o=t.peek(e)-u}function a(n){var r=(n-u)/o;return e(c?Math.max(0,Math.min(1,r)):r)}var i=r.scaleLinear(),u=0,o=1,c=!1;return a.clamp=function(e){return arguments.length?(c=!!e,a):c},a.domain=function(e){return arguments.length?(i.domain(e),n(),a):i.domain()},a.interpolator=function(n){return arguments.length?(e=n,a):e},a.copy=function(){return g().domain(i.domain()).clamp(c).interpolator(e)},a.ticks=function(e){return i.ticks(e)},a.tickFormat=function(e,n){return i.tickFormat(e,n)},a.nice=function(e){return i.nice(e),n(),a},a}function s(e,n){return function(){var r=n();return r.invertRange||(r.invertRange=r.invert?P(r):r.invertExtent?M(r):void 0),r.type=e,r}}function p(e,n){return arguments.length>1?(B[e]=s(e,n),this):B.hasOwnProperty(e)?B[e]:void 0}function b(e){for(var n=e.length/6|0,r=new Array(n),t=0;t<n;)r[t]="#"+e.slice(6*t,6*++t);return r}function m(e,n){S[e]=a["interpolate"+n],I[e]=a["scheme"+n]}function h(e,n){var r=n[0],a=t.peek(n)-r;return function(n){return e(r+n*a)}}function v(e,n,r){return"linear"===e.type||"sequential"===e.type?function(e){return(e-n)/(r-n)}:e.copy().domain([n,r]).range([0,1]).interpolate(y)}function y(e,n){var r=n-e;return function(n){return e+n*r}}function R(e,n){var r=i[w(e)];return null!=n&&r&&r.gamma?r.gamma(n):r}function w(e){return"interpolate"+e.toLowerCase().split("-").map(function(e){return e[0].toUpperCase()+e.slice(1)}).join("")}var P=function(e){return function(n){var r,t=n[0],a=n[1];return a<t&&(r=t,t=a,a=r),[e.invert(t),e.invert(a)]}},M=function(e){return function(n){var r,t,a,i,u=e.range(),o=n[0],c=n[1],l=-1;for(c<o&&(t=o,o=c,c=t),a=0,i=u.length;a<i;++a)u[a]>=o&&u[a]<=c&&(l<0&&(l=a),r=a);if(!(l<0))return o=e.invertExtent(u[l]),c=e.invertExtent(u[r]),[void 0===o[0]?o[1]:o[0],void 0===c[1]?c[0]:c[1]]}},k=function(e,n,r){var t=e-n+2*r;return e?t>0?t:1:0},O=Array.prototype.map,x=Array.prototype.slice,B={identity:r.scaleIdentity,linear:r.scaleLinear,log:r.scaleLog,ordinal:r.scaleOrdinal,pow:r.scalePow,sqrt:r.scaleSqrt,quantile:r.scaleQuantile,quantize:r.scaleQuantize,threshold:r.scaleThreshold,time:r.scaleTime,utc:r.scaleUtc,band:u,point:c,sequential:g,"bin-linear":f,"bin-ordinal":d};for(var G in B)p(G,B[G]);var q=b("4c78a8f58518e4575672b7b254a24beeca3bb279a2ff9da69d755dbab0ac"),Y=b("4c78a89ecae9f58518ffbf7954a24b88d27ab79a20f2cf5b43989483bcb6e45756ff9d9879706ebab0acd67195fcbfd2b279a2d6a5c99e765fd8b5a5"),C=new Array(3).concat("67a9cff7f7f7f1a340","0571b092c5defdb863e66101","0571b092c5def7f7f7fdb863e66101","2166ac67a9cfd1e5f0fee0b6f1a340b35806","2166ac67a9cfd1e5f0f7f7f7fee0b6f1a340b35806","2166ac4393c392c5ded1e5f0fee0b6fdb863e08214b35806","2166ac4393c392c5ded1e5f0f7f7f7fee0b6fdb863e08214b35806","0530612166ac4393c392c5ded1e5f0fee0b6fdb863e08214b358067f3b08","0530612166ac4393c392c5ded1e5f0f7f7f7fee0b6fdb863e08214b358067f3b08").map(b),I={blueorange:C},S={category10:r.schemeCategory10,category20:r.schemeCategory20,category20b:r.schemeCategory20b,category20c:r.schemeCategory20c,accent:a.schemeAccent,dark2:a.schemeDark2,paired:a.schemePaired,pastel1:a.schemePastel1,pastel2:a.schemePastel2,set1:a.schemeSet1,set2:a.schemeSet2,set3:a.schemeSet3,tableau10:q,tableau20:Y,viridis:r.interpolateViridis,magma:r.interpolateMagma,inferno:r.interpolateInferno,plasma:r.interpolatePlasma,blueorange:i.interpolateRgbBasis(t.peek(C))};m("blues","Blues"),m("greens","Greens"),m("greys","Greys"),m("purples","Purples"),m("reds","Reds"),m("oranges","Oranges"),m("brownbluegreen","BrBG"),m("purplegreen","PRGn"),m("pinkyellowgreen","PiYG"),m("purpleorange","PuOr"),m("redblue","RdBu"),m("redgrey","RdGy"),m("redyellowblue","RdYlBu"),m("redyellowgreen","RdYlGn"),m("spectral","Spectral"),m("bluegreen","BuGn"),m("bluepurple","BuPu"),m("greenblue","GnBu"),m("orangered","OrRd"),m("purplebluegreen","PuBuGn"),m("purpleblue","PuBu"),m("purplered","PuRd"),m("redpurple","RdPu"),m("yellowgreenblue","YlGnBu"),m("yellowgreen","YlGn"),m("yelloworangebrown","YlOrBr"),m("yelloworangered","YlOrRd");var A=function(e,n){if(arguments.length>1)return S[e]=n,this;var r=e.split("-");return e=r[0],r=+r[1]+1,r&&I.hasOwnProperty(e)?I[e][r-1]:!r&&S.hasOwnProperty(e)?S[e]:void 0};e.scale=p,e.scheme=A,e.bandSpace=k,e.interpolate=R,e.interpolateRange=h,e.scaleFraction=v,Object.defineProperty(e,"__esModule",{value:!0})}); |
{ | ||
"name": "vega-scale", | ||
"version": "2.0.0-beta.4", | ||
"version": "2.0.0-beta.5", | ||
"description": "Scales and color schemes for visual encoding.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -75,2 +75,5 @@ import bandSpace from './bandSpace'; | ||
scale.invertRange = function(_) { | ||
// bail if range has null or undefined values | ||
if (_[0] == null || _[1] == null) return; | ||
var lo = +_[0], | ||
@@ -82,5 +85,8 @@ hi = +_[1], | ||
// bail if either range endpoint is invalid | ||
if (lo !== lo || hi !== hi) return; | ||
// order range inputs, bail if outside of scale range | ||
if (hi < lo) t = lo, lo = hi, hi = t; | ||
if (hi < values[0] || lo > range[1-reverse]) return undefined; | ||
if (hi < values[0] || lo > range[1-reverse]) return; | ||
@@ -87,0 +93,0 @@ // binary search to index into scale range |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
43234
858