Bar graph added.

This commit is contained in:
prabhatdev
2020-07-28 00:48:25 +05:30
parent d0a6e2667d
commit 194b41124d
3468 changed files with 640611 additions and 169 deletions

27
node_modules/vega-functions/LICENSE generated vendored Normal file
View File

@@ -0,0 +1,27 @@
Copyright (c) 2015-2018, University of Washington Interactive Data Lab
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

137
node_modules/vega-functions/README.md generated vendored Normal file
View File

@@ -0,0 +1,137 @@
# vega-functions
Function implementations for the [Vega expression language](https://vega.github.io/vega/docs/expressions/). Unlike the basic utility functions included in the [vega-expression](https://github.com/vega/vega/tree/master/packages/vega-expression) package, this package includes custom expression functions, many of which are specific to Vega dataflows.
## Provided Functions
This package provides the following expression functions. All other constants and functions are provided by the base [vega-expression](https://github.com/vega/vega/tree/master/packages/vega-expression) package.
**Type Checking Functions**
- [isArray](https://vega.github.io/vega/docs/expressions/#isArray)
- [isBoolean](https://vega.github.io/vega/docs/expressions/#isBoolean)
- [isDate](https://vega.github.io/vega/docs/expressions/#isDate)
- [isNumber](https://vega.github.io/vega/docs/expressions/#isNumber)
- [isObject](https://vega.github.io/vega/docs/expressions/#isObject)
- [isRegExp](https://vega.github.io/vega/docs/expressions/#isRegExp)
- [isString](https://vega.github.io/vega/docs/expressions/#isString)
- [isTuple](https://vega.github.io/vega/docs/expressions/#isTuple)
**Type Coercion Functions**
- [toBoolean](https://vega.github.io/vega/docs/expressions/#toBoolean)
- [toDate](https://vega.github.io/vega/docs/expressions/#toDate)
- [toNumber](https://vega.github.io/vega/docs/expressions/#toNumber)
- [toString](https://vega.github.io/vega/docs/expressions/#toString)
**Math Functions**
- [random](https://vega.github.io/vega/docs/expressions/#random)
**Date/Time Functions**
- [quarter](https://vega.github.io/vega/docs/expressions/#quarter)
- [utcquarter](https://vega.github.io/vega/docs/expressions/#utcquarter)
**Array Functions**
- [clampRange](https://vega.github.io/vega/docs/expressions/#clampRange)
- [extent](https://vega.github.io/vega/docs/expressions/#extent)
- [inrange](https://vega.github.io/vega/docs/expressions/#inrange)
- [lerp](https://vega.github.io/vega/docs/expressions/#lerp)
- [peek](https://vega.github.io/vega/docs/expressions/#peek)
- [sequence](https://vega.github.io/vega/docs/expressions/#sequence)
- [span](https://vega.github.io/vega/docs/expressions/#span)
**String Functions**
- [pad](https://vega.github.io/vega/docs/expressions/#pad)
- [truncate](https://vega.github.io/vega/docs/expressions/#truncate)
**Object Functions**
- [merge](https://vega.github.io/vega/docs/expressions/#merge)
**Formatting Functions**
- [format](https://vega.github.io/vega/docs/expressions/#format)
- [utcFormat](https://vega.github.io/vega/docs/expressions/#utcFormat)
- [utcParse](https://vega.github.io/vega/docs/expressions/#utcParse)
- [timeFormat](https://vega.github.io/vega/docs/expressions/#timeFormat)
- [timeParse](https://vega.github.io/vega/docs/expressions/#timeParse)
- [monthFormat](https://vega.github.io/vega/docs/expressions/#monthFormat)
- [monthAbbrevFormat](https://vega.github.io/vega/docs/expressions/#monthAbbrevFormat)
- [dayFormat](https://vega.github.io/vega/docs/expressions/#dayFormat)
- [dayAbbrevFormat](https://vega.github.io/vega/docs/expressions/#dayAbbrevFormat)
**Color Functions**
- [rgb](https://vega.github.io/vega/docs/expressions/#rgb)
- [lab](https://vega.github.io/vega/docs/expressions/#lab)
- [hcl](https://vega.github.io/vega/docs/expressions/#hcl)
- [hsl](https://vega.github.io/vega/docs/expressions/#hsl)
**Event Functions**
- [pinchDistance](https://vega.github.io/vega/docs/expressions/#pinchDistance)
- [pinchAngle](https://vega.github.io/vega/docs/expressions/#pinchAngle)
- [inScope](https://vega.github.io/vega/docs/expressions/#inScope)
**Scale and Projection Functions**
- [bandspace](https://vega.github.io/vega/docs/expressions/#bandspace)
- [bandwidth](https://vega.github.io/vega/docs/expressions/#bandwidth)
- [copy](https://vega.github.io/vega/docs/expressions/#copy)
- [domain](https://vega.github.io/vega/docs/expressions/#domain)
- [gradient](https://vega.github.io/vega/docs/expressions/#gradient)
- [invert](https://vega.github.io/vega/docs/expressions/#invert)
- [range](https://vega.github.io/vega/docs/expressions/#range)
- [scale](https://vega.github.io/vega/docs/expressions/#scale)
- [panLinear](https://vega.github.io/vega/docs/expressions/#panLinear)
- [panLog](https://vega.github.io/vega/docs/expressions/#panLog)
- [panPow](https://vega.github.io/vega/docs/expressions/#panPow)
- [panSymlog](https://vega.github.io/vega/docs/expressions/#panSymlog)
- [zoomLinear](https://vega.github.io/vega/docs/expressions/#zoomLinear)
- [zoomLog](https://vega.github.io/vega/docs/expressions/#zoomLog)
- [zoomPow](https://vega.github.io/vega/docs/expressions/#zoomPow)
- [zoomSymlog](https://vega.github.io/vega/docs/expressions/#zoomSymlog)
- flush (used internally for axis and legend label layout)
**Geographic Functions**
- [geoArea](https://vega.github.io/vega/docs/expressions/#geoArea)
- [geoBounds](https://vega.github.io/vega/docs/expressions/#geoBounds)
- [geoCentroid](https://vega.github.io/vega/docs/expressions/#geoCentroid)
**Shape Functions**
- geoShape (used internally for mark clipping)
- pathShape (used internally for mark clipping)
**Data Functions**
- [indata](https://vega.github.io/vega/docs/expressions/#indata)
- [data](https://vega.github.io/vega/docs/expressions/#data)
- setdata (used internally for scale domain data)
- modify (used internally for trigger updates)
**Dataflow Functions**
- encode (used internally for signal updates)
**Tree (Hierarchy) Functions**
- [treePath](https://vega.github.io/vega/docs/expressions/#treePath)
- [treeAncestors](https://vega.github.io/vega/docs/expressions/#treeAncestors)
**Browser Functions**
- [screen](https://vega.github.io/vega/docs/expressions/#screen)
- [containerSize](https://vega.github.io/vega/docs/expressions/#containerSize)
- [windowSize](https://vega.github.io/vega/docs/expressions/#windowSize)
**Logging Functions**
- [warn](https://vega.github.io/vega/docs/expressions/#warn)
- [info](https://vega.github.io/vega/docs/expressions/#info)
- [debug](https://vega.github.io/vega/docs/expressions/#debug)

735
node_modules/vega-functions/build/vega-functions.js generated vendored Normal file
View File

@@ -0,0 +1,735 @@
(function (global, factory) {
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';
function data(name) {
const data = this.context.data[name];
return data ? data.values.value : [];
}
function indata(name, field, value) {
const index = this.context.data[name]['index:' + field],
entry = index ? index.value.get(value) : undefined;
return entry ? entry.count : entry;
}
function setdata(name, tuples) {
const df = this.context.dataflow,
data = this.context.data[name],
input = data.input;
df.pulse(input, df.changeset().remove(vegaUtil.truthy).insert(tuples));
return 1;
}
function encode(item, name, retval) {
if (item) {
const df = this.context.dataflow,
target = item.mark.source;
df.pulse(target, df.changeset().encode(item, name));
}
return retval !== undefined ? retval : item;
}
const wrap = method => function(value, spec) {
const locale = this.context.dataflow.locale();
return locale[method](spec)(value);
};
const format = wrap('format');
const timeFormat = wrap('timeFormat');
const utcFormat = wrap('utcFormat');
const timeParse = wrap('timeParse');
const utcParse = wrap('utcParse');
var dateObj = new Date(2000, 0, 1);
function time(month, day, specifier) {
if (!Number.isInteger(month) || !Number.isInteger(day)) return '';
dateObj.setYear(2000);
dateObj.setMonth(month);
dateObj.setDate(day);
return timeFormat.call(this, dateObj, specifier);
}
function monthFormat(month) {
return time.call(this, month, 1, '%B');
}
function monthAbbrevFormat(month) {
return time.call(this, month, 1, '%b');
}
function dayFormat(day) {
return time.call(this, 0, 2 + day, '%A');
}
function dayAbbrevFormat(day) {
return time.call(this, 0, 2 + day, '%a');
}
const DataPrefix = ':';
const IndexPrefix = '@';
const ScalePrefix = '%';
const SignalPrefix = '$';
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 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 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 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 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 getScale(name, ctx) {
let s;
return vegaUtil.isFunction(name) ? name
: vegaUtil.isString(name) ? (s = ctx.scales[name]) && s.value
: undefined;
}
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])})`
};
}
function geoMethod(methodName, globalMethod) {
return function(projection, geojson, group) {
if (projection) {
// projection defined, use it
const p = getScale(projection, (group || this).context);
return p && p.path[methodName](geojson);
} else {
// projection undefined, use global method
return globalMethod(geojson);
}
};
}
const geoArea = geoMethod('area', d3Geo.geoArea);
const geoBounds = geoMethod('bounds', d3Geo.geoBounds);
const geoCentroid = geoMethod('centroid', d3Geo.geoCentroid);
function inScope(item) {
let group = this.context.group,
value = false;
if (group) while (item) {
if (item === group) { value = true; break; }
item = item.mark.group;
}
return value;
}
function log(df, method, args) {
try {
df[method].apply(df, ['EXPRESSION'].concat([].slice.call(args)));
} catch (err) {
df.warn(err);
}
return args[args.length-1];
}
function warn() {
return log(this.context.dataflow, 'warn', arguments);
}
function info() {
return log(this.context.dataflow, 'info', arguments);
}
function debug() {
return log(this.context.dataflow, 'debug', arguments);
}
// 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() {
var args = [].slice.call(arguments);
args.unshift({});
return vegaUtil.extend.apply(null, args);
}
function equal(a, b) {
return a === b || a !== a && b !== b ? true
: vegaUtil.isArray(a) ? (
vegaUtil.isArray(b) && a.length === b.length ? equalArray(a, b) : false
)
: vegaUtil.isObject(a) && vegaUtil.isObject(b) ? equalObject(a, b)
: false;
}
function equalArray(a, b) {
for (let i=0, n=a.length; i<n; ++i) {
if (!equal(a[i], b[i])) return false;
}
return true;
}
function equalObject(a, b) {
for (let key in a) {
if (!equal(a[key], b[key])) return false;
}
return true;
}
function removePredicate(props) {
return _ => equalObject(props, _);
}
function modify(name, insert, remove, toggle, modify, values) {
let df = this.context.dataflow,
data = this.context.data[name],
input = data.input,
changes = data.changes,
stamp = df.stamp(),
predicate, key;
if (df._trigger === false || !(input.value.length || insert || toggle)) {
// nothing to do!
return 0;
}
if (!changes || changes.stamp < stamp) {
data.changes = (changes = df.changeset());
changes.stamp = stamp;
df.runAfter(function() {
data.modified = true;
df.pulse(input, changes).run();
}, true, 1);
}
if (remove) {
predicate = remove === true ? vegaUtil.truthy
: (vegaUtil.isArray(remove) || vegaDataflow.isTuple(remove)) ? remove
: removePredicate(remove);
changes.remove(predicate);
}
if (insert) {
changes.insert(insert);
}
if (toggle) {
predicate = removePredicate(toggle);
if (input.value.some(predicate)) {
changes.remove(predicate);
} else {
changes.insert(toggle);
}
}
if (modify) {
for (key in values) {
changes.modify(modify, key, values[key]);
}
}
return 1;
}
function pinchDistance(event) {
const t = event.touches,
dx = t[0].clientX - t[1].clientX,
dy = t[0].clientY - t[1].clientY;
return Math.sqrt(dx * dx + dy * dy);
}
function pinchAngle(event) {
const t = event.touches;
return Math.atan2(
t[0].clientY - t[1].clientY,
t[0].clientX - t[1].clientX
);
}
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 ? s(value) : undefined;
}
function scaleGradient(scale, p0, p1, count, group) {
scale = getScale(scale, (group || this).context);
const gradient = vegaScenegraph.Gradient(p0, p1);
let stops = scale.domain(),
min = stops[0],
max = vegaUtil.peek(stops),
fraction = vegaUtil.identity;
if (!(max - min)) {
// expand scale if domain has zero span, fix #1479
scale = (scale.interpolator
? vegaScale.scale('sequential')().interpolator(scale.interpolator())
: vegaScale.scale('linear')().interpolate(scale.interpolate()).range(scale.range())
).domain([min=0, max=1]);
} else {
fraction = vegaScale.scaleFraction(scale, min, max);
}
if (scale.ticks) {
stops = scale.ticks(+count || 15);
if (min !== stops[0]) stops.unshift(min);
if (max !== vegaUtil.peek(stops)) stops.push(max);
}
stops.forEach(_ => gradient.stop(fraction(_), scale(_)));
return gradient;
}
function geoShape(projection, geojson, group) {
const p = getScale(projection, (group || this).context);
return function(context) {
return p ? p.path.context(context)(geojson) : '';
};
}
function pathShape(path) {
let p = null;
return function(context) {
return context
? vegaScenegraph.pathRender(context, (p = p || vegaScenegraph.pathParse(path)))
: path;
};
}
const datum = d => d.data;
function treeNodes(name, context) {
const tree = data.call(context, name);
return tree.root && tree.root.lookup || {};
}
function treePath(name, source, target) {
const nodes = treeNodes(name, this),
s = nodes[source],
t = nodes[target];
return s && t ? s.path(t).map(datum) : undefined;
}
function treeAncestors(name, node) {
const n = treeNodes(name, this)[node];
return n ? n.ancestors().map(datum) : undefined;
}
const _window = () => (typeof window !== 'undefined' && window) || null;
function screen() {
const w = _window();
return w ? w.screen : {};
}
function windowSize() {
const w = _window();
return w
? [w.innerWidth, w.innerHeight]
: [undefined, undefined];
}
function containerSize() {
const view = this.context.dataflow,
el = view.container && view.container();
return el
? [el.clientWidth, el.clientHeight]
: [undefined, undefined];
}
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;
}
// Expression function context object
const functionContext = {
random: function() { return vegaStatistics.random(); }, // override default
cumulativeNormal: vegaStatistics.cumulativeNormal,
cumulativeLogNormal: vegaStatistics.cumulativeLogNormal,
cumulativeUniform: vegaStatistics.cumulativeUniform,
densityNormal: vegaStatistics.densityNormal,
densityLogNormal: vegaStatistics.densityLogNormal,
densityUniform: vegaStatistics.densityUniform,
quantileNormal: vegaStatistics.quantileNormal,
quantileLogNormal: vegaStatistics.quantileLogNormal,
quantileUniform: vegaStatistics.quantileUniform,
sampleNormal: vegaStatistics.sampleNormal,
sampleLogNormal: vegaStatistics.sampleLogNormal,
sampleUniform: vegaStatistics.sampleUniform,
isArray: vegaUtil.isArray,
isBoolean: vegaUtil.isBoolean,
isDate: vegaUtil.isDate,
isDefined: function(_) { return _ !== undefined; },
isNumber: vegaUtil.isNumber,
isObject: vegaUtil.isObject,
isRegExp: vegaUtil.isRegExp,
isString: vegaUtil.isString,
isTuple: vegaDataflow.isTuple,
isValid: function(_) { return _ != null && _ === _; },
toBoolean: vegaUtil.toBoolean,
toDate: vegaUtil.toDate,
toNumber: vegaUtil.toNumber,
toString: vegaUtil.toString,
flush: vegaUtil.flush,
lerp: vegaUtil.lerp,
merge,
pad: vegaUtil.pad,
peek: vegaUtil.peek,
span: vegaUtil.span,
inrange: vegaUtil.inrange,
truncate: vegaUtil.truncate,
rgb: d3Color.rgb,
lab: d3Color.lab,
hcl: d3Color.hcl,
hsl: d3Color.hsl,
luminance,
contrast,
sequence: d3Array.range,
format,
utcFormat,
utcParse,
utcOffset: vegaTime.utcOffset,
utcSequence: vegaTime.utcSequence,
timeFormat,
timeParse,
timeOffset: vegaTime.timeOffset,
timeSequence: vegaTime.timeSequence,
timeUnitSpecifier: vegaTime.timeUnitSpecifier,
monthFormat,
monthAbbrevFormat,
dayFormat,
dayAbbrevFormat,
quarter: vegaUtil.quarter,
utcquarter: vegaUtil.utcquarter,
week: vegaTime.week,
utcweek: vegaTime.utcweek,
dayofyear: vegaTime.dayofyear,
utcdayofyear: vegaTime.utcdayofyear,
warn,
info,
debug,
extent: vegaUtil.extent,
inScope,
intersect,
clampRange: vegaUtil.clampRange,
pinchDistance,
pinchAngle,
screen,
containerSize,
windowSize,
bandspace,
setdata,
pathShape,
panLinear: vegaUtil.panLinear,
panLog: vegaUtil.panLog,
panPow: vegaUtil.panPow,
panSymlog: vegaUtil.panSymlog,
zoomLinear: vegaUtil.zoomLinear,
zoomLog: vegaUtil.zoomLog,
zoomPow: vegaUtil.zoomPow,
zoomSymlog: vegaUtil.zoomSymlog,
encode,
modify
};
const eventFunctions = ['view', 'item', 'group', 'xy', 'x', 'y'], // event functions
eventPrefix = 'event.vega.', // event function prefix
thisPrefix = 'this.', // function context prefix
astVisitors = {}; // AST visitors for dependency analysis
// Build expression function registry
function buildFunctions(codegen) {
const fn = vegaExpression.functions(codegen);
eventFunctions.forEach(name => fn[name] = eventPrefix + name);
for (let name in functionContext) { fn[name] = thisPrefix + name; }
vegaUtil.extend(fn, internalScaleFunctions(codegen, functionContext, astVisitors));
return fn;
}
// Register an expression function
function expressionFunction(name, fn, visitor) {
if (arguments.length === 1) {
return functionContext[name];
}
// register with the functionContext
functionContext[name] = fn;
// if there is an astVisitor register that, too
if (visitor) astVisitors[name] = visitor;
// if the code generator has already been initialized,
// we need to also register the function with it
if (codeGenerator) codeGenerator.functions[name] = thisPrefix + name;
return this;
}
// register expression functions with ast visitors
expressionFunction('bandwidth', bandwidth, scaleVisitor);
expressionFunction('copy', copy, scaleVisitor);
expressionFunction('domain', domain, scaleVisitor);
expressionFunction('range', range, scaleVisitor);
expressionFunction('invert', invert, scaleVisitor);
expressionFunction('scale', scale, scaleVisitor);
expressionFunction('gradient', scaleGradient, scaleVisitor);
expressionFunction('geoArea', geoArea, scaleVisitor);
expressionFunction('geoBounds', geoBounds, scaleVisitor);
expressionFunction('geoCentroid', geoCentroid, scaleVisitor);
expressionFunction('geoShape', geoShape, scaleVisitor);
expressionFunction('indata', indata, indataVisitor);
expressionFunction('data', data, dataVisitor);
expressionFunction('treePath', treePath, dataVisitor);
expressionFunction('treeAncestors', treeAncestors, dataVisitor);
// register Vega-Lite selection functions
expressionFunction('vlSelectionTest', vegaSelections.selectionTest, vegaSelections.selectionVisitor);
expressionFunction('vlSelectionResolve', vegaSelections.selectionResolve, vegaSelections.selectionVisitor);
// Export code generator and parameters
const codegenParams = {
blacklist: ['_'],
whitelist: ['datum', 'event', 'item'],
fieldvar: 'datum',
globalvar: id => '_[' + vegaUtil.stringValue(SignalPrefix + id) + ']',
functions: buildFunctions,
constants: vegaExpression.constants,
visitors: astVisitors
};
var codeGenerator = vegaExpression.codegen(codegenParams);
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);
}
// 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;
exports.IndexPrefix = IndexPrefix;
exports.ScalePrefix = ScalePrefix;
exports.SignalPrefix = SignalPrefix;
exports.bandspace = bandspace;
exports.bandwidth = bandwidth;
exports.codeGenerator = codeGenerator;
exports.codegenParams = codegenParams;
exports.containerSize = containerSize;
exports.contrast = contrast;
exports.copy = copy;
exports.data = data;
exports.dataVisitor = dataVisitor;
exports.dayAbbrevFormat = dayAbbrevFormat;
exports.dayFormat = dayFormat;
exports.debug = debug;
exports.domain = domain;
exports.encode = encode;
exports.expressionFunction = expressionFunction;
exports.format = format;
exports.functionContext = functionContext;
exports.geoArea = geoArea;
exports.geoBounds = geoBounds;
exports.geoCentroid = geoCentroid;
exports.geoShape = geoShape;
exports.inScope = inScope;
exports.indata = indata;
exports.indataVisitor = indataVisitor;
exports.info = info;
exports.invert = invert;
exports.luminance = luminance;
exports.merge = merge;
exports.modify = modify;
exports.monthAbbrevFormat = monthAbbrevFormat;
exports.monthFormat = monthFormat;
exports.parseExpression = parser;
exports.pathShape = pathShape;
exports.pinchAngle = pinchAngle;
exports.pinchDistance = pinchDistance;
exports.range = range;
exports.scale = scale;
exports.scaleGradient = scaleGradient;
exports.scaleVisitor = scaleVisitor;
exports.screen = screen;
exports.setdata = setdata;
exports.timeFormat = timeFormat;
exports.timeParse = timeParse;
exports.treeAncestors = treeAncestors;
exports.treePath = treePath;
exports.utcFormat = utcFormat;
exports.utcParse = utcParse;
exports.warn = warn;
exports.windowSize = windowSize;
Object.defineProperty(exports, '__esModule', { value: true });
})));

File diff suppressed because one or more lines are too long

109
node_modules/vega-functions/index.js generated vendored Normal file
View File

@@ -0,0 +1,109 @@
export {
data,
indata,
setdata
} from './src/functions/data';
export {
default as encode
} from './src/functions/encode';
export {
format,
utcFormat,
timeFormat,
utcParse,
timeParse,
monthFormat,
monthAbbrevFormat,
dayFormat,
dayAbbrevFormat
} from './src/functions/format';
export {
geoArea,
geoBounds,
geoCentroid
} from './src/functions/geo';
export {
default as inScope
} from './src/functions/inscope';
export {
warn,
info,
debug
} from './src/functions/log';
export {
luminance,
contrast
} from './src/functions/luminance';
export {
default as merge
} from './src/functions/merge';
export {
default as modify
} from './src/functions/modify';
export {
pinchDistance,
pinchAngle
} from './src/functions/pinch';
export {
range,
domain,
bandwidth,
bandspace,
copy,
scale,
invert
} from './src/functions/scale';
export {
default as scaleGradient
} from './src/functions/scale-gradient';
export {
geoShape,
pathShape
} from './src/functions/shape';
export {
treePath,
treeAncestors
} from './src/functions/tree';
export {
containerSize,
screen,
windowSize
} 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,
indataVisitor,
scaleVisitor
} from './src/visitors';

79
node_modules/vega-functions/package.json generated vendored Normal file
View File

@@ -0,0 +1,79 @@
{
"_from": "vega-functions@~5.7.1",
"_id": "vega-functions@5.7.1",
"_inBundle": false,
"_integrity": "sha512-PQUcRkLAJwiRK+Y2o8MZdHJOHZwGcIYKvnYZnes2IY5433lhKYL7b1DmwQhUqyHyKCudqlz/pRnoLpmuL8sAgg==",
"_location": "/vega-functions",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "vega-functions@~5.7.1",
"name": "vega-functions",
"escapedName": "vega-functions",
"rawSpec": "~5.7.1",
"saveSpec": null,
"fetchSpec": "~5.7.1"
},
"_requiredBy": [
"/vega",
"/vega-parser",
"/vega-view"
],
"_resolved": "https://registry.npmjs.org/vega-functions/-/vega-functions-5.7.1.tgz",
"_shasum": "4231f013c7a8a6cdcefaa6ee08c96f361c0c9ef5",
"_spec": "vega-functions@~5.7.1",
"_where": "/home/prabhatdev/Documents/opensource/gitHubStats/waka-readme-stats/node_modules/vega",
"author": {
"name": "Jeffrey Heer",
"url": "http://idl.cs.washington.edu"
},
"bugs": {
"url": "https://github.com/vega/vega/issues"
},
"bundleDependencies": false,
"dependencies": {
"d3-array": "^2.4.0",
"d3-color": "^1.4.1",
"d3-geo": "^1.12.1",
"vega-dataflow": "^5.7.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.5",
"vega-time": "^2.0.1",
"vega-util": "^1.14.0"
},
"deprecated": false,
"description": "Custom functions for the Vega expression language.",
"devDependencies": {
"vega-format": "^1.0.0"
},
"gitHead": "62565bbe084a422c4a0cbc6e19c6f7c45a3e5137",
"homepage": "https://github.com/vega/vega#readme",
"keywords": [
"vega",
"expression",
"functions"
],
"license": "BSD-3-Clause",
"main": "build/vega-functions.js",
"module": "index.js",
"name": "vega-functions",
"repository": {
"type": "git",
"url": "git+https://github.com/vega/vega.git"
},
"scripts": {
"build": "yarn rollup",
"postbuild": "terser build/vega-functions.js -c -m -o build/vega-functions.min.js",
"postpublish": "git push && git push --tags",
"prebuild": "rimraf build && mkdir build",
"prepublishOnly": "yarn test && yarn build",
"pretest": "yarn prebuild && yarn rollup",
"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",
"test": "tape 'test/**/*-test.js'"
},
"version": "5.7.1"
}

338
node_modules/vega-functions/src/codegen.js generated vendored Normal file
View File

@@ -0,0 +1,338 @@
import {
codegen,
constants,
functions
} from 'vega-expression';
import {
isTuple
} from 'vega-dataflow';
import {
selectionResolve,
selectionTest,
selectionVisitor
} from 'vega-selections';
import {
cumulativeLogNormal,
cumulativeNormal,
cumulativeUniform,
densityLogNormal,
densityNormal,
densityUniform,
quantileLogNormal,
quantileNormal,
quantileUniform,
random,
sampleLogNormal,
sampleNormal,
sampleUniform
} from 'vega-statistics';
import {
dayofyear,
timeOffset,
timeSequence,
timeUnitSpecifier,
utcOffset,
utcSequence,
utcdayofyear,
utcweek,
week
} from 'vega-time';
import {
clampRange,
extend,
extent,
flush,
inrange,
isArray,
isBoolean,
isDate,
isNumber,
isObject,
isRegExp,
isString,
lerp,
pad,
panLinear,
panLog,
panPow,
panSymlog,
peek,
quarter,
span,
stringValue,
toBoolean,
toDate,
toNumber,
toString,
truncate,
utcquarter,
zoomLinear,
zoomLog,
zoomPow,
zoomSymlog
} from 'vega-util';
import {
range as sequence
} from 'd3-array';
import {
hcl,
hsl,
lab,
rgb
} from 'd3-color';
import {
contrast,
luminance
} from './functions/luminance';
import {
data,
indata,
setdata
} from './functions/data';
import encode from './functions/encode';
import {
dayAbbrevFormat,
dayFormat,
format,
monthAbbrevFormat,
monthFormat,
timeFormat,
timeParse,
utcFormat,
utcParse
} from './functions/format';
import {
geoArea,
geoBounds,
geoCentroid
} from './functions/geo';
import inScope from './functions/inscope';
import intersect from './functions/intersect';
import {
debug,
info,
warn
} from './functions/log';
import merge from './functions/merge';
import modify from './functions/modify';
import {
pinchAngle,
pinchDistance
} from './functions/pinch';
import {
bandspace,
bandwidth,
copy,
domain,
invert,
range,
scale
} from './functions/scale';
import scaleGradient from './functions/scale-gradient';
import {
geoShape,
pathShape
} from './functions/shape';
import {
treeAncestors,
treePath
} from './functions/tree';
import {
containerSize,
screen,
windowSize
} from './functions/window';
import {
SignalPrefix
} from './constants';
import {
internalScaleFunctions
} from './scales';
import {
dataVisitor,
indataVisitor,
scaleVisitor
} from './visitors';
// Expression function context object
export const functionContext = {
random: function() { return random(); }, // override default
cumulativeNormal,
cumulativeLogNormal,
cumulativeUniform,
densityNormal,
densityLogNormal,
densityUniform,
quantileNormal,
quantileLogNormal,
quantileUniform,
sampleNormal,
sampleLogNormal,
sampleUniform,
isArray,
isBoolean,
isDate,
isDefined: function(_) { return _ !== undefined; },
isNumber,
isObject,
isRegExp,
isString,
isTuple,
isValid: function(_) { return _ != null && _ === _; },
toBoolean,
toDate,
toNumber,
toString,
flush,
lerp,
merge,
pad,
peek,
span,
inrange,
truncate,
rgb,
lab,
hcl,
hsl,
luminance,
contrast,
sequence,
format,
utcFormat,
utcParse,
utcOffset,
utcSequence,
timeFormat,
timeParse,
timeOffset,
timeSequence,
timeUnitSpecifier,
monthFormat,
monthAbbrevFormat,
dayFormat,
dayAbbrevFormat,
quarter,
utcquarter,
week,
utcweek,
dayofyear,
utcdayofyear,
warn,
info,
debug,
extent,
inScope,
intersect,
clampRange,
pinchDistance,
pinchAngle,
screen,
containerSize,
windowSize,
bandspace,
setdata,
pathShape,
panLinear,
panLog,
panPow,
panSymlog,
zoomLinear,
zoomLog,
zoomPow,
zoomSymlog,
encode,
modify
};
const eventFunctions = ['view', 'item', 'group', 'xy', 'x', 'y'], // event functions
eventPrefix = 'event.vega.', // event function prefix
thisPrefix = 'this.', // function context prefix
astVisitors = {}; // AST visitors for dependency analysis
// Build expression function registry
function buildFunctions(codegen) {
const fn = functions(codegen);
eventFunctions.forEach(name => fn[name] = eventPrefix + name);
for (let name in functionContext) { fn[name] = thisPrefix + name; }
extend(fn, internalScaleFunctions(codegen, functionContext, astVisitors));
return fn;
}
// Register an expression function
export function expressionFunction(name, fn, visitor) {
if (arguments.length === 1) {
return functionContext[name];
}
// register with the functionContext
functionContext[name] = fn;
// if there is an astVisitor register that, too
if (visitor) astVisitors[name] = visitor;
// if the code generator has already been initialized,
// we need to also register the function with it
if (codeGenerator) codeGenerator.functions[name] = thisPrefix + name;
return this;
}
// register expression functions with ast visitors
expressionFunction('bandwidth', bandwidth, scaleVisitor);
expressionFunction('copy', copy, scaleVisitor);
expressionFunction('domain', domain, scaleVisitor);
expressionFunction('range', range, scaleVisitor);
expressionFunction('invert', invert, scaleVisitor);
expressionFunction('scale', scale, scaleVisitor);
expressionFunction('gradient', scaleGradient, scaleVisitor);
expressionFunction('geoArea', geoArea, scaleVisitor);
expressionFunction('geoBounds', geoBounds, scaleVisitor);
expressionFunction('geoCentroid', geoCentroid, scaleVisitor);
expressionFunction('geoShape', geoShape, scaleVisitor);
expressionFunction('indata', indata, indataVisitor);
expressionFunction('data', data, dataVisitor);
expressionFunction('treePath', treePath, dataVisitor);
expressionFunction('treeAncestors', treeAncestors, dataVisitor);
// register Vega-Lite selection functions
expressionFunction('vlSelectionTest', selectionTest, selectionVisitor);
expressionFunction('vlSelectionResolve', selectionResolve, selectionVisitor);
// Export code generator and parameters
export const codegenParams = {
blacklist: ['_'],
whitelist: ['datum', 'event', 'item'],
fieldvar: 'datum',
globalvar: id => '_[' + stringValue(SignalPrefix + id) + ']',
functions: buildFunctions,
constants: constants,
visitors: astVisitors
};
export var codeGenerator = codegen(codegenParams);

4
node_modules/vega-functions/src/constants.js generated vendored Normal file
View File

@@ -0,0 +1,4 @@
export const DataPrefix = ':';
export const IndexPrefix = '@';
export const ScalePrefix = '%';
export const SignalPrefix = '$';

21
node_modules/vega-functions/src/functions/data.js generated vendored Normal file
View File

@@ -0,0 +1,21 @@
import {truthy} from 'vega-util';
export function data(name) {
const data = this.context.data[name];
return data ? data.values.value : [];
}
export function indata(name, field, value) {
const index = this.context.data[name]['index:' + field],
entry = index ? index.value.get(value) : undefined;
return entry ? entry.count : entry;
}
export function setdata(name, tuples) {
const df = this.context.dataflow,
data = this.context.data[name],
input = data.input;
df.pulse(input, df.changeset().remove(truthy).insert(tuples));
return 1;
}

8
node_modules/vega-functions/src/functions/encode.js generated vendored Normal file
View File

@@ -0,0 +1,8 @@
export default function(item, name, retval) {
if (item) {
const df = this.context.dataflow,
target = item.mark.source;
df.pulse(target, df.changeset().encode(item, name));
}
return retval !== undefined ? retval : item;
}

36
node_modules/vega-functions/src/functions/format.js generated vendored Normal file
View File

@@ -0,0 +1,36 @@
const wrap = method => function(value, spec) {
const locale = this.context.dataflow.locale();
return locale[method](spec)(value);
};
export const format = wrap('format');
export const timeFormat = wrap('timeFormat');
export const utcFormat = wrap('utcFormat');
export const timeParse = wrap('timeParse');
export const utcParse = wrap('utcParse');
var dateObj = new Date(2000, 0, 1);
function time(month, day, specifier) {
if (!Number.isInteger(month) || !Number.isInteger(day)) return '';
dateObj.setYear(2000);
dateObj.setMonth(month);
dateObj.setDate(day);
return timeFormat.call(this, dateObj, specifier);
}
export function monthFormat(month) {
return time.call(this, month, 1, '%B');
}
export function monthAbbrevFormat(month) {
return time.call(this, month, 1, '%b');
}
export function dayFormat(day) {
return time.call(this, 0, 2 + day, '%A');
}
export function dayAbbrevFormat(day) {
return time.call(this, 0, 2 + day, '%a');
}

23
node_modules/vega-functions/src/functions/geo.js generated vendored Normal file
View File

@@ -0,0 +1,23 @@
import {getScale} from '../scales';
import {
geoArea as area,
geoBounds as bounds,
geoCentroid as centroid
} from 'd3-geo';
function geoMethod(methodName, globalMethod) {
return function(projection, geojson, group) {
if (projection) {
// projection defined, use it
const p = getScale(projection, (group || this).context);
return p && p.path[methodName](geojson);
} else {
// projection undefined, use global method
return globalMethod(geojson);
}
};
}
export const geoArea = geoMethod('area', area);
export const geoBounds = geoMethod('bounds', bounds);
export const geoCentroid = geoMethod('centroid', centroid);

10
node_modules/vega-functions/src/functions/inscope.js generated vendored Normal file
View File

@@ -0,0 +1,10 @@
export default function(item) {
let group = this.context.group,
value = false;
if (group) while (item) {
if (item === group) { value = true; break; }
item = item.mark.group;
}
return value;
}

25
node_modules/vega-functions/src/functions/intersect.js generated vendored Normal file
View File

@@ -0,0 +1,25 @@
import {Bounds, intersect} from 'vega-scenegraph';
import {array} from 'vega-util';
export default function(b, opt, group) {
if (!b) return [];
const [u, v] = b,
box = new Bounds().set(u[0], u[1], v[0], v[1]),
scene = group || this.context.dataflow.scenegraph().root;
return intersect(scene, box, filter(opt));
}
function filter(opt) {
let p = null;
if (opt) {
const types = array(opt.marktype),
names = array(opt.markname);
p = _ => (!types.length || types.some(t => _.marktype === t))
&& (!names.length || names.some(s => _.name === s));
}
return p;
}

20
node_modules/vega-functions/src/functions/log.js generated vendored Normal file
View File

@@ -0,0 +1,20 @@
function log(df, method, args) {
try {
df[method].apply(df, ['EXPRESSION'].concat([].slice.call(args)));
} catch (err) {
df.warn(err);
}
return args[args.length-1];
}
export function warn() {
return log(this.context.dataflow, 'warn', arguments);
}
export function info() {
return log(this.context.dataflow, 'info', arguments);
}
export function debug() {
return log(this.context.dataflow, 'debug', arguments);
}

27
node_modules/vega-functions/src/functions/luminance.js generated vendored Normal file
View File

@@ -0,0 +1,27 @@
import {rgb} from 'd3-color';
// 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);
}
export function luminance(color) {
const c = 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
export 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);
}

7
node_modules/vega-functions/src/functions/merge.js generated vendored Normal file
View File

@@ -0,0 +1,7 @@
import {extend} from 'vega-util';
export default function() {
var args = [].slice.call(arguments);
args.unshift({});
return extend.apply(null, args);
}

80
node_modules/vega-functions/src/functions/modify.js generated vendored Normal file
View File

@@ -0,0 +1,80 @@
import {isTuple} from 'vega-dataflow';
import {isArray, isObject, truthy} from 'vega-util';
function equal(a, b) {
return a === b || a !== a && b !== b ? true
: isArray(a) ? (
isArray(b) && a.length === b.length ? equalArray(a, b) : false
)
: isObject(a) && isObject(b) ? equalObject(a, b)
: false;
}
function equalArray(a, b) {
for (let i=0, n=a.length; i<n; ++i) {
if (!equal(a[i], b[i])) return false;
}
return true;
}
function equalObject(a, b) {
for (let key in a) {
if (!equal(a[key], b[key])) return false;
}
return true;
}
function removePredicate(props) {
return _ => equalObject(props, _);
}
export default function(name, insert, remove, toggle, modify, values) {
let df = this.context.dataflow,
data = this.context.data[name],
input = data.input,
changes = data.changes,
stamp = df.stamp(),
predicate, key;
if (df._trigger === false || !(input.value.length || insert || toggle)) {
// nothing to do!
return 0;
}
if (!changes || changes.stamp < stamp) {
data.changes = (changes = df.changeset());
changes.stamp = stamp;
df.runAfter(function() {
data.modified = true;
df.pulse(input, changes).run();
}, true, 1);
}
if (remove) {
predicate = remove === true ? truthy
: (isArray(remove) || isTuple(remove)) ? remove
: removePredicate(remove);
changes.remove(predicate);
}
if (insert) {
changes.insert(insert);
}
if (toggle) {
predicate = removePredicate(toggle);
if (input.value.some(predicate)) {
changes.remove(predicate);
} else {
changes.insert(toggle);
}
}
if (modify) {
for (key in values) {
changes.modify(modify, key, values[key]);
}
}
return 1;
}

14
node_modules/vega-functions/src/functions/pinch.js generated vendored Normal file
View File

@@ -0,0 +1,14 @@
export function pinchDistance(event) {
const t = event.touches,
dx = t[0].clientX - t[1].clientX,
dy = t[0].clientY - t[1].clientY;
return Math.sqrt(dx * dx + dy * dy);
}
export function pinchAngle(event) {
const t = event.touches;
return Math.atan2(
t[0].clientY - t[1].clientY,
t[0].clientX - t[1].clientX
);
}

View File

@@ -0,0 +1,35 @@
import {getScale} from '../scales';
import {scale as get, scaleFraction} from 'vega-scale';
import {Gradient} from 'vega-scenegraph';
import {identity, peek} from 'vega-util';
export default function(scale, p0, p1, count, group) {
scale = getScale(scale, (group || this).context);
const gradient = Gradient(p0, p1);
let stops = scale.domain(),
min = stops[0],
max = peek(stops),
fraction = identity;
if (!(max - min)) {
// expand scale if domain has zero span, fix #1479
scale = (scale.interpolator
? get('sequential')().interpolator(scale.interpolator())
: get('linear')().interpolate(scale.interpolate()).range(scale.range())
).domain([min=0, max=1]);
} else {
fraction = scaleFraction(scale, min, max);
}
if (scale.ticks) {
stops = scale.ticks(+count || 15);
if (min !== stops[0]) stops.unshift(min);
if (max !== peek(stops)) stops.push(max);
}
stops.forEach(_ => gradient.stop(fraction(_), scale(_)));
return gradient;
}

39
node_modules/vega-functions/src/functions/scale.js generated vendored Normal file
View File

@@ -0,0 +1,39 @@
import {getScale} from '../scales';
import {bandSpace} from 'vega-scale';
import {isArray} from 'vega-util';
export function bandspace(count, paddingInner, paddingOuter) {
return bandSpace(count || 0, paddingInner || 0, paddingOuter || 0);
}
export function bandwidth(name, group) {
const s = getScale(name, (group || this).context);
return s && s.bandwidth ? s.bandwidth() : 0;
}
export function copy(name, group) {
const s = getScale(name, (group || this).context);
return s ? s.copy() : undefined;
}
export function domain(name, group) {
const s = getScale(name, (group || this).context);
return s ? s.domain() : [];
}
export function invert(name, range, group) {
const s = getScale(name, (group || this).context);
return !s ? undefined
: isArray(range) ? (s.invertRange || s.invert)(range)
: (s.invert || s.invertExtent)(range);
}
export function range(name, group) {
const s = getScale(name, (group || this).context);
return s && s.range ? s.range() : [];
}
export function scale(name, value, group) {
const s = getScale(name, (group || this).context);
return s ? s(value) : undefined;
}

18
node_modules/vega-functions/src/functions/shape.js generated vendored Normal file
View File

@@ -0,0 +1,18 @@
import {getScale} from '../scales';
import {pathParse, pathRender} from 'vega-scenegraph';
export function geoShape(projection, geojson, group) {
const p = getScale(projection, (group || this).context);
return function(context) {
return p ? p.path.context(context)(geojson) : '';
};
}
export function pathShape(path) {
let p = null;
return function(context) {
return context
? pathRender(context, (p = p || pathParse(path)))
: path;
};
}

20
node_modules/vega-functions/src/functions/tree.js generated vendored Normal file
View File

@@ -0,0 +1,20 @@
import {data} from './data';
const datum = d => d.data;
function treeNodes(name, context) {
const tree = data.call(context, name);
return tree.root && tree.root.lookup || {};
}
export function treePath(name, source, target) {
const nodes = treeNodes(name, this),
s = nodes[source],
t = nodes[target];
return s && t ? s.path(t).map(datum) : undefined;
}
export function treeAncestors(name, node) {
const n = treeNodes(name, this)[node];
return n ? n.ancestors().map(datum) : undefined;
}

21
node_modules/vega-functions/src/functions/window.js generated vendored Normal file
View File

@@ -0,0 +1,21 @@
const _window = () => (typeof window !== 'undefined' && window) || null;
export function screen() {
const w = _window();
return w ? w.screen : {};
}
export function windowSize() {
const w = _window();
return w
? [w.innerWidth, w.innerHeight]
: [undefined, undefined];
}
export function containerSize() {
const view = this.context.dataflow,
el = view.container && view.container();
return el
? [el.clientWidth, el.clientHeight]
: [undefined, undefined];
}

42
node_modules/vega-functions/src/parser.js generated vendored Normal file
View File

@@ -0,0 +1,42 @@
import {codeGenerator, codegenParams} from './codegen';
import {SignalPrefix} from './constants';
import {CallExpression, parse} from 'vega-expression';
import {error, extend, hasOwnProperty, isString, stringValue} from 'vega-util';
export default function(expr, scope) {
var params = {}, ast, gen;
// parse the expression to an abstract syntax tree (ast)
try {
expr = isString(expr) ? expr : (stringValue(expr) + '');
ast = parse(expr);
} catch (err) {
error('Expression parse error: ' + expr);
}
// analyze ast function calls for dependencies
ast.visit(node => {
if (node.type !== 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 (!hasOwnProperty(params, signalName) && scope.getSignal(name)) {
params[signalName] = scope.signalRef(name);
}
});
// return generated expression code and dependencies
return {
$expr: extend({code: gen.code}, scope.options.ast ? {ast} : null),
$fields: gen.fields,
$params: params
};
}

36
node_modules/vega-functions/src/scales.js generated vendored Normal file
View File

@@ -0,0 +1,36 @@
import {ScalePrefix} from './constants';
import {scaleVisitor} from './visitors';
import {Literal} from 'vega-expression';
import {isFunction, isString, stringValue} from 'vega-util';
export function getScale(name, ctx) {
let s;
return isFunction(name) ? name
: isString(name) ? (s = ctx.scales[name]) && s.value
: undefined;
}
export 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 === Literal
? stringValue(ScalePrefix + arg.value)
: 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])})`
};
}

56
node_modules/vega-functions/src/visitors.js generated vendored Normal file
View File

@@ -0,0 +1,56 @@
import {DataPrefix, IndexPrefix, ScalePrefix} from './constants';
import {Literal} from 'vega-expression';
import {error, hasOwnProperty} from 'vega-util';
export function dataVisitor(name, args, scope, params) {
if (args[0].type !== Literal) {
error('First argument to data functions must be a string literal.');
}
const data = args[0].value,
dataName = DataPrefix + data;
if (!hasOwnProperty(dataName, params)) {
try {
params[dataName] = scope.getData(data).tuplesRef();
} catch (err) {
// if data set does not exist, there's nothing to track
}
}
}
export function indataVisitor(name, args, scope, params) {
if (args[0].type !== Literal) error('First argument to indata must be a string literal.');
if (args[1].type !== Literal) error('Second argument to indata must be a string literal.');
const data = args[0].value,
field = args[1].value,
indexName = IndexPrefix + field;
if (!hasOwnProperty(indexName, params)) {
params[indexName] = scope.getData(data).indataRef(scope, field);
}
}
export function scaleVisitor(name, args, scope, params) {
if (args[0].type === 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 addScaleDependency(scope, params, name) {
const scaleName = ScalePrefix + name;
if (!hasOwnProperty(params, scaleName)) {
try {
params[scaleName] = scope.scaleRef(name);
} catch (err) {
// TODO: error handling? warning?
}
}
}