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

vega-encode

Package Overview
Dependencies
Maintainers
1
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vega-encode - npm Package Compare versions

Comparing version 4.1.1 to 4.1.2

60

build/vega-encode.js

@@ -112,3 +112,3 @@ (function (global, factory) {

* @param {*} [count] - The approximate number of desired ticks.
* @param {string} [specifier] - The format specifier. Must be a legal d3 4.0
* @param {string} [specifier] - The format specifier. Must be a legal d3
* specifier string (see https://github.com/d3/d3-format#formatSpecifier).

@@ -413,30 +413,33 @@ * @return {function(*):string} - The generated label formatter.

const symbols = {
[vegaScale.Quantile]: quantileSymbols,
[vegaScale.Quantize]: quantizeSymbols,
[vegaScale.Threshold]: thresholdSymbols
[vegaScale.Quantile]: 'quantiles',
[vegaScale.Quantize]: 'thresholds',
[vegaScale.Threshold]: 'domain'
};
const formats = {
[vegaScale.Quantile]: 'quantiles',
[vegaScale.Quantize]: 'domain'
};
function labelValues(scale, count) {
return scale.bins ? binValues$1(scale.bins.slice())
: symbols[scale.type] ? symbols[scale.type](scale)
return scale.bins ? binValues$1(scale.bins)
: symbols[scale.type] ? thresholdValues(scale[symbols[scale.type]]())
: tickValues(scale, count);
}
function quantizeSymbols(scale) {
var domain = scale.domain(),
x0 = domain[0],
x1 = vegaUtil.peek(domain),
n = scale.range().length,
values = new Array(n),
i = 0;
function thresholdFormat(scale, specifier) {
var _ = scale[formats[scale.type]](),
n = _.length,
d = n > 1 ? _[1] - _[0] : _[0], i;
values[0] = -Infinity;
while (++i < n) values[i] = (i * x1 - (i - n) * x0) / n;
values.max = +Infinity;
for (i=1; i<n; ++i) {
d = Math.min(d, _[i] - _[i-1]);
}
return values;
// 3 ticks times 10 for increased resolution
return vegaScale.tickFormat(0, d, 3 * 10, specifier);
}
function quantileSymbols(scale) {
var values = [-Infinity].concat(scale.quantiles());
function thresholdValues(thresholds) {
const values = [-Infinity].concat(thresholds);
values.max = +Infinity;

@@ -447,5 +450,5 @@

function thresholdSymbols(scale) {
var values = [-Infinity].concat(scale.domain());
values.max = +Infinity;
function binValues$1(bins) {
const values = bins.slice(0, -1);
values.max = vegaUtil.peek(bins);

@@ -455,7 +458,2 @@ return values;

function binValues$1(bins) {
bins.max = bins.pop();
return bins;
}
function isDiscreteRange(scale) {

@@ -465,3 +463,6 @@ return symbols[scale.type] || scale.bins;

function labelFormat(scale, format, type) {
function labelFormat(scale, count, type, specifier) {
const format = formats[scale.type] ? thresholdFormat(scale, specifier)
: tickFormat(scale, count, specifier);
return type === Symbols && isDiscreteRange(scale) ? formatRange(format)

@@ -548,7 +549,6 @@ : type === Discrete ? formatDiscrete(format)

count = tickCount(scale, _.count == null ? 5 : _.count, _.minstep),
format = _.format || tickFormat(scale, count, _.formatSpecifier),
format = _.format || labelFormat(scale, count, type, _.formatSpecifier),
values = _.values || labelValues(scale, count, type),
domain, fraction, size, offset;
format = labelFormat(scale, format, type);
if (items) out.rem = items;

@@ -555,0 +555,0 @@

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

!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("vega-scale"),require("vega-util"),require("d3-format"),require("vega-dataflow"),require("d3-array"),require("d3-interpolate")):"function"==typeof define&&define.amd?define(["exports","vega-scale","vega-util","d3-format","vega-dataflow","d3-array","d3-interpolate"],n):n(((e=e||self).vega=e.vega||{},e.vega.transforms={}),e.vega,e.vega,e.d3,e.vega,e.d3,e.d3)}(this,function(e,n,t,r,i,a,o){"use strict";function u(e,r,i){var a;return t.isNumber(r)&&null!=i&&(r=Math.min(r,~~(t.span(e.domain())/i)||1)),t.isObject(r)&&(a=r.step,r=r.interval),t.isString(r)&&(r=n.timeInterval(r,e.type)||t.error("Only time and utc scales accept interval strings."),a&&(r=r.every(a))),r}function l(e,n,r){var i=e.range(),a=Math.floor(i[0]),o=Math.ceil(t.peek(i));if(a>o&&(i=o,o=a,a=i),n=n.filter(function(n){return n=e(n),a<=n&&n<=o}),r>0&&n.length>1){for(var u=[n[0],t.peek(n)];n.length>r&&n.length>=3;)n=n.filter(function(e,n){return!(n%2)});n.length<3&&(n=u)}return n}function s(e,n){return e.bins?l(e,function(e,n){var t=e.length,r=~~(t/(n||t));return r<2?e.slice():e.filter(function(e,n){return!(n%r)})}(e.bins,n)):e.ticks?e.ticks(n):e.domain()}function f(e,t,i){var a,o,u=e.tickFormat?e.tickFormat(t,i):i?r.format(i):String;if(n.isLogarithmic(e.type)){var l=function(e){var n=r.formatSpecifier(e||",");if(null==n.precision){switch(n.precision=12,n.type){case"%":n.precision-=2;break;case"e":n.precision-=1}return t=r.format(n),i=r.format(".1f")(1)[1],function(e){var n,r,a=t(e),o=a.indexOf(i);if(o<0)return a;for(n=function(e,n){var t,r=e.lastIndexOf("e");if(r>0)return r;for(r=e.length;--r>n;)if((t=e.charCodeAt(r))>=48&&t<=57)return r+1}(a,o),r=n<a.length?a.slice(n):"";--n>o;)if("0"!==a[n]){++n;break}return a.slice(0,n)+r}}return r.format(n);var t,i}(i);u=e.bins?l:(a=u,o=l,function(e){return a(e)?o(e):""})}return u}function c(e){i.Transform.call(this,null,e)}function d(e){i.Transform.call(this,null,e)}function m(){return i.ingest({})}function p(e){return e.exit}function h(e){i.Transform.call(this,null,e)}t.inherits(c,i.Transform).transform=function(e,n){if(this.value&&!e.modified())return n.StopPropagation;var t=n.fork(n.NO_SOURCE|n.NO_FIELDS),r=this.value,a=e.scale,o=u(a,null==e.count?e.values?e.values.length:10:e.count,e.minstep),c=e.format||f(a,o,e.formatSpecifier),d=e.values?l(a,e.values,o):s(a,o);return r&&(t.rem=r),r=d.map(function(e,n){return i.ingest({index:n/(d.length-1),value:e,label:c(e)})}),e.extra&&r.length&&r.push(i.ingest({index:-1,extra:{value:r[0].value},label:""})),t.source=r,t.add=r,this.value=r,t},t.inherits(d,i.Transform).transform=function(e,n){var r=n.dataflow,a=n.fork(n.NO_SOURCE|n.NO_FIELDS),o=e.item||m,u=e.key||i.tupleid,l=this.value;return t.isArray(a.encode)&&(a.encode=null),l&&(e.modified("key")||n.modified(u))&&t.error("DataJoin does not support modified key function or fields."),l||(n=n.addAll(),this.value=l=t.fastmap().test(p),l.lookup=function(e){return l.get(u(e))}),n.visit(n.ADD,function(e){var n=u(e),t=l.get(n);t?t.exit?(l.empty--,a.add.push(t)):a.mod.push(t):(l.set(n,t=o(e)),a.add.push(t)),t.datum=e,t.exit=!1}),n.visit(n.MOD,function(e){var n=u(e),t=l.get(n);t&&(t.datum=e,a.mod.push(t))}),n.visit(n.REM,function(e){var n=u(e),t=l.get(n);e!==t.datum||t.exit||(a.rem.push(t),t.exit=!0,++l.empty)}),n.changed(n.ADD_MOD)&&a.modifies("datum"),e.clean&&l.empty>r.cleanThreshold&&r.runAfter(l.clean),a},t.inherits(h,i.Transform).transform=function(e,n){var r=n.fork(n.ADD_REM),i=e.encoders,a=n.encode;if(t.isArray(a)){if(!r.changed()&&!a.every(function(e){return i[e]}))return n.StopPropagation;a=a[0],r.encode=null}var o="enter"===a,u=i.update||t.falsy,l=i.enter||t.falsy,s=i.exit||t.falsy,f=(a&&!o?i[a]:u)||t.falsy;if(n.changed(n.ADD)&&(n.visit(n.ADD,function(n){l(n,e),u(n,e),f!==t.falsy&&f!==u&&f(n,e)}),r.modifies(l.output),r.modifies(u.output),f!==t.falsy&&f!==u&&r.modifies(f.output)),n.changed(n.REM)&&s!==t.falsy&&(n.visit(n.REM,function(n){s(n,e)}),r.modifies(s.output)),o||f!==t.falsy){var c=n.MOD|(e.modified()?n.REFLOW:0);o?(n.visit(c,function(n){var t=l(n,e);(f(n,e)||t)&&r.mod.push(n)}),r.mod.length&&r.modifies(l.output)):n.visit(c,function(n){f(n,e)&&r.mod.push(n)}),r.mod.length&&r.modifies(f.output)}return r.changed()?r:n.StopPropagation};var g="symbol",v="discrete";const y={[n.Quantile]:function(e){var n=[-1/0].concat(e.quantiles());return n.max=1/0,n},[n.Quantize]:function(e){var n=e.domain(),r=n[0],i=t.peek(n),a=e.range().length,o=new Array(a),u=0;o[0]=-1/0;for(;++u<a;)o[u]=(u*i-(u-a)*r)/a;return o.max=1/0,o},[n.Threshold]:function(e){var n=[-1/0].concat(e.domain());return n.max=1/0,n}};function M(e,n,t){return t===g&&function(e){return y[e.type]||e.bins}(e)?function(e){return function(n,t,r){var i=r[t+1]||r.max||1/0,a=x(n,e),o=x(i,e);return a&&o?a+"–"+o:o?"< "+o:"≥ "+a}}(n):t===v?function(e){return function(n,t){return t?e(n):null}}(n):function(e){return function(n){return e(n)}}(n)}function x(e,n){return isFinite(e)?n(e):null}function b(e){i.Transform.call(this,[],e)}t.inherits(b,i.Transform).transform=function(e,r){if(null!=this.value&&!e.modified())return r.StopPropagation;var a,o,l,c,d=r.fork(r.NO_SOURCE|r.NO_FIELDS),m=this.value,p=e.type||g,h=e.scale,v=u(h,null==e.count?5:e.count,e.minstep),x=e.format||f(h,v,e.formatSpecifier),b=e.values||function(e,n){return e.bins?((t=e.bins.slice()).max=t.pop(),t):y[e.type]?y[e.type](e):s(e,n);var t}(h,v);return x=M(h,x,p),m&&(d.rem=m),p===g?(t.isFunction(l=e.size)?(e.values||0!==h(b[0])||(b=b.slice(1)),c=b.reduce(function(n,t){return Math.max(n,l(t,e))},0)):l=t.constant(c=l||8),m=b.map(function(n,t){return i.ingest({index:t,label:x(n,t,b),value:n,offset:c,size:l(n,e)})})):"gradient"===p?(a=h.domain(),o=n.scaleFraction(h,a[0],t.peek(a)),b.length<3&&!e.values&&a[0]!==t.peek(a)&&(b=[a[0],t.peek(a)]),m=b.map(function(e,n){return i.ingest({index:n,label:x(e,n,b),value:e,perc:o(e)})})):(l=b.length-1,o=function(e){var r=e.domain(),i=r.length-1,a=+r[0],o=+t.peek(r),u=o-a;if(e.type===n.Threshold){var l=i?u/i:.1;u=(o+=l)-(a-=l)}return function(e){return(e-a)/u}}(h),m=b.map(function(e,n){return i.ingest({index:n,label:x(e,n,b),value:e,perc:n?o(e):0,perc2:n===l?1:o(b[n+1])})})),d.source=m,d.add=m,this.value=m,d};var S=t.fastmap({line:w,"line-radial":function(e,n,t,r){return w(n*Math.cos(e),n*Math.sin(e),r*Math.cos(t),r*Math.sin(t))},arc:z,"arc-radial":function(e,n,t,r){return z(n*Math.cos(e),n*Math.sin(e),r*Math.cos(t),r*Math.sin(t))},curve:L,"curve-radial":function(e,n,t,r){return L(n*Math.cos(e),n*Math.sin(e),r*Math.cos(t),r*Math.sin(t))},"orthogonal-horizontal":function(e,n,t,r){return"M"+e+","+n+"V"+r+"H"+t},"orthogonal-vertical":function(e,n,t,r){return"M"+e+","+n+"H"+t+"V"+r},"orthogonal-radial":function(e,n,t,r){var i=Math.cos(e),a=Math.sin(e),o=Math.cos(t),u=Math.sin(t),l=Math.abs(t-e)>Math.PI?t<=e:t>e;return"M"+n*i+","+n*a+"A"+n+","+n+" 0 0,"+(l?1:0)+" "+n*o+","+n*u+"L"+r*o+","+r*u},"diagonal-horizontal":function(e,n,t,r){var i=(e+t)/2;return"M"+e+","+n+"C"+i+","+n+" "+i+","+r+" "+t+","+r},"diagonal-vertical":function(e,n,t,r){var i=(n+r)/2;return"M"+e+","+n+"C"+e+","+i+" "+t+","+i+" "+t+","+r},"diagonal-radial":function(e,n,t,r){var i=Math.cos(e),a=Math.sin(e),o=Math.cos(t),u=Math.sin(t),l=(n+r)/2;return"M"+n*i+","+n*a+"C"+l*i+","+l*a+" "+l*o+","+l*u+" "+r*o+","+r*u}});function k(e){return e.source.x}function O(e){return e.source.y}function D(e){return e.target.x}function A(e){return e.target.y}function T(e){i.Transform.call(this,{},e)}function w(e,n,t,r){return"M"+e+","+n+"L"+t+","+r}function z(e,n,t,r){var i=t-e,a=r-n,o=Math.sqrt(i*i+a*a)/2;return"M"+e+","+n+"A"+o+","+o+" "+180*Math.atan2(a,i)/Math.PI+" 0 1 "+t+","+r}function L(e,n,t,r){var i=t-e,a=r-n,o=.2*(i+a),u=.2*(a-i);return"M"+e+","+n+"C"+(e+o)+","+(n+u)+" "+(t+u)+","+(r-o)+" "+t+","+r}function C(e){i.Transform.call(this,null,e)}T.Definition={type:"LinkPath",metadata:{modifies:!0},params:[{name:"sourceX",type:"field",default:"source.x"},{name:"sourceY",type:"field",default:"source.y"},{name:"targetX",type:"field",default:"target.x"},{name:"targetY",type:"field",default:"target.y"},{name:"orient",type:"enum",default:"vertical",values:["horizontal","vertical","radial"]},{name:"shape",type:"enum",default:"line",values:["line","arc","curve","diagonal","orthogonal"]},{name:"require",type:"signal"},{name:"as",type:"string",default:"path"}]},t.inherits(T,i.Transform).transform=function(e,n){var r=e.sourceX||k,i=e.sourceY||O,a=e.targetX||D,o=e.targetY||A,u=e.as||"path",l=e.orient||"vertical",s=e.shape||"line",f=S.get(s+"-"+l)||S.get(s);return f||t.error("LinkPath unsupported type: "+e.shape+(e.orient?"-"+e.orient:"")),n.visit(n.SOURCE,function(e){e[u]=f(r(e),i(e),a(e),o(e))}),n.reflow(e.modified()).modifies(u)},C.Definition={type:"Pie",metadata:{modifies:!0},params:[{name:"field",type:"field"},{name:"startAngle",type:"number",default:0},{name:"endAngle",type:"number",default:6.283185307179586},{name:"sort",type:"boolean",default:!1},{name:"as",type:"string",array:!0,length:2,default:["startAngle","endAngle"]}]},t.inherits(C,i.Transform).transform=function(e,n){var r,i,o,u=e.as||["startAngle","endAngle"],l=u[0],s=u[1],f=e.field||t.one,c=e.startAngle||0,d=null!=e.endAngle?e.endAngle:2*Math.PI,m=n.source,p=m.map(f),h=p.length,g=c,v=(d-c)/a.sum(p),y=a.range(h);for(e.sort&&y.sort(function(e,n){return p[e]-p[n]}),r=0;r<h;++r)o=p[y[r]],(i=m[y[r]])[l]=g,i[s]=g+=o*v;return this.value=p,n.reflow(e.modified()).modifies(u)};var I=5;function P(e){return n.isContinuous(e)&&e!==n.Sequential}var q=t.toSet(["set","modified","clear","type","scheme","schemeExtent","schemeCount","domain","domainMin","domainMid","domainMax","domainRaw","domainImplicit","nice","zero","bins","range","rangeStep","round","reverse","interpolate","interpolateGamma"]);function E(e){i.Transform.call(this,null,e),this.modified(!0)}function F(e,r,i){n.isLogarithmic(e)&&(Math.abs(r.reduce(function(e,n){return e+(n<0?-1:n>0?1:0)},0))!==r.length&&i.warn("Log scale domain includes zero: "+t.stringValue(r)));return r}function R(e,r,i){return t.isFunction(e)&&(r||i)?n.interpolateRange(e,_(r||[0,1],i)):e}function _(e,n){return n?e.slice().reverse():e}function N(e){i.Transform.call(this,null,e)}t.inherits(E,i.Transform).transform=function(e,r){var i=r.dataflow,l=this.value,s=function(e){var r,i=e.type,a="";if(i===n.Sequential)return n.Sequential+"-"+n.Linear;(function(e){const r=e.type;return n.isContinuous(r)&&r!==n.Time&&r!==n.UTC&&(e.scheme||e.range&&e.range.length&&e.range.every(t.isString))})(e)&&(r=e.rawDomain?e.rawDomain.length:e.domain?e.domain.length+ +(null!=e.domainMid):0,a=2===r?n.Sequential+"-":3===r?n.Diverging+"-":"");return(a+i||n.Linear).toLowerCase()}(e);for(s in l&&s===l.type||(this.value=l=n.scale(s)()),e)if(!q[s]){if("padding"===s&&P(l.type))continue;t.isFunction(l[s])?l[s](e[s]):i.warn("Unsupported scale property: "+s)}return function(e,r,i){var a=r.round||!1,u=r.range;if(null!=r.rangeStep)u=function(e,r,i){e!==n.Band&&e!==n.Point&&t.error("Only band and point scales support rangeStep.");var a=(null!=r.paddingOuter?r.paddingOuter:r.padding)||0,o=e===n.Point?1:(null!=r.paddingInner?r.paddingInner:r.padding)||0;return[0,r.rangeStep*n.bandSpace(i,o,a)]}(e.type,r,i);else if(r.scheme){if(u=function(e,r,i){var a,o,u=r.schemeExtent;t.isArray(r.scheme)?o=n.interpolateColors(r.scheme,r.interpolate,r.interpolateGamma):(a=r.scheme.toLowerCase(),(o=n.scheme(a))||t.error("Unrecognized scheme name: "+r.scheme));return i=e===n.Threshold?i+1:e===n.BinOrdinal?i-1:e===n.Quantile||e===n.Quantize?+r.schemeCount||I:i,n.isInterpolating(e)?R(o,u,r.reverse):t.isFunction(o)?n.quantizeInterpolator(R(o,u),i):e===n.Ordinal?o:o.slice(0,i)}(e.type,r,i),t.isFunction(u))return e.interpolator(u)}else if(u&&n.isInterpolating(e.type))return e.interpolator(n.interpolateColors(_(u,r.reverse),r.interpolate,r.interpolateGamma));u&&r.interpolate&&e.interpolate?e.interpolate(n.interpolate(r.interpolate,r.interpolateGamma)):t.isFunction(e.round)?e.round(a):t.isFunction(e.rangeRound)&&e.interpolate(a?o.interpolateRound:o.interpolate);u&&e.range(_(u,r.reverse))}(l,e,function(e,r,i){let o=r.bins;if(o&&!t.isArray(o)){const n=(null==o.start||null==o.stop)&&e.domain(),r=null==o.start?n[0]:o.start,i=null==o.stop?t.peek(n):o.stop,u=o.step;u||t.error("Scale bins parameter missing step property."),o=a.range(r,i+u,u)}o?e.bins=o:e.bins&&delete e.bins;e.type===n.BinOrdinal&&(o?r.domain||r.domainRaw||(e.domain(o),i=o.length):e.bins=e.domain());return i}(l,e,function(e,r,i){var a=function(e,n,t){return n?(e.domain(F(e.type,n,t)),n.length):-1}(e,r.domainRaw,i);if(a>-1)return a;var o,l,s=r.domain,f=e.type,c=r.zero||void 0===r.zero&&function(e){const t=e.type;return!e.bins&&(t===n.Linear||t===n.Pow||t===n.Sqrt)}(e);if(!s)return 0;P(f)&&r.padding&&s[0]!==t.peek(s)&&(s=function(e,r,i,a,o,u){var l=Math.abs(t.peek(i)-i[0]),s=l/(l-2*a),f=e===n.Log?t.zoomLog(r,null,s):e===n.Sqrt?t.zoomPow(r,null,s,.5):e===n.Pow?t.zoomPow(r,null,s,o||1):e===n.Symlog?t.zoomSymlog(r,null,s,u||1):t.zoomLinear(r,null,s);return(r=r.slice())[0]=f[0],r[r.length-1]=f[1],r}(f,s,r.range,r.padding,r.exponent,r.constant));(c||null!=r.domainMin||null!=r.domainMax||null!=r.domainMid)&&(o=(s=s.slice()).length-1||1,c&&(s[0]>0&&(s[0]=0),s[o]<0&&(s[o]=0)),null!=r.domainMin&&(s[0]=r.domainMin),null!=r.domainMax&&(s[o]=r.domainMax),null!=r.domainMid&&(((l=r.domainMid)<s[0]||l>s[o])&&i.warn("Scale domainMid exceeds domain min or max.",l),s.splice(o,0,l)));e.domain(F(f,s,i)),f===n.Ordinal&&e.unknown(r.domainImplicit?n.scaleImplicit:void 0);r.nice&&e.nice&&e.nice(!0!==r.nice&&u(e,r.nice)||null);return s.length}(l,e,i))),r.fork(r.NO_SOURCE|r.NO_FIELDS)},t.inherits(N,i.Transform).transform=function(e,n){var t=e.modified("sort")||n.changed(n.ADD)||n.modified(e.sort.fields)||n.modified("datum");return t&&n.source.sort(e.sort),this.modified(t),n};var U=["y0","y1"];function j(e){i.Transform.call(this,null,e)}function G(e,n,t,r,i){for(var a,o=(n-e.sum)/2,u=e.length,l=0;l<u;++l)(a=e[l])[r]=o,a[i]=o+=Math.abs(t(a))}function Q(e,n,t,r,i){for(var a,o=1/e.sum,u=0,l=e.length,s=0,f=0;s<l;++s)(a=e[s])[r]=u,a[i]=u=o*(f+=Math.abs(t(a)))}function X(e,n,t,r,i){for(var a,o,u=0,l=0,s=e.length,f=0;f<s;++f)(a=t(o=e[f]))<0?(o[r]=l,o[i]=l+=a):(o[r]=u,o[i]=u+=a)}j.Definition={type:"Stack",metadata:{modifies:!0},params:[{name:"field",type:"field"},{name:"groupby",type:"field",array:!0},{name:"sort",type:"compare"},{name:"offset",type:"enum",default:"zero",values:["zero","center","normalize"]},{name:"as",type:"string",array:!0,length:2,default:U}]},t.inherits(j,i.Transform).transform=function(e,n){var r,i,a,o,u=e.as||U,l=u[0],s=u[1],f=e.field||t.one,c="center"===e.offset?G:"normalize"===e.offset?Q:X;for(r=function(e,n,t,r){var i,a,o,u,l,s,f,c,d,m=[],p=function(e){return e(l)};if(null==n)m.push(e.slice());else for(i={},a=0,o=e.length;a<o;++a)l=e[a],s=n.map(p),(f=i[s])||(i[s]=f=[],m.push(f)),f.push(l);for(s=0,d=0,u=m.length;s<u;++s){for(f=m[s],a=0,c=0,o=f.length;a<o;++a)c+=Math.abs(r(f[a]));f.sum=c,c>d&&(d=c),t&&f.sort(t)}return m.max=d,m}(n.source,e.groupby,e.sort,f),i=0,a=r.length,o=r.max;i<a;++i)c(r[i],o,f,l,s);return n.reflow(e.modified()).modifies(u)},e.axisticks=c,e.datajoin=d,e.encode=h,e.legendentries=b,e.linkpath=T,e.pie=C,e.scale=E,e.sortitems=N,e.stack=j,e.validTicks=l,Object.defineProperty(e,"__esModule",{value:!0})});
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports,require("vega-scale"),require("vega-util"),require("d3-format"),require("vega-dataflow"),require("d3-array"),require("d3-interpolate")):"function"==typeof define&&define.amd?define(["exports","vega-scale","vega-util","d3-format","vega-dataflow","d3-array","d3-interpolate"],n):n(((e=e||self).vega=e.vega||{},e.vega.transforms={}),e.vega,e.vega,e.d3,e.vega,e.d3,e.d3)}(this,function(e,n,t,r,i,a,o){"use strict";function u(e,r,i){var a;return t.isNumber(r)&&null!=i&&(r=Math.min(r,~~(t.span(e.domain())/i)||1)),t.isObject(r)&&(a=r.step,r=r.interval),t.isString(r)&&(r=n.timeInterval(r,e.type)||t.error("Only time and utc scales accept interval strings."),a&&(r=r.every(a))),r}function s(e,n,r){var i=e.range(),a=Math.floor(i[0]),o=Math.ceil(t.peek(i));if(a>o&&(i=o,o=a,a=i),n=n.filter(function(n){return n=e(n),a<=n&&n<=o}),r>0&&n.length>1){for(var u=[n[0],t.peek(n)];n.length>r&&n.length>=3;)n=n.filter(function(e,n){return!(n%2)});n.length<3&&(n=u)}return n}function l(e,n){return e.bins?s(e,function(e,n){var t=e.length,r=~~(t/(n||t));return r<2?e.slice():e.filter(function(e,n){return!(n%r)})}(e.bins,n)):e.ticks?e.ticks(n):e.domain()}function f(e,t,i){var a,o,u=e.tickFormat?e.tickFormat(t,i):i?r.format(i):String;if(n.isLogarithmic(e.type)){var s=function(e){var n=r.formatSpecifier(e||",");if(null==n.precision){switch(n.precision=12,n.type){case"%":n.precision-=2;break;case"e":n.precision-=1}return t=r.format(n),i=r.format(".1f")(1)[1],function(e){var n,r,a=t(e),o=a.indexOf(i);if(o<0)return a;for(n=function(e,n){var t,r=e.lastIndexOf("e");if(r>0)return r;for(r=e.length;--r>n;)if((t=e.charCodeAt(r))>=48&&t<=57)return r+1}(a,o),r=n<a.length?a.slice(n):"";--n>o;)if("0"!==a[n]){++n;break}return a.slice(0,n)+r}}return r.format(n);var t,i}(i);u=e.bins?s:(a=u,o=s,function(e){return a(e)?o(e):""})}return u}function c(e){i.Transform.call(this,null,e)}function d(e){i.Transform.call(this,null,e)}function m(){return i.ingest({})}function p(e){return e.exit}function h(e){i.Transform.call(this,null,e)}t.inherits(c,i.Transform).transform=function(e,n){if(this.value&&!e.modified())return n.StopPropagation;var t=n.fork(n.NO_SOURCE|n.NO_FIELDS),r=this.value,a=e.scale,o=u(a,null==e.count?e.values?e.values.length:10:e.count,e.minstep),c=e.format||f(a,o,e.formatSpecifier),d=e.values?s(a,e.values,o):l(a,o);return r&&(t.rem=r),r=d.map(function(e,n){return i.ingest({index:n/(d.length-1),value:e,label:c(e)})}),e.extra&&r.length&&r.push(i.ingest({index:-1,extra:{value:r[0].value},label:""})),t.source=r,t.add=r,this.value=r,t},t.inherits(d,i.Transform).transform=function(e,n){var r=n.dataflow,a=n.fork(n.NO_SOURCE|n.NO_FIELDS),o=e.item||m,u=e.key||i.tupleid,s=this.value;return t.isArray(a.encode)&&(a.encode=null),s&&(e.modified("key")||n.modified(u))&&t.error("DataJoin does not support modified key function or fields."),s||(n=n.addAll(),this.value=s=t.fastmap().test(p),s.lookup=function(e){return s.get(u(e))}),n.visit(n.ADD,function(e){var n=u(e),t=s.get(n);t?t.exit?(s.empty--,a.add.push(t)):a.mod.push(t):(s.set(n,t=o(e)),a.add.push(t)),t.datum=e,t.exit=!1}),n.visit(n.MOD,function(e){var n=u(e),t=s.get(n);t&&(t.datum=e,a.mod.push(t))}),n.visit(n.REM,function(e){var n=u(e),t=s.get(n);e!==t.datum||t.exit||(a.rem.push(t),t.exit=!0,++s.empty)}),n.changed(n.ADD_MOD)&&a.modifies("datum"),e.clean&&s.empty>r.cleanThreshold&&r.runAfter(s.clean),a},t.inherits(h,i.Transform).transform=function(e,n){var r=n.fork(n.ADD_REM),i=e.encoders,a=n.encode;if(t.isArray(a)){if(!r.changed()&&!a.every(function(e){return i[e]}))return n.StopPropagation;a=a[0],r.encode=null}var o="enter"===a,u=i.update||t.falsy,s=i.enter||t.falsy,l=i.exit||t.falsy,f=(a&&!o?i[a]:u)||t.falsy;if(n.changed(n.ADD)&&(n.visit(n.ADD,function(n){s(n,e),u(n,e),f!==t.falsy&&f!==u&&f(n,e)}),r.modifies(s.output),r.modifies(u.output),f!==t.falsy&&f!==u&&r.modifies(f.output)),n.changed(n.REM)&&l!==t.falsy&&(n.visit(n.REM,function(n){l(n,e)}),r.modifies(l.output)),o||f!==t.falsy){var c=n.MOD|(e.modified()?n.REFLOW:0);o?(n.visit(c,function(n){var t=s(n,e);(f(n,e)||t)&&r.mod.push(n)}),r.mod.length&&r.modifies(s.output)):n.visit(c,function(n){f(n,e)&&r.mod.push(n)}),r.mod.length&&r.modifies(f.output)}return r.changed()?r:n.StopPropagation};var g="symbol",v="discrete";const y={[n.Quantile]:"quantiles",[n.Quantize]:"thresholds",[n.Threshold]:"domain"},M={[n.Quantile]:"quantiles",[n.Quantize]:"domain"};function b(e,n){return e.bins?function(e){const n=e.slice(0,-1);return n.max=t.peek(e),n}(e.bins):y[e.type]?function(e){const n=[-1/0].concat(e);return n.max=1/0,n}(e[y[e.type]]()):l(e,n)}function x(e,t,r,i){const a=M[e.type]?function(e,t){var r,i=e[M[e.type]](),a=i.length,o=a>1?i[1]-i[0]:i[0];for(r=1;r<a;++r)o=Math.min(o,i[r]-i[r-1]);return n.tickFormat(0,o,30,t)}(e,i):f(e,t,i);return r===g&&function(e){return y[e.type]||e.bins}(e)?function(e){return function(n,t,r){var i=r[t+1]||r.max||1/0,a=S(n,e),o=S(i,e);return a&&o?a+"–"+o:o?"< "+o:"≥ "+a}}(a):r===v?function(e){return function(n,t){return t?e(n):null}}(a):function(e){return function(n){return e(n)}}(a)}function S(e,n){return isFinite(e)?n(e):null}function k(e){i.Transform.call(this,[],e)}t.inherits(k,i.Transform).transform=function(e,r){if(null!=this.value&&!e.modified())return r.StopPropagation;var a,o,s,l,f=r.fork(r.NO_SOURCE|r.NO_FIELDS),c=this.value,d=e.type||g,m=e.scale,p=u(m,null==e.count?5:e.count,e.minstep),h=e.format||x(m,p,d,e.formatSpecifier),v=e.values||b(m,p);return c&&(f.rem=c),d===g?(t.isFunction(s=e.size)?(e.values||0!==m(v[0])||(v=v.slice(1)),l=v.reduce(function(n,t){return Math.max(n,s(t,e))},0)):s=t.constant(l=s||8),c=v.map(function(n,t){return i.ingest({index:t,label:h(n,t,v),value:n,offset:l,size:s(n,e)})})):"gradient"===d?(a=m.domain(),o=n.scaleFraction(m,a[0],t.peek(a)),v.length<3&&!e.values&&a[0]!==t.peek(a)&&(v=[a[0],t.peek(a)]),c=v.map(function(e,n){return i.ingest({index:n,label:h(e,n,v),value:e,perc:o(e)})})):(s=v.length-1,o=function(e){var r=e.domain(),i=r.length-1,a=+r[0],o=+t.peek(r),u=o-a;if(e.type===n.Threshold){var s=i?u/i:.1;u=(o+=s)-(a-=s)}return function(e){return(e-a)/u}}(m),c=v.map(function(e,n){return i.ingest({index:n,label:h(e,n,v),value:e,perc:n?o(e):0,perc2:n===s?1:o(v[n+1])})})),f.source=c,f.add=c,this.value=c,f};var O=t.fastmap({line:L,"line-radial":function(e,n,t,r){return L(n*Math.cos(e),n*Math.sin(e),r*Math.cos(t),r*Math.sin(t))},arc:C,"arc-radial":function(e,n,t,r){return C(n*Math.cos(e),n*Math.sin(e),r*Math.cos(t),r*Math.sin(t))},curve:q,"curve-radial":function(e,n,t,r){return q(n*Math.cos(e),n*Math.sin(e),r*Math.cos(t),r*Math.sin(t))},"orthogonal-horizontal":function(e,n,t,r){return"M"+e+","+n+"V"+r+"H"+t},"orthogonal-vertical":function(e,n,t,r){return"M"+e+","+n+"H"+t+"V"+r},"orthogonal-radial":function(e,n,t,r){var i=Math.cos(e),a=Math.sin(e),o=Math.cos(t),u=Math.sin(t),s=Math.abs(t-e)>Math.PI?t<=e:t>e;return"M"+n*i+","+n*a+"A"+n+","+n+" 0 0,"+(s?1:0)+" "+n*o+","+n*u+"L"+r*o+","+r*u},"diagonal-horizontal":function(e,n,t,r){var i=(e+t)/2;return"M"+e+","+n+"C"+i+","+n+" "+i+","+r+" "+t+","+r},"diagonal-vertical":function(e,n,t,r){var i=(n+r)/2;return"M"+e+","+n+"C"+e+","+i+" "+t+","+i+" "+t+","+r},"diagonal-radial":function(e,n,t,r){var i=Math.cos(e),a=Math.sin(e),o=Math.cos(t),u=Math.sin(t),s=(n+r)/2;return"M"+n*i+","+n*a+"C"+s*i+","+s*a+" "+s*o+","+s*u+" "+r*o+","+r*u}});function D(e){return e.source.x}function T(e){return e.source.y}function A(e){return e.target.x}function w(e){return e.target.y}function z(e){i.Transform.call(this,{},e)}function L(e,n,t,r){return"M"+e+","+n+"L"+t+","+r}function C(e,n,t,r){var i=t-e,a=r-n,o=Math.sqrt(i*i+a*a)/2;return"M"+e+","+n+"A"+o+","+o+" "+180*Math.atan2(a,i)/Math.PI+" 0 1 "+t+","+r}function q(e,n,t,r){var i=t-e,a=r-n,o=.2*(i+a),u=.2*(a-i);return"M"+e+","+n+"C"+(e+o)+","+(n+u)+" "+(t+u)+","+(r-o)+" "+t+","+r}function F(e){i.Transform.call(this,null,e)}z.Definition={type:"LinkPath",metadata:{modifies:!0},params:[{name:"sourceX",type:"field",default:"source.x"},{name:"sourceY",type:"field",default:"source.y"},{name:"targetX",type:"field",default:"target.x"},{name:"targetY",type:"field",default:"target.y"},{name:"orient",type:"enum",default:"vertical",values:["horizontal","vertical","radial"]},{name:"shape",type:"enum",default:"line",values:["line","arc","curve","diagonal","orthogonal"]},{name:"require",type:"signal"},{name:"as",type:"string",default:"path"}]},t.inherits(z,i.Transform).transform=function(e,n){var r=e.sourceX||D,i=e.sourceY||T,a=e.targetX||A,o=e.targetY||w,u=e.as||"path",s=e.orient||"vertical",l=e.shape||"line",f=O.get(l+"-"+s)||O.get(l);return f||t.error("LinkPath unsupported type: "+e.shape+(e.orient?"-"+e.orient:"")),n.visit(n.SOURCE,function(e){e[u]=f(r(e),i(e),a(e),o(e))}),n.reflow(e.modified()).modifies(u)},F.Definition={type:"Pie",metadata:{modifies:!0},params:[{name:"field",type:"field"},{name:"startAngle",type:"number",default:0},{name:"endAngle",type:"number",default:6.283185307179586},{name:"sort",type:"boolean",default:!1},{name:"as",type:"string",array:!0,length:2,default:["startAngle","endAngle"]}]},t.inherits(F,i.Transform).transform=function(e,n){var r,i,o,u=e.as||["startAngle","endAngle"],s=u[0],l=u[1],f=e.field||t.one,c=e.startAngle||0,d=null!=e.endAngle?e.endAngle:2*Math.PI,m=n.source,p=m.map(f),h=p.length,g=c,v=(d-c)/a.sum(p),y=a.range(h);for(e.sort&&y.sort(function(e,n){return p[e]-p[n]}),r=0;r<h;++r)o=p[y[r]],(i=m[y[r]])[s]=g,i[l]=g+=o*v;return this.value=p,n.reflow(e.modified()).modifies(u)};var I=5;function P(e){return n.isContinuous(e)&&e!==n.Sequential}var E=t.toSet(["set","modified","clear","type","scheme","schemeExtent","schemeCount","domain","domainMin","domainMid","domainMax","domainRaw","domainImplicit","nice","zero","bins","range","rangeStep","round","reverse","interpolate","interpolateGamma"]);function R(e){i.Transform.call(this,null,e),this.modified(!0)}function _(e,r,i){n.isLogarithmic(e)&&(Math.abs(r.reduce(function(e,n){return e+(n<0?-1:n>0?1:0)},0))!==r.length&&i.warn("Log scale domain includes zero: "+t.stringValue(r)));return r}function N(e,r,i){return t.isFunction(e)&&(r||i)?n.interpolateRange(e,U(r||[0,1],i)):e}function U(e,n){return n?e.slice().reverse():e}function Q(e){i.Transform.call(this,null,e)}t.inherits(R,i.Transform).transform=function(e,r){var i=r.dataflow,s=this.value,l=function(e){var r,i=e.type,a="";if(i===n.Sequential)return n.Sequential+"-"+n.Linear;(function(e){const r=e.type;return n.isContinuous(r)&&r!==n.Time&&r!==n.UTC&&(e.scheme||e.range&&e.range.length&&e.range.every(t.isString))})(e)&&(r=e.rawDomain?e.rawDomain.length:e.domain?e.domain.length+ +(null!=e.domainMid):0,a=2===r?n.Sequential+"-":3===r?n.Diverging+"-":"");return(a+i||n.Linear).toLowerCase()}(e);for(l in s&&l===s.type||(this.value=s=n.scale(l)()),e)if(!E[l]){if("padding"===l&&P(s.type))continue;t.isFunction(s[l])?s[l](e[l]):i.warn("Unsupported scale property: "+l)}return function(e,r,i){var a=r.round||!1,u=r.range;if(null!=r.rangeStep)u=function(e,r,i){e!==n.Band&&e!==n.Point&&t.error("Only band and point scales support rangeStep.");var a=(null!=r.paddingOuter?r.paddingOuter:r.padding)||0,o=e===n.Point?1:(null!=r.paddingInner?r.paddingInner:r.padding)||0;return[0,r.rangeStep*n.bandSpace(i,o,a)]}(e.type,r,i);else if(r.scheme){if(u=function(e,r,i){var a,o,u=r.schemeExtent;t.isArray(r.scheme)?o=n.interpolateColors(r.scheme,r.interpolate,r.interpolateGamma):(a=r.scheme.toLowerCase(),(o=n.scheme(a))||t.error("Unrecognized scheme name: "+r.scheme));return i=e===n.Threshold?i+1:e===n.BinOrdinal?i-1:e===n.Quantile||e===n.Quantize?+r.schemeCount||I:i,n.isInterpolating(e)?N(o,u,r.reverse):t.isFunction(o)?n.quantizeInterpolator(N(o,u),i):e===n.Ordinal?o:o.slice(0,i)}(e.type,r,i),t.isFunction(u))return e.interpolator(u)}else if(u&&n.isInterpolating(e.type))return e.interpolator(n.interpolateColors(U(u,r.reverse),r.interpolate,r.interpolateGamma));u&&r.interpolate&&e.interpolate?e.interpolate(n.interpolate(r.interpolate,r.interpolateGamma)):t.isFunction(e.round)?e.round(a):t.isFunction(e.rangeRound)&&e.interpolate(a?o.interpolateRound:o.interpolate);u&&e.range(U(u,r.reverse))}(s,e,function(e,r,i){let o=r.bins;if(o&&!t.isArray(o)){const n=(null==o.start||null==o.stop)&&e.domain(),r=null==o.start?n[0]:o.start,i=null==o.stop?t.peek(n):o.stop,u=o.step;u||t.error("Scale bins parameter missing step property."),o=a.range(r,i+u,u)}o?e.bins=o:e.bins&&delete e.bins;e.type===n.BinOrdinal&&(o?r.domain||r.domainRaw||(e.domain(o),i=o.length):e.bins=e.domain());return i}(s,e,function(e,r,i){var a=function(e,n,t){return n?(e.domain(_(e.type,n,t)),n.length):-1}(e,r.domainRaw,i);if(a>-1)return a;var o,s,l=r.domain,f=e.type,c=r.zero||void 0===r.zero&&function(e){const t=e.type;return!e.bins&&(t===n.Linear||t===n.Pow||t===n.Sqrt)}(e);if(!l)return 0;P(f)&&r.padding&&l[0]!==t.peek(l)&&(l=function(e,r,i,a,o,u){var s=Math.abs(t.peek(i)-i[0]),l=s/(s-2*a),f=e===n.Log?t.zoomLog(r,null,l):e===n.Sqrt?t.zoomPow(r,null,l,.5):e===n.Pow?t.zoomPow(r,null,l,o||1):e===n.Symlog?t.zoomSymlog(r,null,l,u||1):t.zoomLinear(r,null,l);return(r=r.slice())[0]=f[0],r[r.length-1]=f[1],r}(f,l,r.range,r.padding,r.exponent,r.constant));(c||null!=r.domainMin||null!=r.domainMax||null!=r.domainMid)&&(o=(l=l.slice()).length-1||1,c&&(l[0]>0&&(l[0]=0),l[o]<0&&(l[o]=0)),null!=r.domainMin&&(l[0]=r.domainMin),null!=r.domainMax&&(l[o]=r.domainMax),null!=r.domainMid&&(((s=r.domainMid)<l[0]||s>l[o])&&i.warn("Scale domainMid exceeds domain min or max.",s),l.splice(o,0,s)));e.domain(_(f,l,i)),f===n.Ordinal&&e.unknown(r.domainImplicit?n.scaleImplicit:void 0);r.nice&&e.nice&&e.nice(!0!==r.nice&&u(e,r.nice)||null);return l.length}(s,e,i))),r.fork(r.NO_SOURCE|r.NO_FIELDS)},t.inherits(Q,i.Transform).transform=function(e,n){var t=e.modified("sort")||n.changed(n.ADD)||n.modified(e.sort.fields)||n.modified("datum");return t&&n.source.sort(e.sort),this.modified(t),n};var j=["y0","y1"];function G(e){i.Transform.call(this,null,e)}function X(e,n,t,r,i){for(var a,o=(n-e.sum)/2,u=e.length,s=0;s<u;++s)(a=e[s])[r]=o,a[i]=o+=Math.abs(t(a))}function Y(e,n,t,r,i){for(var a,o=1/e.sum,u=0,s=e.length,l=0,f=0;l<s;++l)(a=e[l])[r]=u,a[i]=u=o*(f+=Math.abs(t(a)))}function B(e,n,t,r,i){for(var a,o,u=0,s=0,l=e.length,f=0;f<l;++f)(a=t(o=e[f]))<0?(o[r]=s,o[i]=s+=a):(o[r]=u,o[i]=u+=a)}G.Definition={type:"Stack",metadata:{modifies:!0},params:[{name:"field",type:"field"},{name:"groupby",type:"field",array:!0},{name:"sort",type:"compare"},{name:"offset",type:"enum",default:"zero",values:["zero","center","normalize"]},{name:"as",type:"string",array:!0,length:2,default:j}]},t.inherits(G,i.Transform).transform=function(e,n){var r,i,a,o,u=e.as||j,s=u[0],l=u[1],f=e.field||t.one,c="center"===e.offset?X:"normalize"===e.offset?Y:B;for(r=function(e,n,t,r){var i,a,o,u,s,l,f,c,d,m=[],p=function(e){return e(s)};if(null==n)m.push(e.slice());else for(i={},a=0,o=e.length;a<o;++a)s=e[a],l=n.map(p),(f=i[l])||(i[l]=f=[],m.push(f)),f.push(s);for(l=0,d=0,u=m.length;l<u;++l){for(f=m[l],a=0,c=0,o=f.length;a<o;++a)c+=Math.abs(r(f[a]));f.sum=c,c>d&&(d=c),t&&f.sort(t)}return m.max=d,m}(n.source,e.groupby,e.sort,f),i=0,a=r.length,o=r.max;i<a;++i)c(r[i],o,f,s,l);return n.reflow(e.modified()).modifies(u)},e.axisticks=c,e.datajoin=d,e.encode=h,e.legendentries=k,e.linkpath=z,e.pie=F,e.scale=R,e.sortitems=Q,e.stack=G,e.validTicks=s,Object.defineProperty(e,"__esModule",{value:!0})});
{
"name": "vega-encode",
"version": "4.1.1",
"version": "4.1.2",
"description": "Visual encoding transforms for Vega dataflows.",

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

"vega-dataflow": "^5.1.1",
"vega-scale": "^4.0.0",
"vega-scale": "^4.1.0",
"vega-util": "^1.8.0"

@@ -38,3 +38,3 @@ },

},
"gitHead": "0f0e009069ae0291458398a747f024c693c201d9"
"gitHead": "a34555f5474d42a4599dd958895b8e44d3fda0fe"
}
import {Symbols, Discrete} from './legend-types';
import {tickValues} from './ticks';
import {tickFormat, tickValues} from './ticks';
import {Quantile, Quantize, Threshold} from 'vega-scale';
import {Quantile, Quantize, Threshold, tickFormat as spanFormat} from 'vega-scale';
import {peek} from 'vega-util';
const symbols = {
[Quantile]: quantileSymbols,
[Quantize]: quantizeSymbols,
[Threshold]: thresholdSymbols
[Quantile]: 'quantiles',
[Quantize]: 'thresholds',
[Threshold]: 'domain'
};
const formats = {
[Quantile]: 'quantiles',
[Quantize]: 'domain'
};
export function labelValues(scale, count) {
return scale.bins ? binValues(scale.bins.slice())
: symbols[scale.type] ? symbols[scale.type](scale)
return scale.bins ? binValues(scale.bins)
: symbols[scale.type] ? thresholdValues(scale[symbols[scale.type]]())
: tickValues(scale, count);
}
function quantizeSymbols(scale) {
var domain = scale.domain(),
x0 = domain[0],
x1 = peek(domain),
n = scale.range().length,
values = new Array(n),
i = 0;
export function thresholdFormat(scale, specifier) {
var _ = scale[formats[scale.type]](),
n = _.length,
d = n > 1 ? _[1] - _[0] : _[0], i;
values[0] = -Infinity;
while (++i < n) values[i] = (i * x1 - (i - n) * x0) / n;
values.max = +Infinity;
for (i=1; i<n; ++i) {
d = Math.min(d, _[i] - _[i-1]);
}
return values;
// 3 ticks times 10 for increased resolution
return spanFormat(0, d, 3 * 10, specifier);
}
function quantileSymbols(scale) {
var values = [-Infinity].concat(scale.quantiles());
function thresholdValues(thresholds) {
const values = [-Infinity].concat(thresholds);
values.max = +Infinity;

@@ -41,5 +44,5 @@

function thresholdSymbols(scale) {
var values = [-Infinity].concat(scale.domain());
values.max = +Infinity;
function binValues(bins) {
const values = bins.slice(0, -1);
values.max = peek(bins);

@@ -49,7 +52,2 @@ return values;

function binValues(bins) {
bins.max = bins.pop();
return bins;
}
function isDiscreteRange(scale) {

@@ -59,3 +57,6 @@ return symbols[scale.type] || scale.bins;

export function labelFormat(scale, format, type) {
export function labelFormat(scale, count, type, specifier) {
const format = formats[scale.type] ? thresholdFormat(scale, specifier)
: tickFormat(scale, count, specifier);
return type === Symbols && isDiscreteRange(scale) ? formatRange(format)

@@ -62,0 +63,0 @@ : type === Discrete ? formatDiscrete(format)

import {labelFormat, labelFraction, labelValues} from './labels';
import {Symbols, Gradient} from './legend-types';
import {tickCount, tickFormat} from './ticks';
import {tickCount} from './ticks';
import {Transform, ingest} from 'vega-dataflow';

@@ -40,7 +40,6 @@ import {scaleFraction} from 'vega-scale';

count = tickCount(scale, _.count == null ? 5 : _.count, _.minstep),
format = _.format || tickFormat(scale, count, _.formatSpecifier),
format = _.format || labelFormat(scale, count, type, _.formatSpecifier),
values = _.values || labelValues(scale, count, type),
domain, fraction, size, offset;
format = labelFormat(scale, format, type);
if (items) out.rem = items;

@@ -47,0 +46,0 @@

@@ -113,3 +113,3 @@ import {isLogarithmic, timeInterval} from 'vega-scale';

* @param {*} [count] - The approximate number of desired ticks.
* @param {string} [specifier] - The format specifier. Must be a legal d3 4.0
* @param {string} [specifier] - The format specifier. Must be a legal d3
* specifier string (see https://github.com/d3/d3-format#formatSpecifier).

@@ -116,0 +116,0 @@ * @return {function(*):string} - The generated label formatter.

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