Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vega-scale

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vega-scale - npm Package Compare versions

Comparing version 6.1.0 to 7.0.0

151

build/vega-scale.js
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vega-util'), require('d3-array'), require('d3-scale'), require('d3-interpolate'), require('vega-time'), require('d3-format')) :
typeof define === 'function' && define.amd ? define(['exports', 'vega-util', 'd3-array', 'd3-scale', 'd3-interpolate', 'vega-time', 'd3-format'], factory) :
(global = global || self, factory(global.vega = {}, global.vega, global.d3, global.d3, global.d3, global.vega, global.d3));
}(this, (function (exports, vegaUtil, d3Array, $, $$1, vegaTime, d3Format) { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vega-util'), require('d3-array'), require('d3-scale'), require('d3-interpolate'), require('vega-time')) :
typeof define === 'function' && define.amd ? define(['exports', 'vega-util', 'd3-array', 'd3-scale', 'd3-interpolate', 'vega-time'], factory) :
(global = global || self, factory(global.vega = {}, global.vega, global.d3, global.d3, global.d3, global.vega));
}(this, (function (exports, vegaUtil, d3Array, $, $$1, vegaTime) { 'use strict';

@@ -599,2 +599,5 @@ function bandSpace(count, paddingInner, paddingOuter) {

const ascending = (a, b) => a[1] - b[1];
const descending = (a, b) => b[1] - a[1];
/**

@@ -648,3 +651,4 @@ * Determine the tick count or interval function.

lo = range[0],
hi = vegaUtil.peek(range);
hi = vegaUtil.peek(range),
cmp = ascending;

@@ -655,2 +659,3 @@ if (lo > hi) {

lo = range;
cmp = descending;
}

@@ -661,6 +666,8 @@

ticks = ticks.filter(v => {
v = scale(v);
return lo <= v && v <= hi;
});
// filter ticks to valid values within the range
// additionally sort ticks in range order (#2579)
ticks = ticks.map(v => [v, scale(v)])
.filter(_ => lo <= _[1] && _[1] <= hi)
.sort(cmp)
.map(_ => _[0]);

@@ -710,14 +717,29 @@ if (count > 0 && ticks.length > 1) {

*/
function tickFormat(scale, count, specifier, formatType, noSkip) {
var type = scale.type,
format = (type === Time || formatType === Time) ? vegaTime.timeFormat(specifier)
: (type === UTC || formatType === UTC) ? vegaTime.utcFormat(specifier)
: scale.tickFormat ? scale.tickFormat(count, specifier)
: specifier ? d3Format.format(specifier)
: defaultFormatter;
function tickFormat(locale, scale, count, specifier, formatType, noSkip) {
var type = scale.type;
let format = defaultFormatter;
if (isLogarithmic(type)) {
var logfmt = variablePrecision(specifier);
format = noSkip || scale.bins ? logfmt : filter(format, logfmt);
if (type === Time || formatType === Time) {
format = locale.timeFormat(specifier);
}
else if (type === UTC || formatType === UTC) {
format = locale.utcFormat(specifier);
}
else if (isLogarithmic(type)) {
const varfmt = locale.formatFloat(specifier);
if (noSkip || scale.bins) {
format = varfmt;
} else {
const test = tickLog(scale, count, false);
format = _ => test(_) ? varfmt(_) : '';
}
}
else if (scale.tickFormat) {
// if d3 scale has tickFormat, it must be continuous
const d = scale.domain();
format = locale.formatSpan(d[0], d[d.length - 1], count, specifier);
}
else if (specifier) {
format = locale.format(specifier);
}

@@ -727,47 +749,16 @@ return format;

function filter(sourceFormat, targetFormat) {
return _ => sourceFormat(_) ? targetFormat(_) : '';
}
function tickLog(scale, count, values) {
const ticks = tickValues(scale, count),
base = scale.base(),
logb = Math.log(base),
k = Math.max(1, base * count / ticks.length);
function variablePrecision(specifier) {
var s = d3Format.formatSpecifier(specifier || ',');
if (s.precision == null) {
s.precision = 12;
switch (s.type) {
case '%': s.precision -= 2; break;
case 'e': s.precision -= 1; break;
}
return trimZeroes(
d3Format.format(s), // number format
d3Format.format('.1f')(1)[1] // decimal point character
);
} else {
return d3Format.format(s);
}
}
function trimZeroes(format, decimalChar) {
return x => {
var str = format(x),
dec = str.indexOf(decimalChar),
idx, end;
if (dec < 0) return str;
idx = rightmostDigit(str, dec);
end = idx < str.length ? str.slice(idx) : '';
while (--idx > dec) if (str[idx] !== '0') { ++idx; break; }
return str.slice(0, idx) + end;
// apply d3-scale's log format filter criteria
const test = d => {
let i = d / Math.pow(base, Math.round(Math.log(d) / logb));
if (i * base < base - 0.5) i *= base;
return i <= k;
};
}
function rightmostDigit(str, dec) {
var i = str.lastIndexOf('e'), c;
if (i > 0) return i;
for (i=str.length; --i > dec;) {
c = str.charCodeAt(i);
if (c >= 48 && c <= 57) return i + 1; // is digit
}
return values ? ticks.filter(test) : test;
}

@@ -788,3 +779,3 @@

return scale.bins ? binValues(scale.bins)
: scale.type === Log ? logValues(scale, count)
: scale.type === Log ? tickLog(scale, count, true)
: symbols[scale.type] ? thresholdValues(scale[symbols[scale.type]]())

@@ -794,17 +785,3 @@ : tickValues(scale, count);

function logValues(scale, count) {
var ticks = tickValues(scale, count),
base = scale.base(),
logb = Math.log(base),
k = Math.max(1, base * count / ticks.length);
// apply d3-scale's log format filter criteria
return ticks.filter(d => {
var i = d / Math.pow(base, Math.round(Math.log(d) / logb));
if (i * base < base - 0.5) i *= base;
return i <= k;
});
}
function thresholdFormat(scale, specifier) {
function thresholdFormat(locale, scale, specifier) {
var _ = scale[formats[scale.type]](),

@@ -819,3 +796,3 @@ n = _.length,

// tickCount = 3 ticks times 10 for increased resolution
return $.tickFormat(0, d, 3 * 10, specifier);
return locale.formatSpan(0, d, 3 * 10, specifier);
}

@@ -839,6 +816,6 @@

function labelFormat(scale, count, type, specifier, formatType, noSkip) {
function labelFormat(locale, scale, count, type, specifier, formatType, noSkip) {
const format = formats[scale.type] && formatType !== Time && formatType !== UTC
? thresholdFormat(scale, specifier)
: tickFormat(scale, count, specifier, formatType, noSkip);
? thresholdFormat(locale, scale, specifier)
: tickFormat(locale, scale, count, specifier, formatType, noSkip);

@@ -892,3 +869,3 @@ return type === SymbolLegend && isDiscreteRange(scale) ? formatRange(format)

function format(scale, specifier, formatType) {
function format(locale, scale, specifier, formatType) {
const type = formatType || scale.type;

@@ -901,11 +878,11 @@

return !specifier && type === Time ? vegaTime.timeFormat('%A, %d %B %Y, %X')
: !specifier && type === UTC ? vegaTime.utcFormat('%A, %d %B %Y, %X UTC')
: labelFormat(scale, 5, null, specifier, formatType, true);
return !specifier && type === Time ? locale.timeFormat('%A, %d %B %Y, %X')
: !specifier && type === UTC ? locale.utcFormat('%A, %d %B %Y, %X UTC')
: labelFormat(locale, scale, 5, null, specifier, formatType, true);
}
function domainCaption(scale, opt) {
function domainCaption(locale, scale, opt) {
opt = opt || {};
const max = Math.max(3, opt.maxlen || 7),
fmt = format(scale, opt.format, opt.formatType);
fmt = format(locale, scale, opt.format, opt.formatType);

@@ -912,0 +889,0 @@ // if scale breaks domain into bins, describe boundaries

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

!function(e,a){"object"==typeof exports&&"undefined"!=typeof module?a(exports,require("vega-util"),require("d3-array"),require("d3-scale"),require("d3-interpolate"),require("vega-time"),require("d3-format")):"function"==typeof define&&define.amd?define(["exports","vega-util","d3-array","d3-scale","d3-interpolate","vega-time","d3-format"],a):a((e=e||self).vega={},e.vega,e.d3,e.d3,e.d3,e.vega,e.d3)}(this,(function(e,a,n,c,f,t,d){"use strict";function r(e,a,n){var c=e-a+2*n;return e?c>0?c:1:0}const i="log",b="time",o="utc",l="continuous";function u(){var e,a,f=c.scaleOrdinal().unknown(void 0),t=f.domain,d=f.range,i=[0,1],b=!1,o=0,l=0,s=.5;function g(){var c=t().length,f=i[1]<i[0],u=i[f-0],g=i[1-f],p=r(c,o,l);e=(g-u)/(p||1),b&&(e=Math.floor(e)),u+=(g-u-e*(c-o))*s,a=e*(1-o),b&&(u=Math.round(u),a=Math.round(a));var m=n.range(c).map((function(a){return u+e*a}));return d(f?m.reverse():m)}return delete f.unknown,f.domain=function(e){return arguments.length?(t(e),g()):t()},f.range=function(e){return arguments.length?(i=[+e[0],+e[1]],g()):i.slice()},f.rangeRound=function(e){return i=[+e[0],+e[1]],b=!0,g()},f.bandwidth=function(){return a},f.step=function(){return e},f.round=function(e){return arguments.length?(b=!!e,g()):b},f.padding=function(e){return arguments.length?(l=Math.max(0,Math.min(1,e)),o=l,g()):o},f.paddingInner=function(e){return arguments.length?(o=Math.max(0,Math.min(1,e)),g()):o},f.paddingOuter=function(e){return arguments.length?(l=Math.max(0,Math.min(1,e)),g()):l},f.align=function(e){return arguments.length?(s=Math.max(0,Math.min(1,e)),g()):s},f.invertRange=function(e){if(null!=e[0]&&null!=e[1]){var c,f,r,b=+e[0],o=+e[1],l=i[1]<i[0],u=l?d().reverse():d(),s=u.length-1;if(b==b&&o==o&&(o<b&&(r=b,b=o,o=r),!(o<u[0]||b>i[1-l])))return c=Math.max(0,n.bisectRight(u,b)-1),f=b===o?c:n.bisectRight(u,o)-1,b-u[c]>a+1e-10&&++c,l&&(r=c,c=s-f,f=s-r),c>f?void 0:t().slice(c,f+1)}},f.invert=function(e){var a=f.invertRange([e,e]);return a?a[0]:a},f.copy=function(){return u().domain(t()).range(i).round(b).paddingInner(o).paddingOuter(l).align(s)},g()}var s=Array.prototype.map;function g(e){return s.call(e,(function(e){return+e}))}var p=Array.prototype.slice;const m={};function h(e,n,c){const f=function(){var a=n();return a.invertRange||(a.invertRange=a.invert?function(e){return function(a){var n,c=a[0],f=a[1];return f<c&&(n=c,c=f,f=n),[e.invert(c),e.invert(f)]}}(a):a.invertExtent?function(e){return function(a){var n,c,f,t,d=e.range(),r=a[0],i=a[1],b=-1;for(i<r&&(c=r,r=i,i=c),f=0,t=d.length;f<t;++f)d[f]>=r&&d[f]<=i&&(b<0&&(b=f),n=f);if(!(b<0))return r=e.invertExtent(d[b]),i=e.invertExtent(d[n]),[void 0===r[0]?r[1]:r[0],void 0===i[1]?i[0]:i[1]]}}(a):void 0),a.type=e,a};return f.metadata=a.toSet(a.array(c)),f}function v(e,a,n){return arguments.length>1?(m[e]=h(e,a,n),this):y(e)?m[e]:void 0}function y(e){return a.hasOwnProperty(m,e)}function q(e,a){const n=m[e];return n&&n.metadata[a]}function w(e){return q(e,"discrete")}function k(e){return q(e,"discretizing")}function M(e){return q(e,i)}function S(e){return q(e,"temporal")}v("identity",c.scaleIdentity),v("linear",c.scaleLinear,l),v(i,c.scaleLog,[l,i]),v("pow",c.scalePow,l),v("sqrt",c.scaleSqrt,l),v("symlog",c.scaleSymlog,l),v(b,c.scaleTime,[l,"temporal"]),v(o,c.scaleUtc,[l,"temporal"]),v("sequential",c.scaleSequential,[l,"interpolating"]),v("sequential-linear",c.scaleSequential,[l,"interpolating"]),v("sequential-log",c.scaleSequentialLog,[l,"interpolating",i]),v("sequential-pow",c.scaleSequentialPow,[l,"interpolating"]),v("sequential-sqrt",c.scaleSequentialSqrt,[l,"interpolating"]),v("sequential-symlog",c.scaleSequentialSymlog,[l,"interpolating"]),v("diverging-linear",c.scaleDiverging,[l,"interpolating"]),v("diverging-log",c.scaleDivergingLog,[l,"interpolating",i]),v("diverging-pow",c.scaleDivergingPow,[l,"interpolating"]),v("diverging-sqrt",c.scaleDivergingSqrt,[l,"interpolating"]),v("diverging-symlog",c.scaleDivergingSymlog,[l,"interpolating"]),v("quantile",c.scaleQuantile,["discretizing","quantile"]),v("quantize",c.scaleQuantize,"discretizing"),v("threshold",c.scaleThreshold,"discretizing"),v("bin-ordinal",(function e(){var f=[],t=[];function d(e){return null==e||e!=e?void 0:t[(n.bisect(f,e)-1)%t.length]}return d.domain=function(e){return arguments.length?(f=g(e),d):f.slice()},d.range=function(e){return arguments.length?(t=p.call(e),d):t.slice()},d.tickFormat=function(e,n){return c.tickFormat(f[0],a.peek(f),null==e?10:e,n)},d.copy=function(){return e().domain(d.domain()).range(d.range())},d}),["discrete","discretizing"]),v("ordinal",c.scaleOrdinal,"discrete"),v("band",u,"discrete"),v("point",(function(){return function e(a){var n=a.copy;return a.padding=a.paddingOuter,delete a.paddingInner,a.copy=function(){return e(n())},a}(u().paddingInner(1))}),"discrete");const x=["clamp","base","constant","exponent"];function O(e,a,n){return f.piecewise(B(a||"rgb",n),e)}function B(e,a){var n=f[function(e){return"interpolate"+e.toLowerCase().split("-").map((function(e){return e[0].toUpperCase()+e.slice(1)})).join("")}(e)];return null!=a&&n&&n.gamma?n.gamma(a):n}function G(e){for(var a=e.length/6|0,n=new Array(a),c=0;c<a;)n[c]="#"+e.slice(6*c,6*++c);return n}function F(e,a){for(let n in e)z(n,a(e[n]))}const R={};function z(e,a){return e=e&&e.toLowerCase(),arguments.length>1?(R[e]=a,this):R[e]}F({category10:"1f77b4ff7f0e2ca02cd627289467bd8c564be377c27f7f7fbcbd2217becf",category20:"1f77b4aec7e8ff7f0effbb782ca02c98df8ad62728ff98969467bdc5b0d58c564bc49c94e377c2f7b6d27f7f7fc7c7c7bcbd22dbdb8d17becf9edae5",category20b:"393b795254a36b6ecf9c9ede6379398ca252b5cf6bcedb9c8c6d31bd9e39e7ba52e7cb94843c39ad494ad6616be7969c7b4173a55194ce6dbdde9ed6",category20c:"3182bd6baed69ecae1c6dbefe6550dfd8d3cfdae6bfdd0a231a35474c476a1d99bc7e9c0756bb19e9ac8bcbddcdadaeb636363969696bdbdbdd9d9d9",tableau10:"4c78a8f58518e4575672b7b254a24beeca3bb279a2ff9da69d755dbab0ac",tableau20:"4c78a89ecae9f58518ffbf7954a24b88d27ab79a20f2cf5b43989483bcb6e45756ff9d9879706ebab0acd67195fcbfd2b279a2d6a5c99e765fd8b5a5",accent:"7fc97fbeaed4fdc086ffff99386cb0f0027fbf5b17666666",dark2:"1b9e77d95f027570b3e7298a66a61ee6ab02a6761d666666",paired:"a6cee31f78b4b2df8a33a02cfb9a99e31a1cfdbf6fff7f00cab2d66a3d9affff99b15928",pastel1:"fbb4aeb3cde3ccebc5decbe4fed9a6ffffcce5d8bdfddaecf2f2f2",pastel2:"b3e2cdfdcdaccbd5e8f4cae4e6f5c9fff2aef1e2cccccccc",set1:"e41a1c377eb84daf4a984ea3ff7f00ffff33a65628f781bf999999",set2:"66c2a5fc8d628da0cbe78ac3a6d854ffd92fe5c494b3b3b3",set3:"8dd3c7ffffb3bebadafb807280b1d3fdb462b3de69fccde5d9d9d9bc80bdccebc5ffed6f"},G),F({blues:"cfe1f2bed8eca8cee58fc1de74b2d75ba3cf4592c63181bd206fb2125ca40a4a90",greens:"d3eecdc0e6baabdda594d3917bc77d60ba6c46ab5e329a512089430e7735036429",greys:"e2e2e2d4d4d4c4c4c4b1b1b19d9d9d8888887575756262624d4d4d3535351e1e1e",oranges:"fdd8b3fdc998fdb87bfda55efc9244f87f2cf06b18e4580bd14904b93d029f3303",purples:"e2e1efd4d4e8c4c5e0b4b3d6a3a0cc928ec3827cb97566ae684ea25c3696501f8c",reds:"fdc9b4fcb49afc9e80fc8767fa7051f6573fec3f2fdc2a25c81b1db21218970b13",blueGreen:"d5efedc1e8e0a7ddd18bd2be70c6a958ba9144ad77319c5d2089460e7736036429",bluePurple:"ccddecbad0e4a8c2dd9ab0d4919cc98d85be8b6db28a55a6873c99822287730f71",greenBlue:"d3eecec5e8c3b1e1bb9bd8bb82cec269c2ca51b2cd3c9fc7288abd1675b10b60a1",orangeRed:"fddcaffdcf9bfdc18afdad77fb9562f67d53ee6545e24932d32d1ebf130da70403",purpleBlue:"dbdaebc8cee4b1c3de97b7d87bacd15b9fc93a90c01e7fb70b70ab056199045281",purpleBlueGreen:"dbd8eac8cee4b0c3de93b7d872acd1549fc83892bb1c88a3097f8702736b016353",purpleRed:"dcc9e2d3b3d7ce9eccd186c0da6bb2e14da0e23189d91e6fc61159ab07498f023a",redPurple:"fccfccfcbec0faa9b8f98faff571a5ec539ddb3695c41b8aa908808d0179700174",yellowGreen:"e4f4acd1eca0b9e2949ed68880c97c62bb6e47aa5e3297502083440e723b036034",yellowOrangeBrown:"feeaa1fedd84fecc63feb746fca031f68921eb7215db5e0bc54c05ab3d038f3204",yellowOrangeRed:"fee087fed16ffebd59fea849fd903efc7335f9522bee3423de1b20ca0b22af0225",blueOrange:"134b852f78b35da2cb9dcae1d2e5eff2f0ebfce0bafbbf74e8932fc5690d994a07",brownBlueGreen:"704108a0651ac79548e3c78af3e6c6eef1eac9e9e48ed1c74da79e187a72025147",purpleGreen:"5b1667834792a67fb6c9aed3e6d6e8eff0efd9efd5aedda971bb75368e490e5e29",purpleOrange:"4114696647968f83b7b9b4d6dadbebf3eeeafce0bafbbf74e8932fc5690d994a07",redBlue:"8c0d25bf363adf745ef4ae91fbdbc9f2efeed2e5ef9dcae15da2cb2f78b3134b85",redGrey:"8c0d25bf363adf745ef4ae91fcdccbfaf4f1e2e2e2c0c0c0969696646464343434",yellowGreenBlue:"eff9bddbf1b4bde5b594d5b969c5be45b4c22c9ec02182b82163aa23479c1c3185",redYellowBlue:"a50026d4322cf16e43fcac64fedd90faf8c1dcf1ecabd6e875abd04a74b4313695",redYellowGreen:"a50026d4322cf16e43fcac63fedd8df9f7aed7ee8ea4d86e64bc6122964f006837",pinkYellowGreen:"8e0152c0267edd72adf0b3d6faddedf5f3efe1f2cab6de8780bb474f9125276419",spectral:"9e0142d13c4bf0704afcac63fedd8dfbf8b0e0f3a1a9dda269bda94288b55e4fa2",viridis:"440154470e61481a6c482575472f7d443a834144873d4e8a39568c35608d31688e2d708e2a788e27818e23888e21918d1f988b1fa08822a8842ab07f35b77943bf7154c56866cc5d7ad1518fd744a5db36bcdf27d2e21be9e51afde725",magma:"0000040404130b0924150e3720114b2c11603b0f704a107957157e651a80721f817f24828c29819a2e80a8327db6377ac43c75d1426fde4968e95462f1605df76f5cfa7f5efc8f65fe9f6dfeaf78febf84fece91fddea0fcedaffcfdbf",inferno:"0000040403130c0826170c3b240c4f330a5f420a68500d6c5d126e6b176e781c6d86216b932667a12b62ae305cbb3755c73e4cd24644dd513ae65c30ed6925f3771af8850ffb9506fca50afcb519fac62df6d645f2e661f3f484fcffa4",plasma:"0d088723069033059742039d5002a25d01a66a00a87801a88405a7900da49c179ea72198b12a90ba3488c33d80cb4779d35171da5a69e16462e76e5bed7953f2834cf68f44fa9a3dfca636fdb32ffec029fcce25f9dc24f5ea27f0f921",rainbow:"6e40aa883eb1a43db3bf3cafd83fa4ee4395fe4b83ff576eff6659ff7847ff8c38f3a130e2b72fcfcc36bee044aff05b8ff4576ff65b52f6673af27828ea8d1ddfa319d0b81cbecb23abd82f96e03d82e14c6edb5a5dd0664dbf6e40aa",sinebow:"ff4040fc582af47218e78d0bd5a703bfbf00a7d5038de70b72f41858fc2a40ff402afc5818f4720be78d03d5a700bfbf03a7d50b8de71872f42a58fc4040ff582afc7218f48d0be7a703d5bf00bfd503a7e70b8df41872fc2a58ff4040",browns:"eedbbdecca96e9b97ae4a865dc9856d18954c7784cc0673fb85536ad44339f3632",tealBlues:"bce4d89dd3d181c3cb65b3c245a2b9368fae347da0306a932c5985",teals:"bbdfdfa2d4d58ac9c975bcbb61b0af4da5a43799982b8b8c1e7f7f127273006667",warmGreys:"dcd4d0cec5c1c0b8b4b3aaa7a59c9998908c8b827f7e7673726866665c5a59504e",goldGreen:"f4d166d5ca60b6c35c98bb597cb25760a6564b9c533f8f4f33834a257740146c36",goldOrange:"f4d166f8be5cf8aa4cf5983bf3852aef701be2621fd65322c54923b142239e3a26",goldRed:"f4d166f6be59f9aa51fc964ef6834bee734ae56249db5247cf4244c43141b71d3e",lightGreyRed:"efe9e6e1dad7d5cbc8c8bdb9bbaea9cd967ddc7b43e15f19df4011dc000b",lightGreyTeal:"e4eaead6dcddc8ced2b7c2c7a6b4bc64b0bf22a6c32295c11f85be1876bc",lightMulti:"e0f1f2c4e9d0b0de9fd0e181f6e072f6c053f3993ef77440ef4a3c",lightOrange:"f2e7daf7d5baf9c499fab184fa9c73f68967ef7860e8645bde515bd43d5b",lightTealBlue:"e3e9e0c0dccf9aceca7abfc859afc0389fb9328dad2f7ca0276b95255988",darkBlue:"3232322d46681a5c930074af008cbf05a7ce25c0dd38daed50f3faffffff",darkGold:"3c3c3c584b37725e348c7631ae8b2bcfa424ecc31ef9de30fff184ffffff",darkGreen:"3a3a3a215748006f4d048942489e4276b340a6c63dd2d836ffeb2cffffaa",darkMulti:"3737371f5287197d8c29a86995ce3fffe800ffffff",darkRed:"3434347036339e3c38cc4037e75d1eec8620eeab29f0ce32ffeb2c"},e=>O(G(e)));const I=e=>a.isArray(e)?e.map(e=>String(e)):String(e);function L(e,n,c){let f=e.range(),t=f[0],d=a.peek(f);if(t>d&&(f=d,d=t,t=f),t=Math.floor(t),d=Math.ceil(d),n=n.filter(a=>(a=e(a),t<=a&&a<=d)),c>0&&n.length>1){const e=[n[0],a.peek(n)];for(;n.length>c&&n.length>=3;)n=n.filter((e,a)=>!(a%2));n.length<3&&(n=e)}return n}function T(e,a){return e.bins?L(e,e.bins):e.ticks?e.ticks(a):e.domain()}function C(e,a,n,c,f){var r,i,l=e.type,u=l===b||c===b?t.timeFormat(n):l===o||c===o?t.utcFormat(n):e.tickFormat?e.tickFormat(a,n):n?d.format(n):I;if(M(l)){var s=function(e){var a=d.formatSpecifier(e||",");if(null==a.precision){switch(a.precision=12,a.type){case"%":a.precision-=2;break;case"e":a.precision-=1}return function(e,a){return n=>{var c,f,t=e(n),d=t.indexOf(a);if(d<0)return t;for(f=(c=function(e,a){var n,c=e.lastIndexOf("e");if(c>0)return c;for(c=e.length;--c>a;)if((n=e.charCodeAt(c))>=48&&n<=57)return c+1}(t,d))<t.length?t.slice(c):"";--c>d;)if("0"!==t[c]){++c;break}return t.slice(0,c)+f}}(d.format(a),d.format(".1f")(1)[1])}return d.format(a)}(n);u=f||e.bins?s:(r=u,i=s,e=>r(e)?i(e):"")}return u}const P={quantile:"quantiles",quantize:"thresholds",threshold:"domain"},A={quantile:"quantiles",quantize:"domain"};function D(e,n){return e.bins?function(e){const n=e.slice(0,-1);return n.max=a.peek(e),n}(e.bins):e.type===i?function(e,a){var n=T(e,a),c=e.base(),f=Math.log(c),t=Math.max(1,c*a/n.length);return n.filter(e=>{var a=e/Math.pow(c,Math.round(Math.log(e)/f));return a*c<c-.5&&(a*=c),a<=t})}(e,n):P[e.type]?function(e){const a=[-1/0].concat(e);return a.max=1/0,a}(e[P[e.type]]()):T(e,n)}function j(e,a,n,f,t,d){const r=A[e.type]&&t!==b&&t!==o?function(e,a){var n,f=e[A[e.type]](),t=f.length,d=t>1?f[1]-f[0]:f[0];for(n=1;n<t;++n)d=Math.min(d,f[n]-f[n-1]);return c.tickFormat(0,d,30,a)}(e,f):C(e,a,f,t,d);return"symbol"===n&&function(e){return P[e.type]||e.bins}(e)?function(e){return(a,n,c)=>{var f=$(c[n+1],$(c.max,1/0)),t=Q(a,e),d=Q(f,e);return t&&d?t+" – "+d:d?"< "+d:"≥ "+t}}(r):"discrete"===n?function(e){return(a,n)=>n?e(a):null}(r):function(e){return a=>e(a)}(r)}function $(e,a){return null!=e?e:a}function Q(e,a){return Number.isFinite(e)?a(e):null}Object.defineProperty(e,"scaleImplicit",{enumerable:!0,get:function(){return c.scaleImplicit}}),e.Band="band",e.BinOrdinal="bin-ordinal",e.DiscreteLegend="discrete",e.Diverging="diverging",e.GradientLegend="gradient",e.Identity="identity",e.Linear="linear",e.Log=i,e.Ordinal="ordinal",e.Point="point",e.Pow="pow",e.Quantile="quantile",e.Quantize="quantize",e.Sequential="sequential",e.Sqrt="sqrt",e.SymbolLegend="symbol",e.Symlog="symlog",e.Threshold="threshold",e.Time=b,e.UTC=o,e.bandSpace=r,e.domainCaption=function(e,n){n=n||{};const c=Math.max(3,n.maxlen||7),f=function(e,n,c){const f=c||e.type;return a.isString(n)&&S(f)&&(n=n.replace(/%a/g,"%A").replace(/%b/g,"%B")),n||f!==b?n||f!==o?j(e,5,null,n,c,!0):t.utcFormat("%A, %d %B %Y, %X UTC"):t.timeFormat("%A, %d %B %Y, %X")}(e,n.format,n.formatType);if(k(e.type)){const a=D(e).slice(1).map(f),n=a.length;return`${n} boundar${1===n?"y":"ies"}: ${a.join(", ")}`}if(w(e.type)){const a=e.domain(),n=a.length;return`${n} value${1===n?"":"s"}: ${n>c?a.slice(0,c-2).map(f).join(", ")+", ending with "+a.slice(-1).map(f):a.map(f).join(", ")}`}{const n=e.domain();return`values from ${f(n[0])} to ${f(a.peek(n))}`}},e.interpolate=B,e.interpolateColors=O,e.interpolateRange=function(e,n){var c=n[0],f=a.peek(n)-c;return function(a){return e(c+a*f)}},e.isContinuous=function(e){return q(e,l)},e.isDiscrete=w,e.isDiscretizing=k,e.isInterpolating=function(e){return q(e,"interpolating")},e.isLogarithmic=M,e.isQuantile=function(e){return q(e,"quantile")},e.isTemporal=S,e.isValidScaleType=y,e.labelFormat=j,e.labelFraction=function(e){var n=e.domain(),c=n.length-1,f=+n[0],t=+a.peek(n),d=t-f;if("threshold"===e.type){const e=c?d/c:.1;d=(t+=e)-(f-=e)}return e=>(e-f)/d},e.labelValues=D,e.quantizeInterpolator=function(e,a){for(var n=new Array(a),c=a+1,f=0;f<a;)n[f]=e(++f/c);return n},e.scale=v,e.scaleCopy=function(e){const a=e.type,n=e.copy();return n.type=a,n},e.scaleFraction=function(e,n,c){var f,t,d,r=c-n;return r&&Number.isFinite(r)?(f=(t=e.type).indexOf("-"),t=f<0?t:t.slice(f+1),d=v(t)().domain([n,c]).range([0,1]),x.forEach(a=>e[a]?d[a](e[a]()):0),d):a.constant(.5)},e.scheme=z,e.tickCount=function(e,n,c){var f;return a.isNumber(n)&&(e.bins&&(n=Math.max(n,e.bins.length)),null!=c&&(n=Math.min(n,Math.floor(a.span(e.domain())/c||1)))),a.isObject(n)&&(f=n.step,n=n.interval),a.isString(n)&&(n=e.type===b?t.timeInterval(n):e.type==o?t.utcInterval(n):a.error("Only time and utc scales accept interval strings."),f&&(n=n.every(f))),n},e.tickFormat=C,e.tickValues=T,e.validTicks=L,Object.defineProperty(e,"__esModule",{value:!0})}));
!function(e,a){"object"==typeof exports&&"undefined"!=typeof module?a(exports,require("vega-util"),require("d3-array"),require("d3-scale"),require("d3-interpolate"),require("vega-time")):"function"==typeof define&&define.amd?define(["exports","vega-util","d3-array","d3-scale","d3-interpolate","vega-time"],a):a((e=e||self).vega={},e.vega,e.d3,e.d3,e.d3,e.vega)}(this,(function(e,a,n,c,f,t){"use strict";function d(e,a,n){var c=e-a+2*n;return e?c>0?c:1:0}const r="log",i="time",b="utc",o="continuous";function l(){var e,a,f=c.scaleOrdinal().unknown(void 0),t=f.domain,r=f.range,i=[0,1],b=!1,o=0,u=0,s=.5;function g(){var c=t().length,f=i[1]<i[0],l=i[f-0],g=i[1-f],p=d(c,o,u);e=(g-l)/(p||1),b&&(e=Math.floor(e)),l+=(g-l-e*(c-o))*s,a=e*(1-o),b&&(l=Math.round(l),a=Math.round(a));var m=n.range(c).map((function(a){return l+e*a}));return r(f?m.reverse():m)}return delete f.unknown,f.domain=function(e){return arguments.length?(t(e),g()):t()},f.range=function(e){return arguments.length?(i=[+e[0],+e[1]],g()):i.slice()},f.rangeRound=function(e){return i=[+e[0],+e[1]],b=!0,g()},f.bandwidth=function(){return a},f.step=function(){return e},f.round=function(e){return arguments.length?(b=!!e,g()):b},f.padding=function(e){return arguments.length?(u=Math.max(0,Math.min(1,e)),o=u,g()):o},f.paddingInner=function(e){return arguments.length?(o=Math.max(0,Math.min(1,e)),g()):o},f.paddingOuter=function(e){return arguments.length?(u=Math.max(0,Math.min(1,e)),g()):u},f.align=function(e){return arguments.length?(s=Math.max(0,Math.min(1,e)),g()):s},f.invertRange=function(e){if(null!=e[0]&&null!=e[1]){var c,f,d,b=+e[0],o=+e[1],l=i[1]<i[0],u=l?r().reverse():r(),s=u.length-1;if(b==b&&o==o&&(o<b&&(d=b,b=o,o=d),!(o<u[0]||b>i[1-l])))return c=Math.max(0,n.bisectRight(u,b)-1),f=b===o?c:n.bisectRight(u,o)-1,b-u[c]>a+1e-10&&++c,l&&(d=c,c=s-f,f=s-d),c>f?void 0:t().slice(c,f+1)}},f.invert=function(e){var a=f.invertRange([e,e]);return a?a[0]:a},f.copy=function(){return l().domain(t()).range(i).round(b).paddingInner(o).paddingOuter(u).align(s)},g()}var u=Array.prototype.map;function s(e){return u.call(e,(function(e){return+e}))}var g=Array.prototype.slice;const p={};function m(e,n,c){const f=function(){var a=n();return a.invertRange||(a.invertRange=a.invert?function(e){return function(a){var n,c=a[0],f=a[1];return f<c&&(n=c,c=f,f=n),[e.invert(c),e.invert(f)]}}(a):a.invertExtent?function(e){return function(a){var n,c,f,t,d=e.range(),r=a[0],i=a[1],b=-1;for(i<r&&(c=r,r=i,i=c),f=0,t=d.length;f<t;++f)d[f]>=r&&d[f]<=i&&(b<0&&(b=f),n=f);if(!(b<0))return r=e.invertExtent(d[b]),i=e.invertExtent(d[n]),[void 0===r[0]?r[1]:r[0],void 0===i[1]?i[0]:i[1]]}}(a):void 0),a.type=e,a};return f.metadata=a.toSet(a.array(c)),f}function h(e,a,n){return arguments.length>1?(p[e]=m(e,a,n),this):v(e)?p[e]:void 0}function v(e){return a.hasOwnProperty(p,e)}function y(e,a){const n=p[e];return n&&n.metadata[a]}function q(e){return y(e,"discrete")}function w(e){return y(e,"discretizing")}function M(e){return y(e,r)}function k(e){return y(e,"temporal")}h("identity",c.scaleIdentity),h("linear",c.scaleLinear,o),h(r,c.scaleLog,[o,r]),h("pow",c.scalePow,o),h("sqrt",c.scaleSqrt,o),h("symlog",c.scaleSymlog,o),h(i,c.scaleTime,[o,"temporal"]),h(b,c.scaleUtc,[o,"temporal"]),h("sequential",c.scaleSequential,[o,"interpolating"]),h("sequential-linear",c.scaleSequential,[o,"interpolating"]),h("sequential-log",c.scaleSequentialLog,[o,"interpolating",r]),h("sequential-pow",c.scaleSequentialPow,[o,"interpolating"]),h("sequential-sqrt",c.scaleSequentialSqrt,[o,"interpolating"]),h("sequential-symlog",c.scaleSequentialSymlog,[o,"interpolating"]),h("diverging-linear",c.scaleDiverging,[o,"interpolating"]),h("diverging-log",c.scaleDivergingLog,[o,"interpolating",r]),h("diverging-pow",c.scaleDivergingPow,[o,"interpolating"]),h("diverging-sqrt",c.scaleDivergingSqrt,[o,"interpolating"]),h("diverging-symlog",c.scaleDivergingSymlog,[o,"interpolating"]),h("quantile",c.scaleQuantile,["discretizing","quantile"]),h("quantize",c.scaleQuantize,"discretizing"),h("threshold",c.scaleThreshold,"discretizing"),h("bin-ordinal",(function e(){var f=[],t=[];function d(e){return null==e||e!=e?void 0:t[(n.bisect(f,e)-1)%t.length]}return d.domain=function(e){return arguments.length?(f=s(e),d):f.slice()},d.range=function(e){return arguments.length?(t=g.call(e),d):t.slice()},d.tickFormat=function(e,n){return c.tickFormat(f[0],a.peek(f),null==e?10:e,n)},d.copy=function(){return e().domain(d.domain()).range(d.range())},d}),["discrete","discretizing"]),h("ordinal",c.scaleOrdinal,"discrete"),h("band",l,"discrete"),h("point",(function(){return function e(a){var n=a.copy;return a.padding=a.paddingOuter,delete a.paddingInner,a.copy=function(){return e(n())},a}(l().paddingInner(1))}),"discrete");const S=["clamp","base","constant","exponent"];function x(e,a,n){return f.piecewise(O(a||"rgb",n),e)}function O(e,a){var n=f[function(e){return"interpolate"+e.toLowerCase().split("-").map((function(e){return e[0].toUpperCase()+e.slice(1)})).join("")}(e)];return null!=a&&n&&n.gamma?n.gamma(a):n}function B(e){for(var a=e.length/6|0,n=new Array(a),c=0;c<a;)n[c]="#"+e.slice(6*c,6*++c);return n}function G(e,a){for(let n in e)R(n,a(e[n]))}const F={};function R(e,a){return e=e&&e.toLowerCase(),arguments.length>1?(F[e]=a,this):F[e]}G({category10:"1f77b4ff7f0e2ca02cd627289467bd8c564be377c27f7f7fbcbd2217becf",category20:"1f77b4aec7e8ff7f0effbb782ca02c98df8ad62728ff98969467bdc5b0d58c564bc49c94e377c2f7b6d27f7f7fc7c7c7bcbd22dbdb8d17becf9edae5",category20b:"393b795254a36b6ecf9c9ede6379398ca252b5cf6bcedb9c8c6d31bd9e39e7ba52e7cb94843c39ad494ad6616be7969c7b4173a55194ce6dbdde9ed6",category20c:"3182bd6baed69ecae1c6dbefe6550dfd8d3cfdae6bfdd0a231a35474c476a1d99bc7e9c0756bb19e9ac8bcbddcdadaeb636363969696bdbdbdd9d9d9",tableau10:"4c78a8f58518e4575672b7b254a24beeca3bb279a2ff9da69d755dbab0ac",tableau20:"4c78a89ecae9f58518ffbf7954a24b88d27ab79a20f2cf5b43989483bcb6e45756ff9d9879706ebab0acd67195fcbfd2b279a2d6a5c99e765fd8b5a5",accent:"7fc97fbeaed4fdc086ffff99386cb0f0027fbf5b17666666",dark2:"1b9e77d95f027570b3e7298a66a61ee6ab02a6761d666666",paired:"a6cee31f78b4b2df8a33a02cfb9a99e31a1cfdbf6fff7f00cab2d66a3d9affff99b15928",pastel1:"fbb4aeb3cde3ccebc5decbe4fed9a6ffffcce5d8bdfddaecf2f2f2",pastel2:"b3e2cdfdcdaccbd5e8f4cae4e6f5c9fff2aef1e2cccccccc",set1:"e41a1c377eb84daf4a984ea3ff7f00ffff33a65628f781bf999999",set2:"66c2a5fc8d628da0cbe78ac3a6d854ffd92fe5c494b3b3b3",set3:"8dd3c7ffffb3bebadafb807280b1d3fdb462b3de69fccde5d9d9d9bc80bdccebc5ffed6f"},B),G({blues:"cfe1f2bed8eca8cee58fc1de74b2d75ba3cf4592c63181bd206fb2125ca40a4a90",greens:"d3eecdc0e6baabdda594d3917bc77d60ba6c46ab5e329a512089430e7735036429",greys:"e2e2e2d4d4d4c4c4c4b1b1b19d9d9d8888887575756262624d4d4d3535351e1e1e",oranges:"fdd8b3fdc998fdb87bfda55efc9244f87f2cf06b18e4580bd14904b93d029f3303",purples:"e2e1efd4d4e8c4c5e0b4b3d6a3a0cc928ec3827cb97566ae684ea25c3696501f8c",reds:"fdc9b4fcb49afc9e80fc8767fa7051f6573fec3f2fdc2a25c81b1db21218970b13",blueGreen:"d5efedc1e8e0a7ddd18bd2be70c6a958ba9144ad77319c5d2089460e7736036429",bluePurple:"ccddecbad0e4a8c2dd9ab0d4919cc98d85be8b6db28a55a6873c99822287730f71",greenBlue:"d3eecec5e8c3b1e1bb9bd8bb82cec269c2ca51b2cd3c9fc7288abd1675b10b60a1",orangeRed:"fddcaffdcf9bfdc18afdad77fb9562f67d53ee6545e24932d32d1ebf130da70403",purpleBlue:"dbdaebc8cee4b1c3de97b7d87bacd15b9fc93a90c01e7fb70b70ab056199045281",purpleBlueGreen:"dbd8eac8cee4b0c3de93b7d872acd1549fc83892bb1c88a3097f8702736b016353",purpleRed:"dcc9e2d3b3d7ce9eccd186c0da6bb2e14da0e23189d91e6fc61159ab07498f023a",redPurple:"fccfccfcbec0faa9b8f98faff571a5ec539ddb3695c41b8aa908808d0179700174",yellowGreen:"e4f4acd1eca0b9e2949ed68880c97c62bb6e47aa5e3297502083440e723b036034",yellowOrangeBrown:"feeaa1fedd84fecc63feb746fca031f68921eb7215db5e0bc54c05ab3d038f3204",yellowOrangeRed:"fee087fed16ffebd59fea849fd903efc7335f9522bee3423de1b20ca0b22af0225",blueOrange:"134b852f78b35da2cb9dcae1d2e5eff2f0ebfce0bafbbf74e8932fc5690d994a07",brownBlueGreen:"704108a0651ac79548e3c78af3e6c6eef1eac9e9e48ed1c74da79e187a72025147",purpleGreen:"5b1667834792a67fb6c9aed3e6d6e8eff0efd9efd5aedda971bb75368e490e5e29",purpleOrange:"4114696647968f83b7b9b4d6dadbebf3eeeafce0bafbbf74e8932fc5690d994a07",redBlue:"8c0d25bf363adf745ef4ae91fbdbc9f2efeed2e5ef9dcae15da2cb2f78b3134b85",redGrey:"8c0d25bf363adf745ef4ae91fcdccbfaf4f1e2e2e2c0c0c0969696646464343434",yellowGreenBlue:"eff9bddbf1b4bde5b594d5b969c5be45b4c22c9ec02182b82163aa23479c1c3185",redYellowBlue:"a50026d4322cf16e43fcac64fedd90faf8c1dcf1ecabd6e875abd04a74b4313695",redYellowGreen:"a50026d4322cf16e43fcac63fedd8df9f7aed7ee8ea4d86e64bc6122964f006837",pinkYellowGreen:"8e0152c0267edd72adf0b3d6faddedf5f3efe1f2cab6de8780bb474f9125276419",spectral:"9e0142d13c4bf0704afcac63fedd8dfbf8b0e0f3a1a9dda269bda94288b55e4fa2",viridis:"440154470e61481a6c482575472f7d443a834144873d4e8a39568c35608d31688e2d708e2a788e27818e23888e21918d1f988b1fa08822a8842ab07f35b77943bf7154c56866cc5d7ad1518fd744a5db36bcdf27d2e21be9e51afde725",magma:"0000040404130b0924150e3720114b2c11603b0f704a107957157e651a80721f817f24828c29819a2e80a8327db6377ac43c75d1426fde4968e95462f1605df76f5cfa7f5efc8f65fe9f6dfeaf78febf84fece91fddea0fcedaffcfdbf",inferno:"0000040403130c0826170c3b240c4f330a5f420a68500d6c5d126e6b176e781c6d86216b932667a12b62ae305cbb3755c73e4cd24644dd513ae65c30ed6925f3771af8850ffb9506fca50afcb519fac62df6d645f2e661f3f484fcffa4",plasma:"0d088723069033059742039d5002a25d01a66a00a87801a88405a7900da49c179ea72198b12a90ba3488c33d80cb4779d35171da5a69e16462e76e5bed7953f2834cf68f44fa9a3dfca636fdb32ffec029fcce25f9dc24f5ea27f0f921",rainbow:"6e40aa883eb1a43db3bf3cafd83fa4ee4395fe4b83ff576eff6659ff7847ff8c38f3a130e2b72fcfcc36bee044aff05b8ff4576ff65b52f6673af27828ea8d1ddfa319d0b81cbecb23abd82f96e03d82e14c6edb5a5dd0664dbf6e40aa",sinebow:"ff4040fc582af47218e78d0bd5a703bfbf00a7d5038de70b72f41858fc2a40ff402afc5818f4720be78d03d5a700bfbf03a7d50b8de71872f42a58fc4040ff582afc7218f48d0be7a703d5bf00bfd503a7e70b8df41872fc2a58ff4040",browns:"eedbbdecca96e9b97ae4a865dc9856d18954c7784cc0673fb85536ad44339f3632",tealBlues:"bce4d89dd3d181c3cb65b3c245a2b9368fae347da0306a932c5985",teals:"bbdfdfa2d4d58ac9c975bcbb61b0af4da5a43799982b8b8c1e7f7f127273006667",warmGreys:"dcd4d0cec5c1c0b8b4b3aaa7a59c9998908c8b827f7e7673726866665c5a59504e",goldGreen:"f4d166d5ca60b6c35c98bb597cb25760a6564b9c533f8f4f33834a257740146c36",goldOrange:"f4d166f8be5cf8aa4cf5983bf3852aef701be2621fd65322c54923b142239e3a26",goldRed:"f4d166f6be59f9aa51fc964ef6834bee734ae56249db5247cf4244c43141b71d3e",lightGreyRed:"efe9e6e1dad7d5cbc8c8bdb9bbaea9cd967ddc7b43e15f19df4011dc000b",lightGreyTeal:"e4eaead6dcddc8ced2b7c2c7a6b4bc64b0bf22a6c32295c11f85be1876bc",lightMulti:"e0f1f2c4e9d0b0de9fd0e181f6e072f6c053f3993ef77440ef4a3c",lightOrange:"f2e7daf7d5baf9c499fab184fa9c73f68967ef7860e8645bde515bd43d5b",lightTealBlue:"e3e9e0c0dccf9aceca7abfc859afc0389fb9328dad2f7ca0276b95255988",darkBlue:"3232322d46681a5c930074af008cbf05a7ce25c0dd38daed50f3faffffff",darkGold:"3c3c3c584b37725e348c7631ae8b2bcfa424ecc31ef9de30fff184ffffff",darkGreen:"3a3a3a215748006f4d048942489e4276b340a6c63dd2d836ffeb2cffffaa",darkMulti:"3737371f5287197d8c29a86995ce3fffe800ffffff",darkRed:"3434347036339e3c38cc4037e75d1eec8620eeab29f0ce32ffeb2c"},e=>x(B(e)));const z=e=>a.isArray(e)?e.map(e=>String(e)):String(e),I=(e,a)=>e[1]-a[1],L=(e,a)=>a[1]-e[1];function T(e,n,c){let f=e.range(),t=f[0],d=a.peek(f),r=I;if(t>d&&(f=d,d=t,t=f,r=L),t=Math.floor(t),d=Math.ceil(d),n=n.map(a=>[a,e(a)]).filter(e=>t<=e[1]&&e[1]<=d).sort(r).map(e=>e[0]),c>0&&n.length>1){const e=[n[0],a.peek(n)];for(;n.length>c&&n.length>=3;)n=n.filter((e,a)=>!(a%2));n.length<3&&(n=e)}return n}function C(e,a){return e.bins?T(e,e.bins):e.ticks?e.ticks(a):e.domain()}function P(e,a,n,c,f,t){var d=a.type;let r=z;if(d===i||f===i)r=e.timeFormat(c);else if(d===b||f===b)r=e.utcFormat(c);else if(M(d)){const f=e.formatFloat(c);if(t||a.bins)r=f;else{const e=D(a,n,!1);r=a=>e(a)?f(a):""}}else if(a.tickFormat){const f=a.domain();r=e.formatSpan(f[0],f[f.length-1],n,c)}else c&&(r=e.format(c));return r}function D(e,a,n){const c=C(e,a),f=e.base(),t=Math.log(f),d=Math.max(1,f*a/c.length),r=e=>{let a=e/Math.pow(f,Math.round(Math.log(e)/t));return a*f<f-.5&&(a*=f),a<=d};return n?c.filter(r):r}const j={quantile:"quantiles",quantize:"thresholds",threshold:"domain"},A={quantile:"quantiles",quantize:"domain"};function $(e,n){return e.bins?function(e){const n=e.slice(0,-1);return n.max=a.peek(e),n}(e.bins):e.type===r?D(e,n,!0):j[e.type]?function(e){const a=[-1/0].concat(e);return a.max=1/0,a}(e[j[e.type]]()):C(e,n)}function Q(e,a,n,c,f,t,d){const r=A[a.type]&&t!==i&&t!==b?function(e,a,n){var c,f=a[A[a.type]](),t=f.length,d=t>1?f[1]-f[0]:f[0];for(c=1;c<t;++c)d=Math.min(d,f[c]-f[c-1]);return e.formatSpan(0,d,30,n)}(e,a,f):P(e,a,n,f,t,d);return"symbol"===c&&function(e){return j[e.type]||e.bins}(a)?function(e){return(a,n,c)=>{var f=Y(c[n+1],Y(c.max,1/0)),t=E(a,e),d=E(f,e);return t&&d?t+" – "+d:d?"< "+d:"≥ "+t}}(r):"discrete"===c?function(e){return(a,n)=>n?e(a):null}(r):function(e){return a=>e(a)}(r)}function Y(e,a){return null!=e?e:a}function E(e,a){return Number.isFinite(e)?a(e):null}Object.defineProperty(e,"scaleImplicit",{enumerable:!0,get:function(){return c.scaleImplicit}}),e.Band="band",e.BinOrdinal="bin-ordinal",e.DiscreteLegend="discrete",e.Diverging="diverging",e.GradientLegend="gradient",e.Identity="identity",e.Linear="linear",e.Log=r,e.Ordinal="ordinal",e.Point="point",e.Pow="pow",e.Quantile="quantile",e.Quantize="quantize",e.Sequential="sequential",e.Sqrt="sqrt",e.SymbolLegend="symbol",e.Symlog="symlog",e.Threshold="threshold",e.Time=i,e.UTC=b,e.bandSpace=d,e.domainCaption=function(e,n,c){c=c||{};const f=Math.max(3,c.maxlen||7),t=function(e,n,c,f){const t=f||n.type;return a.isString(c)&&k(t)&&(c=c.replace(/%a/g,"%A").replace(/%b/g,"%B")),c||t!==i?c||t!==b?Q(e,n,5,null,c,f,!0):e.utcFormat("%A, %d %B %Y, %X UTC"):e.timeFormat("%A, %d %B %Y, %X")}(e,n,c.format,c.formatType);if(w(n.type)){const e=$(n).slice(1).map(t),a=e.length;return`${a} boundar${1===a?"y":"ies"}: ${e.join(", ")}`}if(q(n.type)){const e=n.domain(),a=e.length;return`${a} value${1===a?"":"s"}: ${a>f?e.slice(0,f-2).map(t).join(", ")+", ending with "+e.slice(-1).map(t):e.map(t).join(", ")}`}{const e=n.domain();return`values from ${t(e[0])} to ${t(a.peek(e))}`}},e.interpolate=O,e.interpolateColors=x,e.interpolateRange=function(e,n){var c=n[0],f=a.peek(n)-c;return function(a){return e(c+a*f)}},e.isContinuous=function(e){return y(e,o)},e.isDiscrete=q,e.isDiscretizing=w,e.isInterpolating=function(e){return y(e,"interpolating")},e.isLogarithmic=M,e.isQuantile=function(e){return y(e,"quantile")},e.isTemporal=k,e.isValidScaleType=v,e.labelFormat=Q,e.labelFraction=function(e){var n=e.domain(),c=n.length-1,f=+n[0],t=+a.peek(n),d=t-f;if("threshold"===e.type){const e=c?d/c:.1;d=(t+=e)-(f-=e)}return e=>(e-f)/d},e.labelValues=$,e.quantizeInterpolator=function(e,a){for(var n=new Array(a),c=a+1,f=0;f<a;)n[f]=e(++f/c);return n},e.scale=h,e.scaleCopy=function(e){const a=e.type,n=e.copy();return n.type=a,n},e.scaleFraction=function(e,n,c){var f,t,d,r=c-n;return r&&Number.isFinite(r)?(f=(t=e.type).indexOf("-"),t=f<0?t:t.slice(f+1),d=h(t)().domain([n,c]).range([0,1]),S.forEach(a=>e[a]?d[a](e[a]()):0),d):a.constant(.5)},e.scheme=R,e.tickCount=function(e,n,c){var f;return a.isNumber(n)&&(e.bins&&(n=Math.max(n,e.bins.length)),null!=c&&(n=Math.min(n,Math.floor(a.span(e.domain())/c||1)))),a.isObject(n)&&(f=n.step,n=n.interval),a.isString(n)&&(n=e.type===i?t.timeInterval(n):e.type==b?t.utcInterval(n):a.error("Only time and utc scales accept interval strings."),f&&(n=n.every(f))),n},e.tickFormat=P,e.tickValues=C,e.validTicks=T,Object.defineProperty(e,"__esModule",{value:!0})}));
{
"name": "vega-scale",
"version": "6.1.0",
"version": "7.0.0",
"description": "Scales and color schemes for visual encoding.",

@@ -18,3 +18,3 @@ "keywords": [

"scripts": {
"rollup": "rollup -g d3-array:d3,d3-format:d3,d3-interpolate:d3,d3-scale:d3,vega-time:vega,vega-util:vega -f umd -n vega -o build/vega-scale.js -- index.js",
"rollup": "rollup -g d3-array:d3,d3-interpolate:d3,d3-scale:d3,vega-time:vega,vega-util:vega -f umd -n vega -o build/vega-scale.js -- index.js",
"prebuild": "rimraf build && mkdir build",

@@ -30,9 +30,8 @@ "build": "yarn rollup",

"d3-array": "^2.4.0",
"d3-format": "^1.4.4",
"d3-interpolate": "^1.4.0",
"d3-scale": "^3.2.1",
"vega-time": "^1.1.0",
"vega-util": "^1.13.2"
"vega-time": "^2.0.0",
"vega-util": "^1.14.0"
},
"gitHead": "35e31c5c6b54db9dc3a577b5adad8d15ec274d32"
"gitHead": "48c85218f2202242171aa569f2dca0f53cf2b51f"
}

@@ -103,2 +103,2 @@ # vega-scale

Given an *interpolator* function, returns *count* evenly-spaced samples. This method is particularly useful for generating a discrete color scheme from a continuous color interpolator.
Given an *interpolator* function, returns *count* evenly-spaced samples. This method is useful for generating a discrete color scheme from a continuous color interpolator.
import {labelFormat, labelValues} from './labels';
import {Time, UTC} from './scales/types';
import {isDiscrete, isDiscretizing, isTemporal} from './scales';
import {timeFormat, utcFormat} from 'vega-time';
import {isString, peek} from 'vega-util';
function format(scale, specifier, formatType) {
function format(locale, scale, specifier, formatType) {
const type = formatType || scale.type;

@@ -15,11 +14,11 @@

return !specifier && type === Time ? timeFormat('%A, %d %B %Y, %X')
: !specifier && type === UTC ? utcFormat('%A, %d %B %Y, %X UTC')
: labelFormat(scale, 5, null, specifier, formatType, true);
return !specifier && type === Time ? locale.timeFormat('%A, %d %B %Y, %X')
: !specifier && type === UTC ? locale.utcFormat('%A, %d %B %Y, %X UTC')
: labelFormat(locale, scale, 5, null, specifier, formatType, true);
}
export function domainCaption(scale, opt) {
export function domainCaption(locale, scale, opt) {
opt = opt || {};
const max = Math.max(3, opt.maxlen || 7),
fmt = format(scale, opt.format, opt.formatType);
fmt = format(locale, scale, opt.format, opt.formatType);

@@ -26,0 +25,0 @@ // if scale breaks domain into bins, describe boundaries

import {DiscreteLegend, SymbolLegend} from './legend-types';
import {Log, Quantile, Quantize, Threshold, Time, UTC} from './scales/types';
import {tickFormat, tickValues} from './ticks';
import {tickFormat, tickLog, tickValues} from './ticks';
import {peek} from 'vega-util';
import {tickFormat as spanFormat} from 'd3-scale';

@@ -20,3 +19,3 @@ const symbols = {

return scale.bins ? binValues(scale.bins)
: scale.type === Log ? logValues(scale, count)
: scale.type === Log ? tickLog(scale, count, true)
: symbols[scale.type] ? thresholdValues(scale[symbols[scale.type]]())

@@ -26,17 +25,3 @@ : tickValues(scale, count);

function logValues(scale, count) {
var ticks = tickValues(scale, count),
base = scale.base(),
logb = Math.log(base),
k = Math.max(1, base * count / ticks.length);
// apply d3-scale's log format filter criteria
return ticks.filter(d => {
var i = d / Math.pow(base, Math.round(Math.log(d) / logb));
if (i * base < base - 0.5) i *= base;
return i <= k;
});
}
export function thresholdFormat(scale, specifier) {
export function thresholdFormat(locale, scale, specifier) {
var _ = scale[formats[scale.type]](),

@@ -51,3 +36,3 @@ n = _.length,

// tickCount = 3 ticks times 10 for increased resolution
return spanFormat(0, d, 3 * 10, specifier);
return locale.formatSpan(0, d, 3 * 10, specifier);
}

@@ -71,6 +56,6 @@

export function labelFormat(scale, count, type, specifier, formatType, noSkip) {
export function labelFormat(locale, scale, count, type, specifier, formatType, noSkip) {
const format = formats[scale.type] && formatType !== Time && formatType !== UTC
? thresholdFormat(scale, specifier)
: tickFormat(scale, count, specifier, formatType, noSkip);
? thresholdFormat(locale, scale, specifier)
: tickFormat(locale, scale, count, specifier, formatType, noSkip);

@@ -77,0 +62,0 @@ return type === SymbolLegend && isDiscreteRange(scale) ? formatRange(format)

import {isLogarithmic} from './scales';
import {Time, UTC} from './scales/types';
import {timeFormat, timeInterval, utcFormat, utcInterval} from 'vega-time';
import {timeInterval, utcInterval} from 'vega-time';
import {error, isArray, isNumber, isObject, isString, peek, span} from 'vega-util';
import {formatSpecifier, format as numberFormat} from 'd3-format';

@@ -11,2 +10,5 @@ const defaultFormatter = value => isArray(value)

const ascending = (a, b) => a[1] - b[1];
const descending = (a, b) => b[1] - a[1];
/**

@@ -60,3 +62,4 @@ * Determine the tick count or interval function.

lo = range[0],
hi = peek(range);
hi = peek(range),
cmp = ascending;

@@ -67,2 +70,3 @@ if (lo > hi) {

lo = range;
cmp = descending;
}

@@ -73,6 +77,8 @@

ticks = ticks.filter(v => {
v = scale(v);
return lo <= v && v <= hi;
});
// filter ticks to valid values within the range
// additionally sort ticks in range order (#2579)
ticks = ticks.map(v => [v, scale(v)])
.filter(_ => lo <= _[1] && _[1] <= hi)
.sort(cmp)
.map(_ => _[0]);

@@ -122,14 +128,29 @@ if (count > 0 && ticks.length > 1) {

*/
export function tickFormat(scale, count, specifier, formatType, noSkip) {
var type = scale.type,
format = (type === Time || formatType === Time) ? timeFormat(specifier)
: (type === UTC || formatType === UTC) ? utcFormat(specifier)
: scale.tickFormat ? scale.tickFormat(count, specifier)
: specifier ? numberFormat(specifier)
: defaultFormatter;
export function tickFormat(locale, scale, count, specifier, formatType, noSkip) {
var type = scale.type;
let format = defaultFormatter;
if (isLogarithmic(type)) {
var logfmt = variablePrecision(specifier);
format = noSkip || scale.bins ? logfmt : filter(format, logfmt);
if (type === Time || formatType === Time) {
format = locale.timeFormat(specifier);
}
else if (type === UTC || formatType === UTC) {
format = locale.utcFormat(specifier);
}
else if (isLogarithmic(type)) {
const varfmt = locale.formatFloat(specifier);
if (noSkip || scale.bins) {
format = varfmt;
} else {
const test = tickLog(scale, count, false);
format = _ => test(_) ? varfmt(_) : '';
}
}
else if (scale.tickFormat) {
// if d3 scale has tickFormat, it must be continuous
const d = scale.domain();
format = locale.formatSpan(d[0], d[d.length - 1], count, specifier);
}
else if (specifier) {
format = locale.format(specifier);
}

@@ -139,47 +160,16 @@ return format;

function filter(sourceFormat, targetFormat) {
return _ => sourceFormat(_) ? targetFormat(_) : '';
}
export function tickLog(scale, count, values) {
const ticks = tickValues(scale, count),
base = scale.base(),
logb = Math.log(base),
k = Math.max(1, base * count / ticks.length);
function variablePrecision(specifier) {
var s = formatSpecifier(specifier || ',');
if (s.precision == null) {
s.precision = 12;
switch (s.type) {
case '%': s.precision -= 2; break;
case 'e': s.precision -= 1; break;
}
return trimZeroes(
numberFormat(s), // number format
numberFormat('.1f')(1)[1] // decimal point character
);
} else {
return numberFormat(s);
}
}
function trimZeroes(format, decimalChar) {
return x => {
var str = format(x),
dec = str.indexOf(decimalChar),
idx, end;
if (dec < 0) return str;
idx = rightmostDigit(str, dec);
end = idx < str.length ? str.slice(idx) : '';
while (--idx > dec) if (str[idx] !== '0') { ++idx; break; }
return str.slice(0, idx) + end;
// apply d3-scale's log format filter criteria
const test = d => {
let i = d / Math.pow(base, Math.round(Math.log(d) / logb));
if (i * base < base - 0.5) i *= base;
return i <= k;
};
}
function rightmostDigit(str, dec) {
var i = str.lastIndexOf('e'), c;
if (i > 0) return i;
for (i=str.length; --i > dec;) {
c = str.charCodeAt(i);
if (c >= 48 && c <= 57) return i + 1; // is digit
}
return values ? ticks.filter(test) : test;
}
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