UNPKG
vega-hierarchy
Version:
latest (5.1.0)
5.1.0
5.0.0
4.1.3
4.1.2
4.1.1
4.1.0
4.0.9
4.0.8
4.0.7
4.0.6
4.0.5
4.0.4
4.0.3
4.0.2
4.0.1
4.0.0
3.1.0
3.0.3
3.0.2
3.0.1
3.0.0
2.1.2
2.1.1
2.1.0
2.0.0
1.0.0
1.0.0-beta.2
1.0.0-beta.1
1.0.0-beta
Hierarchical layout transforms for Vega dataflows.
vega-hierarchy
/
src
/
lookup.js
11 lines
(10 loc)
•
257 B
JavaScript
View Raw
1
2
3
4
5
6
7
8
9
10
11
// Build lookup table mapping tuple keys to tree node instances
export
default
function
(
tree, key, filter
) {
const
map = {}; tree.
each
(
node
=>
{
const
t = node.
data
;
if
(
filter
(t)) map[
key
(t)] = node; }); tree.
lookup
= map;
return
tree; }