vega-functions
Advanced tools
Comparing version 5.6.0 to 5.7.0
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vega-expression'), require('vega-dataflow'), require('vega-selections'), require('vega-statistics'), require('vega-time'), require('vega-util'), require('d3-array'), require('d3-color'), require('d3-format'), require('d3-time-format'), require('vega-scale'), require('d3-geo'), require('vega-scenegraph')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'vega-expression', 'vega-dataflow', 'vega-selections', 'vega-statistics', 'vega-time', 'vega-util', 'd3-array', 'd3-color', 'd3-format', 'd3-time-format', 'vega-scale', 'd3-geo', 'vega-scenegraph'], factory) : | ||
(global = global || self, factory(global.vega = {}, global.vega, global.vega, global.vega, global.vega, global.vega, global.vega, global.d3, global.d3, global.d3, global.d3, global.vega, global.d3, global.vega)); | ||
}(this, (function (exports, vegaExpression, vegaDataflow, vegaSelections, vegaStatistics, vegaTime, vegaUtil, d3Array, d3Color, d3Format, d3TimeFormat, vegaScale, d3Geo, vegaScenegraph) { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vega-util'), require('vega-expression'), require('d3-geo'), require('d3-color'), require('vega-dataflow'), require('vega-scale'), require('vega-scenegraph'), require('vega-selections'), require('vega-statistics'), require('vega-time'), require('d3-array')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'vega-util', 'vega-expression', 'd3-geo', 'd3-color', 'vega-dataflow', 'vega-scale', 'vega-scenegraph', 'vega-selections', 'vega-statistics', 'vega-time', 'd3-array'], factory) : | ||
(global = global || self, factory(global.vega = {}, global.vega, global.vega, global.d3, global.d3, global.vega, global.vega, global.vega, global.vega, global.vega, global.vega, global.d3)); | ||
}(this, (function (exports, vegaUtil, vegaExpression, d3Geo, d3Color, vegaDataflow, vegaScale, vegaScenegraph, vegaSelections, vegaStatistics, vegaTime, d3Array) { 'use strict'; | ||
// https://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef | ||
function channel_luminance_value(channelValue) { | ||
const val = channelValue / 255; | ||
if (val <= 0.03928) { | ||
return val / 12.92; | ||
} | ||
return Math.pow((val + 0.055) / 1.055, 2.4); | ||
} | ||
function luminance(color) { | ||
const c = d3Color.rgb(color), | ||
r = channel_luminance_value(c.r), | ||
g = channel_luminance_value(c.g), | ||
b = channel_luminance_value(c.b); | ||
return 0.2126 * r + 0.7152 * g + 0.0722 * b; | ||
} | ||
// https://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef | ||
function contrast(color1, color2) { | ||
const lum1 = luminance(color1), | ||
lum2 = luminance(color2), | ||
lumL = Math.max(lum1, lum2), | ||
lumD = Math.min(lum1, lum2); | ||
return (lumL + 0.05) / (lumD + 0.05); | ||
} | ||
function data(name) { | ||
@@ -62,33 +36,13 @@ const data = this.context.data[name]; | ||
const formatCache = {}; | ||
const wrap = method => function(value, spec) { | ||
const locale = this.context.dataflow.locale(); | ||
return locale[method](spec)(value); | ||
}; | ||
function formatter(type, method, specifier) { | ||
let k = type + ':' + specifier, | ||
e = formatCache[k]; | ||
if (!e || e[0] !== method) { | ||
formatCache[k] = (e = [method, method(specifier)]); | ||
} | ||
return e[1]; | ||
} | ||
const format = wrap('format'); | ||
const timeFormat = wrap('timeFormat'); | ||
const utcFormat = wrap('utcFormat'); | ||
const timeParse = wrap('timeParse'); | ||
const utcParse = wrap('utcParse'); | ||
function format(_, specifier) { | ||
return formatter('format', d3Format.format, specifier)(_); | ||
} | ||
function timeFormat(_, specifier) { | ||
return formatter('timeFormat', vegaTime.timeFormat, specifier)(_); | ||
} | ||
function utcFormat(_, specifier) { | ||
return formatter('utcFormat', vegaTime.utcFormat, specifier)(_); | ||
} | ||
function timeParse(_, specifier) { | ||
return formatter('timeParse', d3TimeFormat.timeParse, specifier)(_); | ||
} | ||
function utcParse(_, specifier) { | ||
return formatter('utcParse', d3TimeFormat.utcParse, specifier)(_); | ||
} | ||
var dateObj = new Date(2000, 0, 1); | ||
@@ -101,62 +55,109 @@ | ||
dateObj.setDate(day); | ||
return timeFormat(dateObj, specifier); | ||
return timeFormat.call(this, dateObj, specifier); | ||
} | ||
function monthFormat(month) { | ||
return time(month, 1, '%B'); | ||
return time.call(this, month, 1, '%B'); | ||
} | ||
function monthAbbrevFormat(month) { | ||
return time(month, 1, '%b'); | ||
return time.call(this, month, 1, '%b'); | ||
} | ||
function dayFormat(day) { | ||
return time(0, 2 + day, '%A'); | ||
return time.call(this, 0, 2 + day, '%A'); | ||
} | ||
function dayAbbrevFormat(day) { | ||
return time(0, 2 + day, '%a'); | ||
return time.call(this, 0, 2 + day, '%a'); | ||
} | ||
function getScale(name, ctx) { | ||
let s; | ||
return vegaUtil.isFunction(name) ? name | ||
: vegaUtil.isString(name) ? (s = ctx.scales[name]) && s.value | ||
: undefined; | ||
} | ||
const DataPrefix = ':'; | ||
const IndexPrefix = '@'; | ||
const ScalePrefix = '%'; | ||
const SignalPrefix = '$'; | ||
function range(name, group) { | ||
const s = getScale(name, (group || this).context); | ||
return s && s.range ? s.range() : []; | ||
} | ||
function dataVisitor(name, args, scope, params) { | ||
if (args[0].type !== vegaExpression.Literal) { | ||
vegaUtil.error('First argument to data functions must be a string literal.'); | ||
} | ||
function domain(name, group) { | ||
const s = getScale(name, (group || this).context); | ||
return s ? s.domain() : []; | ||
const data = args[0].value, | ||
dataName = DataPrefix + data; | ||
if (!vegaUtil.hasOwnProperty(dataName, params)) { | ||
try { | ||
params[dataName] = scope.getData(data).tuplesRef(); | ||
} catch (err) { | ||
// if data set does not exist, there's nothing to track | ||
} | ||
} | ||
} | ||
function bandwidth(name, group) { | ||
const s = getScale(name, (group || this).context); | ||
return s && s.bandwidth ? s.bandwidth() : 0; | ||
function indataVisitor(name, args, scope, params) { | ||
if (args[0].type !== vegaExpression.Literal) vegaUtil.error('First argument to indata must be a string literal.'); | ||
if (args[1].type !== vegaExpression.Literal) vegaUtil.error('Second argument to indata must be a string literal.'); | ||
const data = args[0].value, | ||
field = args[1].value, | ||
indexName = IndexPrefix + field; | ||
if (!vegaUtil.hasOwnProperty(indexName, params)) { | ||
params[indexName] = scope.getData(data).indataRef(scope, field); | ||
} | ||
} | ||
function bandspace(count, paddingInner, paddingOuter) { | ||
return vegaScale.bandSpace(count || 0, paddingInner || 0, paddingOuter || 0); | ||
function scaleVisitor(name, args, scope, params) { | ||
if (args[0].type === vegaExpression.Literal) { | ||
// add scale dependency | ||
addScaleDependency(scope, params, args[0].value); | ||
} else { | ||
// indirect scale lookup; add all scales as parameters | ||
for (name in scope.scales) { | ||
addScaleDependency(scope, params, name); | ||
} | ||
} | ||
} | ||
function copy(name, group) { | ||
const s = getScale(name, (group || this).context); | ||
return s ? s.copy() : undefined; | ||
function addScaleDependency(scope, params, name) { | ||
const scaleName = ScalePrefix + name; | ||
if (!vegaUtil.hasOwnProperty(params, scaleName)) { | ||
try { | ||
params[scaleName] = scope.scaleRef(name); | ||
} catch (err) { | ||
// TODO: error handling? warning? | ||
} | ||
} | ||
} | ||
function scale(name, value, group) { | ||
const s = getScale(name, (group || this).context); | ||
return s && value !== undefined ? s(value) : undefined; | ||
function getScale(name, ctx) { | ||
let s; | ||
return vegaUtil.isFunction(name) ? name | ||
: vegaUtil.isString(name) ? (s = ctx.scales[name]) && s.value | ||
: undefined; | ||
} | ||
function invert(name, range, group) { | ||
const s = getScale(name, (group || this).context); | ||
return !s ? undefined | ||
: vegaUtil.isArray(range) ? (s.invertRange || s.invert)(range) | ||
: (s.invert || s.invertExtent)(range); | ||
function internalScaleFunctions(codegen, fnctx, visitors) { | ||
// add helper method to the 'this' expression function context | ||
fnctx.__bandwidth = s => s && s.bandwidth ? s.bandwidth() : 0; | ||
// register AST visitors for internal scale functions | ||
visitors._bandwidth = scaleVisitor; | ||
visitors._range = scaleVisitor; | ||
visitors._scale = scaleVisitor; | ||
// resolve scale reference directly to the signal hash argument | ||
const ref = arg => '_[' + ( | ||
arg.type === vegaExpression.Literal | ||
? vegaUtil.stringValue(ScalePrefix + arg.value) | ||
: vegaUtil.stringValue(ScalePrefix) + '+' + codegen(arg) | ||
) + ']'; | ||
// define and return internal scale function code generators | ||
// these internal functions are called by mark encoders | ||
return { | ||
_bandwidth: args => `this.__bandwidth(${ref(args[0])})`, | ||
_range: args => `${ref(args[0])}.range()`, | ||
_scale: args => `${ref(args[0])}(${codegen(args[1])})` | ||
}; | ||
} | ||
@@ -192,25 +193,2 @@ | ||
function intersect(b, opt, group) { | ||
if (!b) return []; | ||
const [u, v] = b, | ||
box = new vegaScenegraph.Bounds().set(u[0], u[1], v[0], v[1]), | ||
scene = group || this.context.dataflow.scenegraph().root; | ||
return vegaScenegraph.intersect(scene, box, filter(opt)); | ||
} | ||
function filter(opt) { | ||
let p = null; | ||
if (opt) { | ||
const types = vegaUtil.array(opt.marktype), | ||
names = vegaUtil.array(opt.markname); | ||
p = _ => (!types.length || types.some(t => _.marktype === t)) | ||
&& (!names.length || names.some(s => _.name === s)); | ||
} | ||
return p; | ||
} | ||
function log(df, method, args) { | ||
@@ -237,2 +215,28 @@ try { | ||
// https://www.w3.org/TR/2008/REC-WCAG20-20081211/#relativeluminancedef | ||
function channel_luminance_value(channelValue) { | ||
const val = channelValue / 255; | ||
if (val <= 0.03928) { | ||
return val / 12.92; | ||
} | ||
return Math.pow((val + 0.055) / 1.055, 2.4); | ||
} | ||
function luminance(color) { | ||
const c = d3Color.rgb(color), | ||
r = channel_luminance_value(c.r), | ||
g = channel_luminance_value(c.g), | ||
b = channel_luminance_value(c.b); | ||
return 0.2126 * r + 0.7152 * g + 0.0722 * b; | ||
} | ||
// https://www.w3.org/TR/2008/REC-WCAG20-20081211/#contrast-ratiodef | ||
function contrast(color1, color2) { | ||
const lum1 = luminance(color1), | ||
lum2 = luminance(color2), | ||
lumL = Math.max(lum1, lum2), | ||
lumD = Math.min(lum1, lum2); | ||
return (lumL + 0.05) / (lumD + 0.05); | ||
} | ||
function merge() { | ||
@@ -337,2 +341,38 @@ var args = [].slice.call(arguments); | ||
function bandspace(count, paddingInner, paddingOuter) { | ||
return vegaScale.bandSpace(count || 0, paddingInner || 0, paddingOuter || 0); | ||
} | ||
function bandwidth(name, group) { | ||
const s = getScale(name, (group || this).context); | ||
return s && s.bandwidth ? s.bandwidth() : 0; | ||
} | ||
function copy(name, group) { | ||
const s = getScale(name, (group || this).context); | ||
return s ? s.copy() : undefined; | ||
} | ||
function domain(name, group) { | ||
const s = getScale(name, (group || this).context); | ||
return s ? s.domain() : []; | ||
} | ||
function invert(name, range, group) { | ||
const s = getScale(name, (group || this).context); | ||
return !s ? undefined | ||
: vegaUtil.isArray(range) ? (s.invertRange || s.invert)(range) | ||
: (s.invert || s.invertExtent)(range); | ||
} | ||
function range(name, group) { | ||
const s = getScale(name, (group || this).context); | ||
return s && s.range ? s.range() : []; | ||
} | ||
function scale(name, value, group) { | ||
const s = getScale(name, (group || this).context); | ||
return s && value !== undefined ? s(value) : undefined; | ||
} | ||
function scaleGradient(scale, p0, p1, count, group) { | ||
@@ -385,9 +425,7 @@ scale = getScale(scale, (group || this).context); | ||
const EMPTY = {}; | ||
const datum = d => d.data; | ||
function datum(d) { return d.data; } | ||
function treeNodes(name, context) { | ||
const tree = data.call(context, name); | ||
return tree.root && tree.root.lookup || EMPTY; | ||
return tree.root && tree.root.lookup || {}; | ||
} | ||
@@ -407,11 +445,13 @@ | ||
const _window = (typeof window !== 'undefined' && window) || null; | ||
const _window = () => (typeof window !== 'undefined' && window) || null; | ||
function screen() { | ||
return _window ? _window.screen : {}; | ||
const w = _window(); | ||
return w ? w.screen : {}; | ||
} | ||
function windowSize() { | ||
return _window | ||
? [_window.innerWidth, _window.innerHeight] | ||
const w = _window(); | ||
return w | ||
? [w.innerWidth, w.innerHeight] | ||
: [undefined, undefined]; | ||
@@ -428,61 +468,25 @@ } | ||
const DataPrefix = ':'; | ||
const IndexPrefix = '@'; | ||
const ScalePrefix = '%'; | ||
const SignalPrefix = '$'; | ||
function intersect(b, opt, group) { | ||
if (!b) return []; | ||
function dataVisitor(name, args, scope, params) { | ||
if (args[0].type !== vegaExpression.Literal) { | ||
vegaUtil.error('First argument to data functions must be a string literal.'); | ||
} | ||
const [u, v] = b, | ||
box = new vegaScenegraph.Bounds().set(u[0], u[1], v[0], v[1]), | ||
scene = group || this.context.dataflow.scenegraph().root; | ||
const data = args[0].value, | ||
dataName = DataPrefix + data; | ||
if (!vegaUtil.hasOwnProperty(dataName, params)) { | ||
try { | ||
params[dataName] = scope.getData(data).tuplesRef(); | ||
} catch (err) { | ||
// if data set does not exist, there's nothing to track | ||
} | ||
} | ||
return vegaScenegraph.intersect(scene, box, filter(opt)); | ||
} | ||
function indataVisitor(name, args, scope, params) { | ||
if (args[0].type !== vegaExpression.Literal) vegaUtil.error('First argument to indata must be a string literal.'); | ||
if (args[1].type !== vegaExpression.Literal) vegaUtil.error('Second argument to indata must be a string literal.'); | ||
function filter(opt) { | ||
let p = null; | ||
const data = args[0].value, | ||
field = args[1].value, | ||
indexName = IndexPrefix + field; | ||
if (!vegaUtil.hasOwnProperty(indexName, params)) { | ||
params[indexName] = scope.getData(data).indataRef(scope, field); | ||
if (opt) { | ||
const types = vegaUtil.array(opt.marktype), | ||
names = vegaUtil.array(opt.markname); | ||
p = _ => (!types.length || types.some(t => _.marktype === t)) | ||
&& (!names.length || names.some(s => _.name === s)); | ||
} | ||
} | ||
function scaleVisitor(name, args, scope, params) { | ||
if (args[0].type === vegaExpression.Literal) { | ||
// add scale dependency | ||
addScaleDependency(scope, params, args[0].value); | ||
} | ||
else if (args[0].type === vegaExpression.Identifier) { | ||
// indirect scale lookup; add all scales as parameters | ||
for (name in scope.scales) { | ||
addScaleDependency(scope, params, name); | ||
} | ||
} | ||
return p; | ||
} | ||
function addScaleDependency(scope, params, name) { | ||
const scaleName = ScalePrefix + name; | ||
if (!vegaUtil.hasOwnProperty(params, scaleName)) { | ||
try { | ||
params[scaleName] = scope.scaleRef(name); | ||
} catch (err) { | ||
// TODO: error handling? warning? | ||
} | ||
} | ||
} | ||
// Expression function context object | ||
@@ -589,2 +593,3 @@ const functionContext = { | ||
for (let name in functionContext) { fn[name] = thisPrefix + name; } | ||
vegaUtil.extend(fn, internalScaleFunctions(codegen, functionContext, astVisitors)); | ||
return fn; | ||
@@ -637,3 +642,3 @@ } | ||
fieldvar: 'datum', | ||
globalvar: function(id) { return '_[' + vegaUtil.stringValue(SignalPrefix + id) + ']'; }, | ||
globalvar: id => '_[' + vegaUtil.stringValue(SignalPrefix + id) + ']', | ||
functions: buildFunctions, | ||
@@ -646,14 +651,40 @@ constants: vegaExpression.constants, | ||
Object.defineProperty(exports, 'formatLocale', { | ||
enumerable: true, | ||
get: function () { | ||
return d3Format.formatDefaultLocale; | ||
function parser(expr, scope) { | ||
var params = {}, ast, gen; | ||
// parse the expression to an abstract syntax tree (ast) | ||
try { | ||
expr = vegaUtil.isString(expr) ? expr : (vegaUtil.stringValue(expr) + ''); | ||
ast = vegaExpression.parse(expr); | ||
} catch (err) { | ||
vegaUtil.error('Expression parse error: ' + expr); | ||
} | ||
}); | ||
Object.defineProperty(exports, 'timeFormatLocale', { | ||
enumerable: true, | ||
get: function () { | ||
return d3TimeFormat.timeFormatDefaultLocale; | ||
} | ||
}); | ||
// analyze ast function calls for dependencies | ||
ast.visit(node => { | ||
if (node.type !== vegaExpression.CallExpression) return; | ||
var name = node.callee.name, | ||
visit = codegenParams.visitors[name]; | ||
if (visit) visit(name, node.arguments, scope, params); | ||
}); | ||
// perform code generation | ||
gen = codeGenerator(ast); | ||
// collect signal dependencies | ||
gen.globals.forEach(name => { | ||
var signalName = SignalPrefix + name; | ||
if (!vegaUtil.hasOwnProperty(params, signalName) && scope.getSignal(name)) { | ||
params[signalName] = scope.signalRef(name); | ||
} | ||
}); | ||
// return generated expression code and dependencies | ||
return { | ||
$expr: vegaUtil.extend({code: gen.code}, scope.options.ast ? {ast} : null), | ||
$fields: gen.fields, | ||
$params: params | ||
}; | ||
} | ||
exports.DataPrefix = DataPrefix; | ||
@@ -694,2 +725,3 @@ exports.IndexPrefix = IndexPrefix; | ||
exports.monthFormat = monthFormat; | ||
exports.parseExpression = parser; | ||
exports.pathShape = pathShape; | ||
@@ -696,0 +728,0 @@ exports.pinchAngle = pinchAngle; |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("vega-expression"),require("vega-dataflow"),require("vega-selections"),require("vega-statistics"),require("vega-time"),require("vega-util"),require("d3-array"),require("d3-color"),require("d3-format"),require("d3-time-format"),require("vega-scale"),require("d3-geo"),require("vega-scenegraph")):"function"==typeof define&&define.amd?define(["exports","vega-expression","vega-dataflow","vega-selections","vega-statistics","vega-time","vega-util","d3-array","d3-color","d3-format","d3-time-format","vega-scale","d3-geo","vega-scenegraph"],e):e((t=t||self).vega={},t.vega,t.vega,t.vega,t.vega,t.vega,t.vega,t.d3,t.d3,t.d3,t.d3,t.vega,t.d3,t.vega)}(this,(function(t,e,n,r,o,i,a,c,u,s,l,f,m,d){"use strict";function g(t){const e=t/255;return e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4)}function p(t){const e=u.rgb(t);return.2126*g(e.r)+.7152*g(e.g)+.0722*g(e.b)}function h(t,e){const n=p(t),r=p(e);return(Math.max(n,r)+.05)/(Math.min(n,r)+.05)}function v(t){const e=this.context.data[t];return e?e.values.value:[]}function y(t,e,n){const r=this.context.data[t]["index:"+e],o=r?r.value.get(n):void 0;return o?o.count:o}function b(t,e){const n=this.context.dataflow,r=this.context.data[t].input;return n.pulse(r,n.changeset().remove(a.truthy).insert(e)),1}function x(t,e,n){if(t){const n=this.context.dataflow,r=t.mark.source;n.pulse(r,n.changeset().encode(t,e))}return void 0!==n?n:t}const w={};function S(t,e,n){let r=t+":"+n,o=w[r];return o&&o[0]===e||(w[r]=o=[e,e(n)]),o[1]}function q(t,e){return S("format",s.format,e)(t)}function P(t,e){return S("timeFormat",i.timeFormat,e)(t)}function L(t,e){return S("utcFormat",i.utcFormat,e)(t)}function F(t,e){return S("timeParse",l.timeParse,e)(t)}function N(t,e){return S("utcParse",l.utcParse,e)(t)}var A=new Date(2e3,0,1);function k(t,e,n){return Number.isInteger(t)&&Number.isInteger(e)?(A.setYear(2e3),A.setMonth(t),A.setDate(e),P(A,n)):""}function O(t){return k(t,1,"%B")}function D(t){return k(t,1,"%b")}function z(t){return k(0,2+t,"%A")}function R(t){return k(0,2+t,"%a")}function U(t,e){let n;return a.isFunction(t)?t:a.isString(t)?(n=e.scales[t])&&n.value:void 0}function B(t,e){const n=U(t,(e||this).context);return n&&n.range?n.range():[]}function j(t,e){const n=U(t,(e||this).context);return n?n.domain():[]}function E(t,e){const n=U(t,(e||this).context);return n&&n.bandwidth?n.bandwidth():0}function M(t,e,n){return f.bandSpace(t||0,e||0,n||0)}function V(t,e){const n=U(t,(e||this).context);return n?n.copy():void 0}function I(t,e,n){const r=U(t,(n||this).context);return r&&void 0!==e?r(e):void 0}function T(t,e,n){const r=U(t,(n||this).context);return r?a.isArray(e)?(r.invertRange||r.invert)(e):(r.invert||r.invertExtent)(e):void 0}function X(t,e){return function(n,r,o){if(n){const e=U(n,(o||this).context);return e&&e.path[t](r)}return e(r)}}const Y=X("area",m.geoArea),_=X("bounds",m.geoBounds),C=X("centroid",m.geoCentroid);function G(t){let e=this.context.group,n=!1;if(e)for(;t;){if(t===e){n=!0;break}t=t.mark.group}return n}function H(t,e,n){try{t[e].apply(t,["EXPRESSION"].concat([].slice.call(n)))}catch(e){t.warn(e)}return n[n.length-1]}function W(){return H(this.context.dataflow,"warn",arguments)}function $(){return H(this.context.dataflow,"info",arguments)}function J(){return H(this.context.dataflow,"debug",arguments)}function K(){var t=[].slice.call(arguments);return t.unshift({}),a.extend.apply(null,t)}function Q(t,e){return t===e||t!=t&&e!=e||(a.isArray(t)?!(!a.isArray(e)||t.length!==e.length)&&function(t,e){for(let n=0,r=t.length;n<r;++n)if(!Q(t[n],e[n]))return!1;return!0}(t,e):!(!a.isObject(t)||!a.isObject(e))&&Z(t,e))}function Z(t,e){for(let n in t)if(!Q(t[n],e[n]))return!1;return!0}function tt(t){return e=>Z(t,e)}function et(t,e,r,o,i,c){let u,s,l=this.context.dataflow,f=this.context.data[t],m=f.input,d=f.changes,g=l.stamp();if(!1===l._trigger||!(m.value.length||e||o))return 0;if((!d||d.stamp<g)&&(f.changes=d=l.changeset(),d.stamp=g,l.runAfter((function(){f.modified=!0,l.pulse(m,d).run()}),!0,1)),r&&(u=!0===r?a.truthy:a.isArray(r)||n.isTuple(r)?r:tt(r),d.remove(u)),e&&d.insert(e),o&&(u=tt(o),m.value.some(u)?d.remove(u):d.insert(o)),i)for(s in c)d.modify(i,s,c[s]);return 1}function nt(t){const e=t.touches,n=e[0].clientX-e[1].clientX,r=e[0].clientY-e[1].clientY;return Math.sqrt(n*n+r*r)}function rt(t){const e=t.touches;return Math.atan2(e[0].clientY-e[1].clientY,e[0].clientX-e[1].clientX)}function ot(t,e,n,r,o){t=U(t,(o||this).context);const i=d.Gradient(e,n);let c=t.domain(),u=c[0],s=a.peek(c),l=a.identity;return s-u?l=f.scaleFraction(t,u,s):t=(t.interpolator?f.scale("sequential")().interpolator(t.interpolator()):f.scale("linear")().interpolate(t.interpolate()).range(t.range())).domain([u=0,s=1]),t.ticks&&(c=t.ticks(+r||15),u!==c[0]&&c.unshift(u),s!==a.peek(c)&&c.push(s)),c.forEach(e=>i.stop(l(e),t(e))),i}function it(t,e,n){const r=U(t,(n||this).context);return function(t){return r?r.path.context(t)(e):""}}function at(t){let e=null;return function(n){return n?d.pathRender(n,e=e||d.pathParse(t)):t}}const ct={};function ut(t){return t.data}function st(t,e){const n=v.call(e,t);return n.root&&n.root.lookup||ct}function lt(t,e,n){const r=st(t,this),o=r[e],i=r[n];return o&&i?o.path(i).map(ut):void 0}function ft(t,e){const n=st(t,this)[e];return n?n.ancestors().map(ut):void 0}const mt="undefined"!=typeof window&&window||null;function dt(){return mt?mt.screen:{}}function gt(){return mt?[mt.innerWidth,mt.innerHeight]:[void 0,void 0]}function pt(){const t=this.context.dataflow,e=t.container&&t.container();return e?[e.clientWidth,e.clientHeight]:[void 0,void 0]}function ht(t,n,r,o){n[0].type!==e.Literal&&a.error("First argument to data functions must be a string literal.");const i=n[0].value,c=":"+i;if(!a.hasOwnProperty(c,o))try{o[c]=r.getData(i).tuplesRef()}catch(t){}}function vt(t,n,r,o){n[0].type!==e.Literal&&a.error("First argument to indata must be a string literal."),n[1].type!==e.Literal&&a.error("Second argument to indata must be a string literal.");const i=n[0].value,c=n[1].value,u="@"+c;a.hasOwnProperty(u,o)||(o[u]=r.getData(i).indataRef(r,c))}function yt(t,n,r,o){if(n[0].type===e.Literal)bt(r,o,n[0].value);else if(n[0].type===e.Identifier)for(t in r.scales)bt(r,o,t)}function bt(t,e,n){const r="%"+n;if(!a.hasOwnProperty(e,r))try{e[r]=t.scaleRef(n)}catch(t){}}const xt={random:function(){return o.random()},cumulativeNormal:o.cumulativeNormal,cumulativeLogNormal:o.cumulativeLogNormal,cumulativeUniform:o.cumulativeUniform,densityNormal:o.densityNormal,densityLogNormal:o.densityLogNormal,densityUniform:o.densityUniform,quantileNormal:o.quantileNormal,quantileLogNormal:o.quantileLogNormal,quantileUniform:o.quantileUniform,sampleNormal:o.sampleNormal,sampleLogNormal:o.sampleLogNormal,sampleUniform:o.sampleUniform,isArray:a.isArray,isBoolean:a.isBoolean,isDate:a.isDate,isDefined:function(t){return void 0!==t},isNumber:a.isNumber,isObject:a.isObject,isRegExp:a.isRegExp,isString:a.isString,isTuple:n.isTuple,isValid:function(t){return null!=t&&t==t},toBoolean:a.toBoolean,toDate:a.toDate,toNumber:a.toNumber,toString:a.toString,flush:a.flush,lerp:a.lerp,merge:K,pad:a.pad,peek:a.peek,span:a.span,inrange:a.inrange,truncate:a.truncate,rgb:u.rgb,lab:u.lab,hcl:u.hcl,hsl:u.hsl,luminance:p,contrast:h,sequence:c.range,format:q,utcFormat:L,utcParse:N,utcOffset:i.utcOffset,utcSequence:i.utcSequence,timeFormat:P,timeParse:F,timeOffset:i.timeOffset,timeSequence:i.timeSequence,timeUnitSpecifier:i.timeUnitSpecifier,monthFormat:O,monthAbbrevFormat:D,dayFormat:z,dayAbbrevFormat:R,quarter:a.quarter,utcquarter:a.utcquarter,week:i.week,utcweek:i.utcweek,dayofyear:i.dayofyear,utcdayofyear:i.utcdayofyear,warn:W,info:$,debug:J,extent:a.extent,inScope:G,intersect:function(t,e,n){if(!t)return[];const[r,o]=t,i=(new d.Bounds).set(r[0],r[1],o[0],o[1]),c=n||this.context.dataflow.scenegraph().root;return d.intersect(c,i,function(t){let e=null;if(t){const n=a.array(t.marktype),r=a.array(t.markname);e=t=>(!n.length||n.some(e=>t.marktype===e))&&(!r.length||r.some(e=>t.name===e))}return e}(e))},clampRange:a.clampRange,pinchDistance:nt,pinchAngle:rt,screen:dt,containerSize:pt,windowSize:gt,bandspace:M,setdata:b,pathShape:at,panLinear:a.panLinear,panLog:a.panLog,panPow:a.panPow,panSymlog:a.panSymlog,zoomLinear:a.zoomLinear,zoomLog:a.zoomLog,zoomPow:a.zoomPow,zoomSymlog:a.zoomSymlog,encode:x,modify:et},wt=["view","item","group","xy","x","y"],St={};function qt(t,e,n){return 1===arguments.length?xt[t]:(xt[t]=e,n&&(St[t]=n),Lt&&(Lt.functions[t]="this."+t),this)}qt("bandwidth",E,yt),qt("copy",V,yt),qt("domain",j,yt),qt("range",B,yt),qt("invert",T,yt),qt("scale",I,yt),qt("gradient",ot,yt),qt("geoArea",Y,yt),qt("geoBounds",_,yt),qt("geoCentroid",C,yt),qt("geoShape",it,yt),qt("indata",y,vt),qt("data",v,ht),qt("treePath",lt,ht),qt("treeAncestors",ft,ht),qt("vlSelectionTest",r.selectionTest,r.selectionVisitor),qt("vlSelectionResolve",r.selectionResolve,r.selectionVisitor);const Pt={blacklist:["_"],whitelist:["datum","event","item"],fieldvar:"datum",globalvar:function(t){return"_["+a.stringValue("$"+t)+"]"},functions:function(t){const n=e.functions(t);wt.forEach(t=>n[t]="event.vega."+t);for(let t in xt)n[t]="this."+t;return n},constants:e.constants,visitors:St};var Lt=e.codegen(Pt);Object.defineProperty(t,"formatLocale",{enumerable:!0,get:function(){return s.formatDefaultLocale}}),Object.defineProperty(t,"timeFormatLocale",{enumerable:!0,get:function(){return l.timeFormatDefaultLocale}}),t.DataPrefix=":",t.IndexPrefix="@",t.ScalePrefix="%",t.SignalPrefix="$",t.bandspace=M,t.bandwidth=E,t.codeGenerator=Lt,t.codegenParams=Pt,t.containerSize=pt,t.contrast=h,t.copy=V,t.data=v,t.dataVisitor=ht,t.dayAbbrevFormat=R,t.dayFormat=z,t.debug=J,t.domain=j,t.encode=x,t.expressionFunction=qt,t.format=q,t.functionContext=xt,t.geoArea=Y,t.geoBounds=_,t.geoCentroid=C,t.geoShape=it,t.inScope=G,t.indata=y,t.indataVisitor=vt,t.info=$,t.invert=T,t.luminance=p,t.merge=K,t.modify=et,t.monthAbbrevFormat=D,t.monthFormat=O,t.pathShape=at,t.pinchAngle=rt,t.pinchDistance=nt,t.range=B,t.scale=I,t.scaleGradient=ot,t.scaleVisitor=yt,t.screen=dt,t.setdata=b,t.timeFormat=P,t.timeParse=F,t.treeAncestors=ft,t.treePath=lt,t.utcFormat=L,t.utcParse=N,t.warn=W,t.windowSize=gt,Object.defineProperty(t,"__esModule",{value:!0})})); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("vega-util"),require("vega-expression"),require("d3-geo"),require("d3-color"),require("vega-dataflow"),require("vega-scale"),require("vega-scenegraph"),require("vega-selections"),require("vega-statistics"),require("vega-time"),require("d3-array")):"function"==typeof define&&define.amd?define(["exports","vega-util","vega-expression","d3-geo","d3-color","vega-dataflow","vega-scale","vega-scenegraph","vega-selections","vega-statistics","vega-time","d3-array"],e):e((t=t||self).vega={},t.vega,t.vega,t.d3,t.d3,t.vega,t.vega,t.vega,t.vega,t.vega,t.vega,t.d3)}(this,(function(t,e,n,r,a,o,i,s,c,u,l,f){"use strict";function d(t){const e=this.context.data[t];return e?e.values.value:[]}function m(t,e,n){const r=this.context.data[t]["index:"+e],a=r?r.value.get(n):void 0;return a?a.count:a}function g(t,n){const r=this.context.dataflow,a=this.context.data[t].input;return r.pulse(a,r.changeset().remove(e.truthy).insert(n)),1}function p(t,e,n){if(t){const n=this.context.dataflow,r=t.mark.source;n.pulse(r,n.changeset().encode(t,e))}return void 0!==n?n:t}const h=t=>function(e,n){return this.context.dataflow.locale()[t](n)(e)},v=h("format"),y=h("timeFormat"),x=h("utcFormat"),b=h("timeParse"),w=h("utcParse");var S=new Date(2e3,0,1);function q(t,e,n){return Number.isInteger(t)&&Number.isInteger(e)?(S.setYear(2e3),S.setMonth(t),S.setDate(e),y.call(this,S,n)):""}function P(t){return q.call(this,t,1,"%B")}function N(t){return q.call(this,t,1,"%b")}function L(t){return q.call(this,0,2+t,"%A")}function A(t){return q.call(this,0,2+t,"%a")}function F(t,r,a,o){r[0].type!==n.Literal&&e.error("First argument to data functions must be a string literal.");const i=r[0].value,s=":"+i;if(!e.hasOwnProperty(s,o))try{o[s]=a.getData(i).tuplesRef()}catch(t){}}function k(t,r,a,o){r[0].type!==n.Literal&&e.error("First argument to indata must be a string literal."),r[1].type!==n.Literal&&e.error("Second argument to indata must be a string literal.");const i=r[0].value,s=r[1].value,c="@"+s;e.hasOwnProperty(c,o)||(o[c]=a.getData(i).indataRef(a,s))}function _(t,e,r,a){if(e[0].type===n.Literal)O(r,a,e[0].value);else for(t in r.scales)O(r,a,t)}function O(t,n,r){const a="%"+r;if(!e.hasOwnProperty(n,a))try{n[a]=t.scaleRef(r)}catch(t){}}function R(t,n){let r;return e.isFunction(t)?t:e.isString(t)?(r=n.scales[t])&&r.value:void 0}function z(t,e){return function(n,r,a){if(n){const e=R(n,(a||this).context);return e&&e.path[t](r)}return e(r)}}const D=z("area",r.geoArea),E=z("bounds",r.geoBounds),U=z("centroid",r.geoCentroid);function V(t){let e=this.context.group,n=!1;if(e)for(;t;){if(t===e){n=!0;break}t=t.mark.group}return n}function B(t,e,n){try{t[e].apply(t,["EXPRESSION"].concat([].slice.call(n)))}catch(e){t.warn(e)}return n[n.length-1]}function $(){return B(this.context.dataflow,"warn",arguments)}function M(){return B(this.context.dataflow,"info",arguments)}function j(){return B(this.context.dataflow,"debug",arguments)}function C(t){const e=t/255;return e<=.03928?e/12.92:Math.pow((e+.055)/1.055,2.4)}function T(t){const e=a.rgb(t);return.2126*C(e.r)+.7152*C(e.g)+.0722*C(e.b)}function X(t,e){const n=T(t),r=T(e);return(Math.max(n,r)+.05)/(Math.min(n,r)+.05)}function Y(){var t=[].slice.call(arguments);return t.unshift({}),e.extend.apply(null,t)}function I(t,n){return t===n||t!=t&&n!=n||(e.isArray(t)?!(!e.isArray(n)||t.length!==n.length)&&function(t,e){for(let n=0,r=t.length;n<r;++n)if(!I(t[n],e[n]))return!1;return!0}(t,n):!(!e.isObject(t)||!e.isObject(n))&&G(t,n))}function G(t,e){for(let n in t)if(!I(t[n],e[n]))return!1;return!0}function H(t){return e=>G(t,e)}function W(t,n,r,a,i,s){let c,u,l=this.context.dataflow,f=this.context.data[t],d=f.input,m=f.changes,g=l.stamp();if(!1===l._trigger||!(d.value.length||n||a))return 0;if((!m||m.stamp<g)&&(f.changes=m=l.changeset(),m.stamp=g,l.runAfter((function(){f.modified=!0,l.pulse(d,m).run()}),!0,1)),r&&(c=!0===r?e.truthy:e.isArray(r)||o.isTuple(r)?r:H(r),m.remove(c)),n&&m.insert(n),a&&(c=H(a),d.value.some(c)?m.remove(c):m.insert(a)),i)for(u in s)m.modify(i,u,s[u]);return 1}function J(t){const e=t.touches,n=e[0].clientX-e[1].clientX,r=e[0].clientY-e[1].clientY;return Math.sqrt(n*n+r*r)}function K(t){const e=t.touches;return Math.atan2(e[0].clientY-e[1].clientY,e[0].clientX-e[1].clientX)}function Q(t,e,n){return i.bandSpace(t||0,e||0,n||0)}function Z(t,e){const n=R(t,(e||this).context);return n&&n.bandwidth?n.bandwidth():0}function tt(t,e){const n=R(t,(e||this).context);return n?n.copy():void 0}function et(t,e){const n=R(t,(e||this).context);return n?n.domain():[]}function nt(t,n,r){const a=R(t,(r||this).context);return a?e.isArray(n)?(a.invertRange||a.invert)(n):(a.invert||a.invertExtent)(n):void 0}function rt(t,e){const n=R(t,(e||this).context);return n&&n.range?n.range():[]}function at(t,e,n){const r=R(t,(n||this).context);return r&&void 0!==e?r(e):void 0}function ot(t,n,r,a,o){t=R(t,(o||this).context);const c=s.Gradient(n,r);let u=t.domain(),l=u[0],f=e.peek(u),d=e.identity;return f-l?d=i.scaleFraction(t,l,f):t=(t.interpolator?i.scale("sequential")().interpolator(t.interpolator()):i.scale("linear")().interpolate(t.interpolate()).range(t.range())).domain([l=0,f=1]),t.ticks&&(u=t.ticks(+a||15),l!==u[0]&&u.unshift(l),f!==e.peek(u)&&u.push(f)),u.forEach(e=>c.stop(d(e),t(e))),c}function it(t,e,n){const r=R(t,(n||this).context);return function(t){return r?r.path.context(t)(e):""}}function st(t){let e=null;return function(n){return n?s.pathRender(n,e=e||s.pathParse(t)):t}}const ct=t=>t.data;function ut(t,e){const n=d.call(e,t);return n.root&&n.root.lookup||{}}function lt(t,e,n){const r=ut(t,this),a=r[e],o=r[n];return a&&o?a.path(o).map(ct):void 0}function ft(t,e){const n=ut(t,this)[e];return n?n.ancestors().map(ct):void 0}const dt=()=>"undefined"!=typeof window&&window||null;function mt(){const t=dt();return t?t.screen:{}}function gt(){const t=dt();return t?[t.innerWidth,t.innerHeight]:[void 0,void 0]}function pt(){const t=this.context.dataflow,e=t.container&&t.container();return e?[e.clientWidth,e.clientHeight]:[void 0,void 0]}const ht={random:function(){return u.random()},cumulativeNormal:u.cumulativeNormal,cumulativeLogNormal:u.cumulativeLogNormal,cumulativeUniform:u.cumulativeUniform,densityNormal:u.densityNormal,densityLogNormal:u.densityLogNormal,densityUniform:u.densityUniform,quantileNormal:u.quantileNormal,quantileLogNormal:u.quantileLogNormal,quantileUniform:u.quantileUniform,sampleNormal:u.sampleNormal,sampleLogNormal:u.sampleLogNormal,sampleUniform:u.sampleUniform,isArray:e.isArray,isBoolean:e.isBoolean,isDate:e.isDate,isDefined:function(t){return void 0!==t},isNumber:e.isNumber,isObject:e.isObject,isRegExp:e.isRegExp,isString:e.isString,isTuple:o.isTuple,isValid:function(t){return null!=t&&t==t},toBoolean:e.toBoolean,toDate:e.toDate,toNumber:e.toNumber,toString:e.toString,flush:e.flush,lerp:e.lerp,merge:Y,pad:e.pad,peek:e.peek,span:e.span,inrange:e.inrange,truncate:e.truncate,rgb:a.rgb,lab:a.lab,hcl:a.hcl,hsl:a.hsl,luminance:T,contrast:X,sequence:f.range,format:v,utcFormat:x,utcParse:w,utcOffset:l.utcOffset,utcSequence:l.utcSequence,timeFormat:y,timeParse:b,timeOffset:l.timeOffset,timeSequence:l.timeSequence,timeUnitSpecifier:l.timeUnitSpecifier,monthFormat:P,monthAbbrevFormat:N,dayFormat:L,dayAbbrevFormat:A,quarter:e.quarter,utcquarter:e.utcquarter,week:l.week,utcweek:l.utcweek,dayofyear:l.dayofyear,utcdayofyear:l.utcdayofyear,warn:$,info:M,debug:j,extent:e.extent,inScope:V,intersect:function(t,n,r){if(!t)return[];const[a,o]=t,i=(new s.Bounds).set(a[0],a[1],o[0],o[1]),c=r||this.context.dataflow.scenegraph().root;return s.intersect(c,i,function(t){let n=null;if(t){const r=e.array(t.marktype),a=e.array(t.markname);n=t=>(!r.length||r.some(e=>t.marktype===e))&&(!a.length||a.some(e=>t.name===e))}return n}(n))},clampRange:e.clampRange,pinchDistance:J,pinchAngle:K,screen:mt,containerSize:pt,windowSize:gt,bandspace:Q,setdata:g,pathShape:st,panLinear:e.panLinear,panLog:e.panLog,panPow:e.panPow,panSymlog:e.panSymlog,zoomLinear:e.zoomLinear,zoomLog:e.zoomLog,zoomPow:e.zoomPow,zoomSymlog:e.zoomSymlog,encode:p,modify:W},vt=["view","item","group","xy","x","y"],yt={};function xt(t,e,n){return 1===arguments.length?ht[t]:(ht[t]=e,n&&(yt[t]=n),wt&&(wt.functions[t]="this."+t),this)}xt("bandwidth",Z,_),xt("copy",tt,_),xt("domain",et,_),xt("range",rt,_),xt("invert",nt,_),xt("scale",at,_),xt("gradient",ot,_),xt("geoArea",D,_),xt("geoBounds",E,_),xt("geoCentroid",U,_),xt("geoShape",it,_),xt("indata",m,k),xt("data",d,F),xt("treePath",lt,F),xt("treeAncestors",ft,F),xt("vlSelectionTest",c.selectionTest,c.selectionVisitor),xt("vlSelectionResolve",c.selectionResolve,c.selectionVisitor);const bt={blacklist:["_"],whitelist:["datum","event","item"],fieldvar:"datum",globalvar:t=>"_["+e.stringValue("$"+t)+"]",functions:function(t){const r=n.functions(t);vt.forEach(t=>r[t]="event.vega."+t);for(let t in ht)r[t]="this."+t;return e.extend(r,function(t,r,a){r.__bandwidth=t=>t&&t.bandwidth?t.bandwidth():0,a._bandwidth=_,a._range=_,a._scale=_;const o=r=>"_["+(r.type===n.Literal?e.stringValue("%"+r.value):e.stringValue("%")+"+"+t(r))+"]";return{_bandwidth:t=>`this.__bandwidth(${o(t[0])})`,_range:t=>o(t[0])+".range()",_scale:e=>`${o(e[0])}(${t(e[1])})`}}(t,ht,yt)),r},constants:n.constants,visitors:yt};var wt=n.codegen(bt);t.DataPrefix=":",t.IndexPrefix="@",t.ScalePrefix="%",t.SignalPrefix="$",t.bandspace=Q,t.bandwidth=Z,t.codeGenerator=wt,t.codegenParams=bt,t.containerSize=pt,t.contrast=X,t.copy=tt,t.data=d,t.dataVisitor=F,t.dayAbbrevFormat=A,t.dayFormat=L,t.debug=j,t.domain=et,t.encode=p,t.expressionFunction=xt,t.format=v,t.functionContext=ht,t.geoArea=D,t.geoBounds=E,t.geoCentroid=U,t.geoShape=it,t.inScope=V,t.indata=m,t.indataVisitor=k,t.info=M,t.invert=nt,t.luminance=T,t.merge=Y,t.modify=W,t.monthAbbrevFormat=N,t.monthFormat=P,t.parseExpression=function(t,r){var a,o,i={};try{t=e.isString(t)?t:e.stringValue(t)+"",a=n.parse(t)}catch(n){e.error("Expression parse error: "+t)}return a.visit(t=>{if(t.type===n.CallExpression){var e=t.callee.name,a=bt.visitors[e];a&&a(e,t.arguments,r,i)}}),(o=wt(a)).globals.forEach(t=>{var n="$"+t;!e.hasOwnProperty(i,n)&&r.getSignal(t)&&(i[n]=r.signalRef(t))}),{$expr:e.extend({code:o.code},r.options.ast?{ast:a}:null),$fields:o.fields,$params:i}},t.pathShape=st,t.pinchAngle=K,t.pinchDistance=J,t.range=rt,t.scale=at,t.scaleGradient=ot,t.scaleVisitor=_,t.screen=mt,t.setdata=g,t.timeFormat=y,t.timeParse=b,t.treeAncestors=ft,t.treePath=lt,t.utcFormat=x,t.utcParse=w,t.warn=$,t.windowSize=gt,Object.defineProperty(t,"__esModule",{value:!0})})); |
70
index.js
export { | ||
codegenParams, | ||
codeGenerator, | ||
expressionFunction, | ||
functionContext | ||
} from './src/codegen'; | ||
export { | ||
data, | ||
indata, | ||
setdata | ||
} from './src/data'; | ||
} from './src/functions/data'; | ||
export { | ||
default as encode | ||
} from './src/encode'; | ||
} from './src/functions/encode'; | ||
@@ -28,3 +21,3 @@ export { | ||
dayAbbrevFormat | ||
} from './src/format'; | ||
} from './src/functions/format'; | ||
@@ -35,7 +28,7 @@ export { | ||
geoCentroid | ||
} from './src/geo'; | ||
} from './src/functions/geo'; | ||
export { | ||
default as inScope | ||
} from './src/inscope'; | ||
} from './src/functions/inscope'; | ||
@@ -46,3 +39,3 @@ export { | ||
debug | ||
} from './src/log'; | ||
} from './src/functions/log'; | ||
@@ -52,11 +45,11 @@ export { | ||
contrast | ||
} from './src/luminance'; | ||
} from './src/functions/luminance'; | ||
export { | ||
default as merge | ||
} from './src/merge'; | ||
} from './src/functions/merge'; | ||
export { | ||
default as modify | ||
} from './src/modify'; | ||
} from './src/functions/modify'; | ||
@@ -66,12 +59,5 @@ export { | ||
pinchAngle | ||
} from './src/pinch'; | ||
} from './src/functions/pinch'; | ||
export { | ||
DataPrefix, | ||
IndexPrefix, | ||
ScalePrefix, | ||
SignalPrefix | ||
} from './src/prefix.js'; | ||
export { | ||
range, | ||
@@ -84,7 +70,7 @@ domain, | ||
invert | ||
} from './src/scale'; | ||
} from './src/functions/scale'; | ||
export { | ||
default as scaleGradient | ||
} from './src/scale-gradient'; | ||
} from './src/functions/scale-gradient'; | ||
@@ -94,3 +80,3 @@ export { | ||
pathShape | ||
} from './src/shape'; | ||
} from './src/functions/shape'; | ||
@@ -100,3 +86,3 @@ export { | ||
treeAncestors | ||
} from './src/tree'; | ||
} from './src/functions/tree'; | ||
@@ -107,5 +93,23 @@ export { | ||
windowSize | ||
} from './src/window'; | ||
} from './src/functions/window'; | ||
export { | ||
codegenParams, | ||
codeGenerator, | ||
expressionFunction, | ||
functionContext | ||
} from './src/codegen'; | ||
export { | ||
DataPrefix, | ||
IndexPrefix, | ||
ScalePrefix, | ||
SignalPrefix | ||
} from './src/constants.js'; | ||
export { | ||
default as parseExpression | ||
} from './src/parser'; | ||
export { | ||
dataVisitor, | ||
@@ -115,9 +119,1 @@ indataVisitor, | ||
} from './src/visitors'; | ||
export { | ||
formatDefaultLocale as formatLocale | ||
} from 'd3-format'; | ||
export { | ||
timeFormatDefaultLocale as timeFormatLocale | ||
} from 'd3-time-format'; |
{ | ||
"name": "vega-functions", | ||
"version": "5.6.0", | ||
"version": "5.7.0", | ||
"description": "Custom functions for the Vega expression language.", | ||
@@ -16,3 +16,3 @@ "keywords": [ | ||
"scripts": { | ||
"rollup": "rollup -g d3-array:d3,d3-color:d3,d3-format:d3,d3-geo:d3,d3-time-format:d3,vega-dataflow:vega,vega-expression:vega,vega-scale:vega,vega-scenegraph:vega,vega-selections:vega,vega-statistics:vega,vega-time:vega,vega-util:vega -f umd -n vega -o build/vega-functions.js -- index.js", | ||
"rollup": "rollup -g d3-array:d3,d3-color:d3,d3-geo:d3,vega-dataflow:vega,vega-expression:vega,vega-scale:vega,vega-scenegraph:vega,vega-selections:vega,vega-statistics:vega,vega-time:vega,vega-util:vega -f umd -n vega -o build/vega-functions.js -- index.js", | ||
"prebuild": "rimraf build && mkdir build", | ||
@@ -29,15 +29,16 @@ "build": "yarn rollup", | ||
"d3-color": "^1.4.1", | ||
"d3-format": "^1.4.4", | ||
"d3-geo": "^1.12.0", | ||
"d3-time-format": "^2.2.3", | ||
"vega-dataflow": "^5.5.1", | ||
"vega-expression": "^2.6.4", | ||
"vega-scale": "^6.1.0", | ||
"vega-scenegraph": "^4.7.0", | ||
"vega-dataflow": "^5.6.0", | ||
"vega-expression": "^2.6.5", | ||
"vega-scale": "^7.0.0", | ||
"vega-scenegraph": "^4.8.0", | ||
"vega-selections": "^5.1.1", | ||
"vega-statistics": "^1.7.4", | ||
"vega-time": "^1.1.0", | ||
"vega-util": "^1.13.2" | ||
"vega-statistics": "^1.7.5", | ||
"vega-time": "^2.0.0", | ||
"vega-util": "^1.14.0" | ||
}, | ||
"gitHead": "35e31c5c6b54db9dc3a577b5adad8d15ec274d32" | ||
"devDependencies": { | ||
"vega-format": "^1.0.0" | ||
}, | ||
"gitHead": "48c85218f2202242171aa569f2dca0f53cf2b51f" | ||
} |
@@ -47,2 +47,3 @@ import { | ||
clampRange, | ||
extend, | ||
extent, | ||
@@ -94,3 +95,3 @@ flush, | ||
luminance | ||
} from './luminance'; | ||
} from './functions/luminance'; | ||
@@ -101,7 +102,5 @@ import { | ||
setdata | ||
} from './data'; | ||
} from './functions/data'; | ||
import { | ||
default as encode | ||
} from './encode'; | ||
import encode from './functions/encode'; | ||
@@ -118,3 +117,3 @@ import { | ||
utcParse | ||
} from './format'; | ||
} from './functions/format'; | ||
@@ -125,11 +124,7 @@ import { | ||
geoCentroid | ||
} from './geo'; | ||
} from './functions/geo'; | ||
import { | ||
default as inScope | ||
} from './inscope'; | ||
import inScope from './functions/inscope'; | ||
import { | ||
default as intersect | ||
} from './intersect'; | ||
import intersect from './functions/intersect'; | ||
@@ -140,11 +135,7 @@ import { | ||
warn | ||
} from './log'; | ||
} from './functions/log'; | ||
import { | ||
default as merge | ||
} from './merge'; | ||
import merge from './functions/merge'; | ||
import { | ||
default as modify | ||
} from './modify'; | ||
import modify from './functions/modify'; | ||
@@ -154,3 +145,3 @@ import { | ||
pinchDistance | ||
} from './pinch'; | ||
} from './functions/pinch'; | ||
@@ -165,7 +156,5 @@ import { | ||
scale | ||
} from './scale'; | ||
} from './functions/scale'; | ||
import { | ||
default as scaleGradient | ||
} from './scale-gradient'; | ||
import scaleGradient from './functions/scale-gradient'; | ||
@@ -175,3 +164,3 @@ import { | ||
pathShape | ||
} from './shape'; | ||
} from './functions/shape'; | ||
@@ -181,3 +170,3 @@ import { | ||
treePath | ||
} from './tree'; | ||
} from './functions/tree'; | ||
@@ -188,5 +177,13 @@ import { | ||
windowSize | ||
} from './window'; | ||
} from './functions/window'; | ||
import { | ||
SignalPrefix | ||
} from './constants'; | ||
import { | ||
internalScaleFunctions | ||
} from './scales'; | ||
import { | ||
dataVisitor, | ||
@@ -197,4 +194,2 @@ indataVisitor, | ||
import {SignalPrefix} from './prefix'; | ||
// Expression function context object | ||
@@ -301,2 +296,3 @@ export const functionContext = { | ||
for (let name in functionContext) { fn[name] = thisPrefix + name; } | ||
extend(fn, internalScaleFunctions(codegen, functionContext, astVisitors)); | ||
return fn; | ||
@@ -349,3 +345,3 @@ } | ||
fieldvar: 'datum', | ||
globalvar: function(id) { return '_[' + stringValue(SignalPrefix + id) + ']'; }, | ||
globalvar: id => '_[' + stringValue(SignalPrefix + id) + ']', | ||
functions: buildFunctions, | ||
@@ -352,0 +348,0 @@ constants: constants, |
@@ -1,3 +0,3 @@ | ||
import {DataPrefix, IndexPrefix, ScalePrefix} from './prefix'; | ||
import {Identifier, Literal} from 'vega-expression'; | ||
import {DataPrefix, IndexPrefix, ScalePrefix} from './constants'; | ||
import {Literal} from 'vega-expression'; | ||
import {error, hasOwnProperty} from 'vega-util'; | ||
@@ -39,4 +39,3 @@ | ||
addScaleDependency(scope, params, args[0].value); | ||
} | ||
else if (args[0].type === Identifier) { | ||
} else { | ||
// indirect scale lookup; add all scales as parameters | ||
@@ -43,0 +42,0 @@ for (name in scope.scales) { |
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
65138
11
27
1484
1
- Removedd3-format@^1.4.4
- Removedd3-time-format@^2.2.3
- Removedd3-format@1.4.5(transitive)
- Removedd3-interpolate@1.4.0(transitive)
- Removedd3-scale@3.3.0(transitive)
- Removedd3-time@1.1.02.1.1(transitive)
- Removedd3-time-format@2.3.0(transitive)
- Removedvega-scale@6.1.0(transitive)
- Removedvega-time@1.1.0(transitive)
Updatedvega-dataflow@^5.6.0
Updatedvega-expression@^2.6.5
Updatedvega-scale@^7.0.0
Updatedvega-scenegraph@^4.8.0
Updatedvega-statistics@^1.7.5
Updatedvega-time@^2.0.0
Updatedvega-util@^1.14.0