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-hierarchy/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.

13
node_modules/vega-hierarchy/README.md generated vendored Normal file
View File

@@ -0,0 +1,13 @@
# vega-hierarchy
Hierarchical layout transforms for Vega dataflows.
This pacakge provides the following Vega data transforms:
- [**Nest**](https://vega.github.io/vega/docs/transforms/nest/) [<>](https://github.com/vega/vega/blob/master/packages/vega-hierarchy/src/Nest.js "Source")
- [**Pack**](https://vega.github.io/vega/docs/transforms/pack/) [<>](https://github.com/vega/vega/blob/master/packages/vega-hierarchy/src/Pack.js "Source")
- [**Partition**](https://vega.github.io/vega/docs/transforms/partition/) [<>](https://github.com/vega/vega/blob/master/packages/vega-hierarchy/src/Partition.js "Source")
- [**Stratify**](https://vega.github.io/vega/docs/transforms/stratify/) [<>](https://github.com/vega/vega/blob/master/packages/vega-hierarchy/src/Stratify.js "Source")
- [**Tree**](https://vega.github.io/vega/docs/transforms/tree/) [<>](https://github.com/vega/vega/blob/master/packages/vega-hierarchy/src/Tree.js "Source")
- [**Treemap**](https://vega.github.io/vega/docs/transforms/treemap/) [<>](https://github.com/vega/vega/blob/master/packages/vega-hierarchy/src/Treemap.js "Source")
- [**TreeLinks**](https://vega.github.io/vega/docs/transforms/treelinks/) [<>](https://github.com/vega/vega/blob/master/packages/vega-hierarchy/src/TreeLinks.js "Source")

507
node_modules/vega-hierarchy/build/vega-hierarchy.js generated vendored Normal file
View File

@@ -0,0 +1,507 @@
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('vega-dataflow'), require('vega-util'), require('d3-hierarchy')) :
typeof define === 'function' && define.amd ? define(['exports', 'vega-dataflow', 'vega-util', 'd3-hierarchy'], factory) :
(global = global || self, factory((global.vega = global.vega || {}, global.vega.transforms = {}), global.vega, global.vega, global.d3));
}(this, (function (exports, vegaDataflow, vegaUtil, d3Hierarchy) { 'use strict';
// Build lookup table mapping tuple keys to tree node instances
function lookup(tree, key, filter) {
var map = {};
tree.each(function(node) {
var t = node.data;
if (filter(t)) map[key(t)] = node;
});
tree.lookup = map;
return tree;
}
/**
* Nest tuples into a tree structure, grouped by key values.
* @constructor
* @param {object} params - The parameters for this operator.
* @param {Array<function(object): *>} params.keys - The key fields to nest by, in order.
* @param {boolean} [params.generate=false] - A boolean flag indicating if
* non-leaf nodes generated by this transform should be included in the
* output. The default (false) includes only the input data (leaf nodes)
* in the data stream.
*/
function Nest(params) {
vegaDataflow.Transform.call(this, null, params);
}
Nest.Definition = {
'type': 'Nest',
'metadata': {'treesource': true, 'changes': true},
'params': [
{ 'name': 'keys', 'type': 'field', 'array': true },
{ 'name': 'generate', 'type': 'boolean' }
]
};
var prototype = vegaUtil.inherits(Nest, vegaDataflow.Transform);
function children(n) {
return n.values;
}
prototype.transform = function(_, pulse) {
if (!pulse.source) {
vegaUtil.error('Nest transform requires an upstream data source.');
}
var gen = _.generate,
mod = _.modified(),
out = pulse.clone(),
tree = this.value;
if (!tree || mod || pulse.changed()) {
// collect nodes to remove
if (tree) {
tree.each(node => {
if (node.children && vegaDataflow.isTuple(node.data)) {
out.rem.push(node.data);
}
});
}
// generate new tree structure
this.value = tree = d3Hierarchy.hierarchy({
values: vegaUtil.array(_.keys)
.reduce((n, k) => { n.key(k); return n; }, nest())
.entries(out.source)
}, children);
// collect nodes to add
if (gen) {
tree.each(node => {
if (node.children) {
node = vegaDataflow.ingest(node.data);
out.add.push(node);
out.source.push(node);
}
});
}
// build lookup table
lookup(tree, vegaDataflow.tupleid, vegaDataflow.tupleid);
}
out.source.root = tree;
return out;
};
function nest() {
var keys = [],
nest;
function apply(array, depth) {
if (depth >= keys.length) {
return array;
}
var i = -1,
n = array.length,
key = keys[depth++],
keyValue,
value,
valuesByKey = {},
values,
result = {};
while (++i < n) {
keyValue = key(value = array[i]) + '';
if (values = valuesByKey[keyValue]) {
values.push(value);
} else {
valuesByKey[keyValue] = [value];
}
}
for (keyValue in valuesByKey) {
result[keyValue] = apply(valuesByKey[keyValue], depth);
}
return result;
}
function entries(map, depth) {
if (++depth > keys.length) return map;
var array = [], k;
for (k in map) {
array.push({key: k, values: entries(map[k], depth)});
}
return array;
}
return nest = {
entries: array => entries(apply(array, 0), 0),
key: d => { keys.push(d); return nest; }
};
}
/**
* Abstract class for tree layout.
* @constructor
* @param {object} params - The parameters for this operator.
*/
function HierarchyLayout(params) {
vegaDataflow.Transform.call(this, null, params);
}
var prototype$1 = vegaUtil.inherits(HierarchyLayout, vegaDataflow.Transform);
prototype$1.transform = function(_, pulse) {
if (!pulse.source || !pulse.source.root) {
vegaUtil.error(this.constructor.name
+ ' transform requires a backing tree data source.');
}
var layout = this.layout(_.method),
fields = this.fields,
root = pulse.source.root,
as = _.as || fields;
if (_.field) root.sum(_.field); else root.count();
if (_.sort) root.sort(vegaDataflow.stableCompare(_.sort, d => d.data));
setParams(layout, this.params, _);
if (layout.separation) {
layout.separation(_.separation !== false ? defaultSeparation : vegaUtil.one);
}
try {
this.value = layout(root);
} catch (err) {
vegaUtil.error(err);
}
root.each(function(node) { setFields(node, fields, as); });
return pulse.reflow(_.modified()).modifies(as).modifies('leaf');
};
function setParams(layout, params, _) {
for (var p, i=0, n=params.length; i<n; ++i) {
p = params[i];
if (p in _) layout[p](_[p]);
}
}
function setFields(node, fields, as) {
var t = node.data;
for (var i=0, n=fields.length-1; i<n; ++i) {
t[as[i]] = node[fields[i]];
}
t[as[n]] = node.children ? node.children.length : 0;
}
function defaultSeparation(a, b) {
return a.parent === b.parent ? 1 : 2;
}
var Output = ['x', 'y', 'r', 'depth', 'children'];
/**
* Packed circle tree layout.
* @constructor
* @param {object} params - The parameters for this operator.
* @param {function(object): *} params.field - The value field to size nodes.
*/
function Pack(params) {
HierarchyLayout.call(this, params);
}
Pack.Definition = {
'type': 'Pack',
'metadata': {'tree': true, 'modifies': true},
'params': [
{ 'name': 'field', 'type': 'field' },
{ 'name': 'sort', 'type': 'compare' },
{ 'name': 'padding', 'type': 'number', 'default': 0 },
{ 'name': 'radius', 'type': 'field', 'default': null },
{ 'name': 'size', 'type': 'number', 'array': true, 'length': 2 },
{ 'name': 'as', 'type': 'string', 'array': true, 'length': Output.length, 'default': Output }
]
};
var prototype$2 = vegaUtil.inherits(Pack, HierarchyLayout);
prototype$2.layout = d3Hierarchy.pack;
prototype$2.params = ['radius', 'size', 'padding'];
prototype$2.fields = Output;
var Output$1 = ['x0', 'y0', 'x1', 'y1', 'depth', 'children'];
/**
* Partition tree layout.
* @constructor
* @param {object} params - The parameters for this operator.
* @param {function(object): *} params.field - The value field to size nodes.
*/
function Partition(params) {
HierarchyLayout.call(this, params);
}
Partition.Definition = {
'type': 'Partition',
'metadata': {'tree': true, 'modifies': true},
'params': [
{ 'name': 'field', 'type': 'field' },
{ 'name': 'sort', 'type': 'compare' },
{ 'name': 'padding', 'type': 'number', 'default': 0 },
{ 'name': 'round', 'type': 'boolean', 'default': false },
{ 'name': 'size', 'type': 'number', 'array': true, 'length': 2 },
{ 'name': 'as', 'type': 'string', 'array': true, 'length': Output$1.length, 'default': Output$1 }
]
};
var prototype$3 = vegaUtil.inherits(Partition, HierarchyLayout);
prototype$3.layout = d3Hierarchy.partition;
prototype$3.params = ['size', 'round', 'padding'];
prototype$3.fields = Output$1;
/**
* Stratify a collection of tuples into a tree structure based on
* id and parent id fields.
* @constructor
* @param {object} params - The parameters for this operator.
* @param {function(object): *} params.key - Unique key field for each tuple.
* @param {function(object): *} params.parentKey - Field with key for parent tuple.
*/
function Stratify(params) {
vegaDataflow.Transform.call(this, null, params);
}
Stratify.Definition = {
'type': 'Stratify',
'metadata': {'treesource': true},
'params': [
{ 'name': 'key', 'type': 'field', 'required': true },
{ 'name': 'parentKey', 'type': 'field', 'required': true }
]
};
var prototype$4 = vegaUtil.inherits(Stratify, vegaDataflow.Transform);
prototype$4.transform = function(_, pulse) {
if (!pulse.source) {
vegaUtil.error('Stratify transform requires an upstream data source.');
}
var tree = this.value,
mod = _.modified(),
out = pulse.fork(pulse.ALL).materialize(pulse.SOURCE),
run = !this.value
|| mod
|| pulse.changed(pulse.ADD_REM)
|| pulse.modified(_.key.fields)
|| pulse.modified(_.parentKey.fields);
// prevent upstream source pollution
out.source = out.source.slice();
if (run) {
if (out.source.length) {
tree = lookup(
d3Hierarchy.stratify().id(_.key).parentId(_.parentKey)(out.source)
, _.key, vegaUtil.truthy);
} else {
tree = lookup(d3Hierarchy.stratify()([{}]), _.key, _.key);
}
}
out.source.root = this.value = tree;
return out;
};
var Layouts = {
tidy: d3Hierarchy.tree,
cluster: d3Hierarchy.cluster
};
var Output$2 = ['x', 'y', 'depth', 'children'];
/**
* Tree layout. Depending on the method parameter, performs either
* Reingold-Tilford 'tidy' layout or dendrogram 'cluster' layout.
* @constructor
* @param {object} params - The parameters for this operator.
*/
function Tree(params) {
HierarchyLayout.call(this, params);
}
Tree.Definition = {
'type': 'Tree',
'metadata': {'tree': true, 'modifies': true},
'params': [
{ 'name': 'field', 'type': 'field' },
{ 'name': 'sort', 'type': 'compare' },
{ 'name': 'method', 'type': 'enum', 'default': 'tidy', 'values': ['tidy', 'cluster'] },
{ 'name': 'size', 'type': 'number', 'array': true, 'length': 2 },
{ 'name': 'nodeSize', 'type': 'number', 'array': true, 'length': 2 },
{ 'name': 'separation', 'type': 'boolean', 'default': true },
{ 'name': 'as', 'type': 'string', 'array': true, 'length': Output$2.length, 'default': Output$2 }
]
};
var prototype$5 = vegaUtil.inherits(Tree, HierarchyLayout);
/**
* Tree layout generator. Supports both 'tidy' and 'cluster' layouts.
*/
prototype$5.layout = function(method) {
var m = method || 'tidy';
if (vegaUtil.hasOwnProperty(Layouts, m)) return Layouts[m]();
else vegaUtil.error('Unrecognized Tree layout method: ' + m);
};
prototype$5.params = ['size', 'nodeSize'];
prototype$5.fields = Output$2;
/**
* Generate tuples representing links between tree nodes.
* The resulting tuples will contain 'source' and 'target' fields,
* which point to parent and child node tuples, respectively.
* @constructor
* @param {object} params - The parameters for this operator.
*/
function TreeLinks(params) {
vegaDataflow.Transform.call(this, [], params);
}
TreeLinks.Definition = {
'type': 'TreeLinks',
'metadata': {'tree': true, 'generates': true, 'changes': true},
'params': []
};
var prototype$6 = vegaUtil.inherits(TreeLinks, vegaDataflow.Transform);
prototype$6.transform = function(_, pulse) {
var links = this.value,
tree = pulse.source && pulse.source.root,
out = pulse.fork(pulse.NO_SOURCE),
lut = {};
if (!tree) vegaUtil.error('TreeLinks transform requires a tree data source.');
if (pulse.changed(pulse.ADD_REM)) {
// remove previous links
out.rem = links;
// build lookup table of valid tuples
pulse.visit(pulse.SOURCE, function(t) { lut[vegaDataflow.tupleid(t)] = 1; });
// generate links for all edges incident on valid tuples
tree.each(function(node) {
var t = node.data,
p = node.parent && node.parent.data;
if (p && lut[vegaDataflow.tupleid(t)] && lut[vegaDataflow.tupleid(p)]) {
out.add.push(vegaDataflow.ingest({source: p, target: t}));
}
});
this.value = out.add;
}
else if (pulse.changed(pulse.MOD)) {
// build lookup table of modified tuples
pulse.visit(pulse.MOD, function(t) { lut[vegaDataflow.tupleid(t)] = 1; });
// gather links incident on modified tuples
links.forEach(function(link) {
if (lut[vegaDataflow.tupleid(link.source)] || lut[vegaDataflow.tupleid(link.target)]) {
out.mod.push(link);
}
});
}
return out;
};
var Tiles = {
binary: d3Hierarchy.treemapBinary,
dice: d3Hierarchy.treemapDice,
slice: d3Hierarchy.treemapSlice,
slicedice: d3Hierarchy.treemapSliceDice,
squarify: d3Hierarchy.treemapSquarify,
resquarify: d3Hierarchy.treemapResquarify
};
var Output$3 = ['x0', 'y0', 'x1', 'y1', 'depth', 'children'];
/**
* Treemap layout.
* @constructor
* @param {object} params - The parameters for this operator.
* @param {function(object): *} params.field - The value field to size nodes.
*/
function Treemap(params) {
HierarchyLayout.call(this, params);
}
Treemap.Definition = {
'type': 'Treemap',
'metadata': {'tree': true, 'modifies': true},
'params': [
{ 'name': 'field', 'type': 'field' },
{ 'name': 'sort', 'type': 'compare' },
{ 'name': 'method', 'type': 'enum', 'default': 'squarify',
'values': ['squarify', 'resquarify', 'binary', 'dice', 'slice', 'slicedice'] },
{ 'name': 'padding', 'type': 'number', 'default': 0 },
{ 'name': 'paddingInner', 'type': 'number', 'default': 0 },
{ 'name': 'paddingOuter', 'type': 'number', 'default': 0 },
{ 'name': 'paddingTop', 'type': 'number', 'default': 0 },
{ 'name': 'paddingRight', 'type': 'number', 'default': 0 },
{ 'name': 'paddingBottom', 'type': 'number', 'default': 0 },
{ 'name': 'paddingLeft', 'type': 'number', 'default': 0 },
{ 'name': 'ratio', 'type': 'number', 'default': 1.618033988749895 },
{ 'name': 'round', 'type': 'boolean', 'default': false },
{ 'name': 'size', 'type': 'number', 'array': true, 'length': 2 },
{ 'name': 'as', 'type': 'string', 'array': true, 'length': Output$3.length, 'default': Output$3 }
]
};
var prototype$7 = vegaUtil.inherits(Treemap, HierarchyLayout);
/**
* Treemap layout generator. Adds 'method' and 'ratio' parameters
* to configure the underlying tile method.
*/
prototype$7.layout = function() {
var x = d3Hierarchy.treemap();
x.ratio = function(_) {
var t = x.tile();
if (t.ratio) x.tile(t.ratio(_));
};
x.method = function(_) {
if (vegaUtil.hasOwnProperty(Tiles, _)) x.tile(Tiles[_]);
else vegaUtil.error('Unrecognized Treemap layout method: ' + _);
};
return x;
};
prototype$7.params = [
'method', 'ratio', 'size', 'round',
'padding', 'paddingInner', 'paddingOuter',
'paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft'
];
prototype$7.fields = Output$3;
exports.nest = Nest;
exports.pack = Pack;
exports.partition = Partition;
exports.stratify = Stratify;
exports.tree = Tree;
exports.treelinks = TreeLinks;
exports.treemap = Treemap;
Object.defineProperty(exports, '__esModule', { value: true });
})));

File diff suppressed because one or more lines are too long

7
node_modules/vega-hierarchy/index.js generated vendored Normal file
View File

@@ -0,0 +1,7 @@
export {default as nest} from './src/Nest';
export {default as pack} from './src/Pack';
export {default as partition} from './src/Partition';
export {default as stratify} from './src/Stratify';
export {default as tree} from './src/Tree';
export {default as treelinks} from './src/TreeLinks';
export {default as treemap} from './src/Treemap';

73
node_modules/vega-hierarchy/package.json generated vendored Normal file
View File

@@ -0,0 +1,73 @@
{
"_from": "vega-hierarchy@~4.0.6",
"_id": "vega-hierarchy@4.0.6",
"_inBundle": false,
"_integrity": "sha512-v71NQzz9503aBJgRPnrBEZ/87q58EjwylmAs3uh+SaI5ocMCn9+goE+x5ZwZ0gNT9qJv4Umm5L3GZ9h8LuXjlg==",
"_location": "/vega-hierarchy",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "vega-hierarchy@~4.0.6",
"name": "vega-hierarchy",
"escapedName": "vega-hierarchy",
"rawSpec": "~4.0.6",
"saveSpec": null,
"fetchSpec": "~4.0.6"
},
"_requiredBy": [
"/vega"
],
"_resolved": "https://registry.npmjs.org/vega-hierarchy/-/vega-hierarchy-4.0.6.tgz",
"_shasum": "e286e917e47f1d4d9bfefa278cfdfa163d9f1225",
"_spec": "vega-hierarchy@~4.0.6",
"_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-hierarchy": "^1.1.9",
"vega-dataflow": "^5.5.1",
"vega-util": "^1.13.2"
},
"deprecated": false,
"description": "Hierarchical layout transforms for Vega dataflows.",
"devDependencies": {
"vega-transforms": "*"
},
"gitHead": "8fe8d36961c128df8300e6bc4fe6aac1e537bbe0",
"homepage": "https://github.com/vega/vega#readme",
"keywords": [
"vega",
"hierarchy",
"layout",
"tree",
"treemap",
"cluster",
"pack"
],
"license": "BSD-3-Clause",
"main": "build/vega-hierarchy.js",
"module": "index",
"name": "vega-hierarchy",
"repository": {
"type": "git",
"url": "git+https://github.com/vega/vega.git"
},
"scripts": {
"build": "yarn rollup",
"postbuild": "terser build/vega-hierarchy.js -c -m -o build/vega-hierarchy.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-hierarchy:d3,vega-dataflow:vega,vega-util:vega -f umd -n vega.transforms -o build/vega-hierarchy.js -- index.js",
"test": "tape 'test/**/*-test.js'"
},
"version": "4.0.6"
}

61
node_modules/vega-hierarchy/src/HierarchyLayout.js generated vendored Normal file
View File

@@ -0,0 +1,61 @@
import {Transform, stableCompare} from 'vega-dataflow';
import {error, inherits, one} from 'vega-util';
/**
* Abstract class for tree layout.
* @constructor
* @param {object} params - The parameters for this operator.
*/
export default function HierarchyLayout(params) {
Transform.call(this, null, params);
}
var prototype = inherits(HierarchyLayout, Transform);
prototype.transform = function(_, pulse) {
if (!pulse.source || !pulse.source.root) {
error(this.constructor.name
+ ' transform requires a backing tree data source.');
}
var layout = this.layout(_.method),
fields = this.fields,
root = pulse.source.root,
as = _.as || fields;
if (_.field) root.sum(_.field); else root.count();
if (_.sort) root.sort(stableCompare(_.sort, d => d.data));
setParams(layout, this.params, _);
if (layout.separation) {
layout.separation(_.separation !== false ? defaultSeparation : one);
}
try {
this.value = layout(root);
} catch (err) {
error(err);
}
root.each(function(node) { setFields(node, fields, as); });
return pulse.reflow(_.modified()).modifies(as).modifies('leaf');
};
function setParams(layout, params, _) {
for (var p, i=0, n=params.length; i<n; ++i) {
p = params[i];
if (p in _) layout[p](_[p]);
}
}
function setFields(node, fields, as) {
var t = node.data;
for (var i=0, n=fields.length-1; i<n; ++i) {
t[as[i]] = node[fields[i]];
}
t[as[n]] = node.children ? node.children.length : 0;
}
function defaultSeparation(a, b) {
return a.parent === b.parent ? 1 : 2;
}

128
node_modules/vega-hierarchy/src/Nest.js generated vendored Normal file
View File

@@ -0,0 +1,128 @@
import lookup from './lookup';
import {Transform, ingest, isTuple, tupleid} from 'vega-dataflow';
import {array, error, inherits} from 'vega-util';
import {hierarchy} from 'd3-hierarchy';
/**
* Nest tuples into a tree structure, grouped by key values.
* @constructor
* @param {object} params - The parameters for this operator.
* @param {Array<function(object): *>} params.keys - The key fields to nest by, in order.
* @param {boolean} [params.generate=false] - A boolean flag indicating if
* non-leaf nodes generated by this transform should be included in the
* output. The default (false) includes only the input data (leaf nodes)
* in the data stream.
*/
export default function Nest(params) {
Transform.call(this, null, params);
}
Nest.Definition = {
'type': 'Nest',
'metadata': {'treesource': true, 'changes': true},
'params': [
{ 'name': 'keys', 'type': 'field', 'array': true },
{ 'name': 'generate', 'type': 'boolean' }
]
};
var prototype = inherits(Nest, Transform);
function children(n) {
return n.values;
}
prototype.transform = function(_, pulse) {
if (!pulse.source) {
error('Nest transform requires an upstream data source.');
}
var gen = _.generate,
mod = _.modified(),
out = pulse.clone(),
tree = this.value;
if (!tree || mod || pulse.changed()) {
// collect nodes to remove
if (tree) {
tree.each(node => {
if (node.children && isTuple(node.data)) {
out.rem.push(node.data);
}
});
}
// generate new tree structure
this.value = tree = hierarchy({
values: array(_.keys)
.reduce((n, k) => { n.key(k); return n; }, nest())
.entries(out.source)
}, children);
// collect nodes to add
if (gen) {
tree.each(node => {
if (node.children) {
node = ingest(node.data);
out.add.push(node);
out.source.push(node);
}
});
}
// build lookup table
lookup(tree, tupleid, tupleid);
}
out.source.root = tree;
return out;
};
function nest() {
var keys = [],
nest;
function apply(array, depth) {
if (depth >= keys.length) {
return array;
}
var i = -1,
n = array.length,
key = keys[depth++],
keyValue,
value,
valuesByKey = {},
values,
result = {};
while (++i < n) {
keyValue = key(value = array[i]) + '';
if (values = valuesByKey[keyValue]) {
values.push(value);
} else {
valuesByKey[keyValue] = [value];
}
}
for (keyValue in valuesByKey) {
result[keyValue] = apply(valuesByKey[keyValue], depth);
}
return result;
}
function entries(map, depth) {
if (++depth > keys.length) return map;
var array = [], k;
for (k in map) {
array.push({key: k, values: entries(map[k], depth)});
}
return array;
}
return nest = {
entries: array => entries(apply(array, 0), 0),
key: d => { keys.push(d); return nest; }
};
}

36
node_modules/vega-hierarchy/src/Pack.js generated vendored Normal file
View File

@@ -0,0 +1,36 @@
import HierarchyLayout from './HierarchyLayout';
import {inherits} from 'vega-util';
import {pack} from 'd3-hierarchy';
var Output = ['x', 'y', 'r', 'depth', 'children'];
/**
* Packed circle tree layout.
* @constructor
* @param {object} params - The parameters for this operator.
* @param {function(object): *} params.field - The value field to size nodes.
*/
export default function Pack(params) {
HierarchyLayout.call(this, params);
}
Pack.Definition = {
'type': 'Pack',
'metadata': {'tree': true, 'modifies': true},
'params': [
{ 'name': 'field', 'type': 'field' },
{ 'name': 'sort', 'type': 'compare' },
{ 'name': 'padding', 'type': 'number', 'default': 0 },
{ 'name': 'radius', 'type': 'field', 'default': null },
{ 'name': 'size', 'type': 'number', 'array': true, 'length': 2 },
{ 'name': 'as', 'type': 'string', 'array': true, 'length': Output.length, 'default': Output }
]
};
var prototype = inherits(Pack, HierarchyLayout);
prototype.layout = pack;
prototype.params = ['radius', 'size', 'padding'];
prototype.fields = Output;

36
node_modules/vega-hierarchy/src/Partition.js generated vendored Normal file
View File

@@ -0,0 +1,36 @@
import HierarchyLayout from './HierarchyLayout';
import {inherits} from 'vega-util';
import {partition} from 'd3-hierarchy';
var Output = ['x0', 'y0', 'x1', 'y1', 'depth', 'children'];
/**
* Partition tree layout.
* @constructor
* @param {object} params - The parameters for this operator.
* @param {function(object): *} params.field - The value field to size nodes.
*/
export default function Partition(params) {
HierarchyLayout.call(this, params);
}
Partition.Definition = {
'type': 'Partition',
'metadata': {'tree': true, 'modifies': true},
'params': [
{ 'name': 'field', 'type': 'field' },
{ 'name': 'sort', 'type': 'compare' },
{ 'name': 'padding', 'type': 'number', 'default': 0 },
{ 'name': 'round', 'type': 'boolean', 'default': false },
{ 'name': 'size', 'type': 'number', 'array': true, 'length': 2 },
{ 'name': 'as', 'type': 'string', 'array': true, 'length': Output.length, 'default': Output }
]
};
var prototype = inherits(Partition, HierarchyLayout);
prototype.layout = partition;
prototype.params = ['size', 'round', 'padding'];
prototype.fields = Output;

58
node_modules/vega-hierarchy/src/Stratify.js generated vendored Normal file
View File

@@ -0,0 +1,58 @@
import lookup from './lookup';
import {Transform} from 'vega-dataflow';
import {error, inherits, truthy} from 'vega-util';
import {stratify} from 'd3-hierarchy';
/**
* Stratify a collection of tuples into a tree structure based on
* id and parent id fields.
* @constructor
* @param {object} params - The parameters for this operator.
* @param {function(object): *} params.key - Unique key field for each tuple.
* @param {function(object): *} params.parentKey - Field with key for parent tuple.
*/
export default function Stratify(params) {
Transform.call(this, null, params);
}
Stratify.Definition = {
'type': 'Stratify',
'metadata': {'treesource': true},
'params': [
{ 'name': 'key', 'type': 'field', 'required': true },
{ 'name': 'parentKey', 'type': 'field', 'required': true }
]
};
var prototype = inherits(Stratify, Transform);
prototype.transform = function(_, pulse) {
if (!pulse.source) {
error('Stratify transform requires an upstream data source.');
}
var tree = this.value,
mod = _.modified(),
out = pulse.fork(pulse.ALL).materialize(pulse.SOURCE),
run = !this.value
|| mod
|| pulse.changed(pulse.ADD_REM)
|| pulse.modified(_.key.fields)
|| pulse.modified(_.parentKey.fields);
// prevent upstream source pollution
out.source = out.source.slice();
if (run) {
if (out.source.length) {
tree = lookup(
stratify().id(_.key).parentId(_.parentKey)(out.source)
, _.key, truthy);
} else {
tree = lookup(stratify()([{}]), _.key, _.key);
}
}
out.source.root = this.value = tree;
return out;
};

49
node_modules/vega-hierarchy/src/Tree.js generated vendored Normal file
View File

@@ -0,0 +1,49 @@
import HierarchyLayout from './HierarchyLayout';
import {error, hasOwnProperty, inherits} from 'vega-util';
import {cluster, tree} from 'd3-hierarchy';
var Layouts = {
tidy: tree,
cluster: cluster
};
var Output = ['x', 'y', 'depth', 'children'];
/**
* Tree layout. Depending on the method parameter, performs either
* Reingold-Tilford 'tidy' layout or dendrogram 'cluster' layout.
* @constructor
* @param {object} params - The parameters for this operator.
*/
export default function Tree(params) {
HierarchyLayout.call(this, params);
}
Tree.Definition = {
'type': 'Tree',
'metadata': {'tree': true, 'modifies': true},
'params': [
{ 'name': 'field', 'type': 'field' },
{ 'name': 'sort', 'type': 'compare' },
{ 'name': 'method', 'type': 'enum', 'default': 'tidy', 'values': ['tidy', 'cluster'] },
{ 'name': 'size', 'type': 'number', 'array': true, 'length': 2 },
{ 'name': 'nodeSize', 'type': 'number', 'array': true, 'length': 2 },
{ 'name': 'separation', 'type': 'boolean', 'default': true },
{ 'name': 'as', 'type': 'string', 'array': true, 'length': Output.length, 'default': Output }
]
};
var prototype = inherits(Tree, HierarchyLayout);
/**
* Tree layout generator. Supports both 'tidy' and 'cluster' layouts.
*/
prototype.layout = function(method) {
var m = method || 'tidy';
if (hasOwnProperty(Layouts, m)) return Layouts[m]();
else error('Unrecognized Tree layout method: ' + m);
};
prototype.params = ['size', 'nodeSize'];
prototype.fields = Output;

62
node_modules/vega-hierarchy/src/TreeLinks.js generated vendored Normal file
View File

@@ -0,0 +1,62 @@
import {Transform, ingest, tupleid} from 'vega-dataflow';
import {error, inherits} from 'vega-util';
/**
* Generate tuples representing links between tree nodes.
* The resulting tuples will contain 'source' and 'target' fields,
* which point to parent and child node tuples, respectively.
* @constructor
* @param {object} params - The parameters for this operator.
*/
export default function TreeLinks(params) {
Transform.call(this, [], params);
}
TreeLinks.Definition = {
'type': 'TreeLinks',
'metadata': {'tree': true, 'generates': true, 'changes': true},
'params': []
};
var prototype = inherits(TreeLinks, Transform);
prototype.transform = function(_, pulse) {
var links = this.value,
tree = pulse.source && pulse.source.root,
out = pulse.fork(pulse.NO_SOURCE),
lut = {};
if (!tree) error('TreeLinks transform requires a tree data source.');
if (pulse.changed(pulse.ADD_REM)) {
// remove previous links
out.rem = links;
// build lookup table of valid tuples
pulse.visit(pulse.SOURCE, function(t) { lut[tupleid(t)] = 1; });
// generate links for all edges incident on valid tuples
tree.each(function(node) {
var t = node.data,
p = node.parent && node.parent.data;
if (p && lut[tupleid(t)] && lut[tupleid(p)]) {
out.add.push(ingest({source: p, target: t}));
}
});
this.value = out.add;
}
else if (pulse.changed(pulse.MOD)) {
// build lookup table of modified tuples
pulse.visit(pulse.MOD, function(t) { lut[tupleid(t)] = 1; });
// gather links incident on modified tuples
links.forEach(function(link) {
if (lut[tupleid(link.source)] || lut[tupleid(link.target)]) {
out.mod.push(link);
}
});
}
return out;
};

81
node_modules/vega-hierarchy/src/Treemap.js generated vendored Normal file
View File

@@ -0,0 +1,81 @@
import HierarchyLayout from './HierarchyLayout';
import {error, hasOwnProperty, inherits} from 'vega-util';
import {
treemap,
treemapBinary,
treemapDice,
treemapResquarify,
treemapSlice,
treemapSliceDice,
treemapSquarify
} from 'd3-hierarchy';
var Tiles = {
binary: treemapBinary,
dice: treemapDice,
slice: treemapSlice,
slicedice: treemapSliceDice,
squarify: treemapSquarify,
resquarify: treemapResquarify
};
var Output = ['x0', 'y0', 'x1', 'y1', 'depth', 'children'];
/**
* Treemap layout.
* @constructor
* @param {object} params - The parameters for this operator.
* @param {function(object): *} params.field - The value field to size nodes.
*/
export default function Treemap(params) {
HierarchyLayout.call(this, params);
}
Treemap.Definition = {
'type': 'Treemap',
'metadata': {'tree': true, 'modifies': true},
'params': [
{ 'name': 'field', 'type': 'field' },
{ 'name': 'sort', 'type': 'compare' },
{ 'name': 'method', 'type': 'enum', 'default': 'squarify',
'values': ['squarify', 'resquarify', 'binary', 'dice', 'slice', 'slicedice'] },
{ 'name': 'padding', 'type': 'number', 'default': 0 },
{ 'name': 'paddingInner', 'type': 'number', 'default': 0 },
{ 'name': 'paddingOuter', 'type': 'number', 'default': 0 },
{ 'name': 'paddingTop', 'type': 'number', 'default': 0 },
{ 'name': 'paddingRight', 'type': 'number', 'default': 0 },
{ 'name': 'paddingBottom', 'type': 'number', 'default': 0 },
{ 'name': 'paddingLeft', 'type': 'number', 'default': 0 },
{ 'name': 'ratio', 'type': 'number', 'default': 1.618033988749895 },
{ 'name': 'round', 'type': 'boolean', 'default': false },
{ 'name': 'size', 'type': 'number', 'array': true, 'length': 2 },
{ 'name': 'as', 'type': 'string', 'array': true, 'length': Output.length, 'default': Output }
]
};
var prototype = inherits(Treemap, HierarchyLayout);
/**
* Treemap layout generator. Adds 'method' and 'ratio' parameters
* to configure the underlying tile method.
*/
prototype.layout = function() {
var x = treemap();
x.ratio = function(_) {
var t = x.tile();
if (t.ratio) x.tile(t.ratio(_));
};
x.method = function(_) {
if (hasOwnProperty(Tiles, _)) x.tile(Tiles[_]);
else error('Unrecognized Treemap layout method: ' + _);
};
return x;
};
prototype.params = [
'method', 'ratio', 'size', 'round',
'padding', 'paddingInner', 'paddingOuter',
'paddingTop', 'paddingRight', 'paddingBottom', 'paddingLeft'
];
prototype.fields = Output;

10
node_modules/vega-hierarchy/src/lookup.js generated vendored Normal file
View File

@@ -0,0 +1,10 @@
// Build lookup table mapping tuple keys to tree node instances
export default function(tree, key, filter) {
var map = {};
tree.each(function(node) {
var t = node.data;
if (filter(t)) map[key(t)] = node;
});
tree.lookup = map;
return tree;
}