@unovis/ts 1.5.1-exf.2 → 1.5.1-exf.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/graph/config.d.ts +2 -1
- package/components/graph/config.js.map +1 -1
- package/components/graph/index.d.ts +8 -0
- package/components/graph/index.js +27 -9
- package/components/graph/index.js.map +1 -1
- package/components/graph/modules/link/index.d.ts +3 -2
- package/components/graph/modules/link/index.js +39 -19
- package/components/graph/modules/link/index.js.map +1 -1
- package/components/graph/modules/node/index.d.ts +2 -0
- package/components/graph/modules/node/index.js +6 -3
- package/components/graph/modules/node/index.js.map +1 -1
- package/components/nested-donut/config.d.ts +1 -1
- package/components/nested-donut/config.js.map +1 -1
- package/components/treemap/config.d.ts +26 -0
- package/components/treemap/config.js +6 -0
- package/components/treemap/config.js.map +1 -0
- package/components/treemap/index.d.ts +14 -0
- package/components/treemap/index.js +149 -0
- package/components/treemap/index.js.map +1 -0
- package/components/treemap/style.d.ts +19 -0
- package/components/treemap/style.js +49 -0
- package/components/treemap/style.js.map +1 -0
- package/components/treemap/types.d.ts +10 -0
- package/components/treemap/types.js +2 -0
- package/components/treemap/types.js.map +1 -0
- package/components.d.ts +2 -0
- package/components.js +1 -0
- package/components.js.map +1 -1
- package/data-models/graph.d.ts +3 -2
- package/data-models/graph.js +15 -6
- package/data-models/graph.js.map +1 -1
- package/index.js +1 -0
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/types.d.ts +1 -0
- package/types.js +1 -0
- package/types.js.map +1 -1
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { hierarchy, treemap } from 'd3-hierarchy';
|
|
2
|
+
import { group, max } from 'd3-array';
|
|
3
|
+
import { scaleLinear } from 'd3-scale';
|
|
4
|
+
import { ComponentCore } from '../../core/component/index.js';
|
|
5
|
+
import { SeriesDataModel } from '../../data-models/series.js';
|
|
6
|
+
import { getColor } from '../../utils/color.js';
|
|
7
|
+
import { isNumber, getString, getNumber } from '../../utils/data.js';
|
|
8
|
+
import { smartTransition } from '../../utils/d3.js';
|
|
9
|
+
import { TreemapDefaultConfig } from './config.js';
|
|
10
|
+
import * as style from './style.js';
|
|
11
|
+
import { tiles, tile, tileBackground, tileForeground, label } from './style.js';
|
|
12
|
+
|
|
13
|
+
class Treemap extends ComponentCore {
|
|
14
|
+
constructor(config) {
|
|
15
|
+
super();
|
|
16
|
+
this._defaultConfig = TreemapDefaultConfig;
|
|
17
|
+
this.config = this._defaultConfig;
|
|
18
|
+
this.datamodel = new SeriesDataModel();
|
|
19
|
+
if (config)
|
|
20
|
+
this.setConfig(config);
|
|
21
|
+
this.tiles = this.g.append('g').attr('class', tiles);
|
|
22
|
+
}
|
|
23
|
+
_render(customDuration) {
|
|
24
|
+
var _a;
|
|
25
|
+
const { config, datamodel: { data } } = this;
|
|
26
|
+
const duration = isNumber(customDuration) ? customDuration : config.duration;
|
|
27
|
+
if (!((_a = config.layers) === null || _a === void 0 ? void 0 : _a.length)) {
|
|
28
|
+
console.warn('Unovis | Treemap: No layers defined');
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
// Map each layer accessor function to get string values from the data array
|
|
32
|
+
const layerAccessors = config.layers.map(layerAccessor => {
|
|
33
|
+
return (i) => getString(data[i], layerAccessor, i);
|
|
34
|
+
});
|
|
35
|
+
// Group the data indices by the layer accessors to create a hierarchical structure
|
|
36
|
+
const nestedData = group(data.keys(), ...layerAccessors);
|
|
37
|
+
const rootNode = config.value !== undefined
|
|
38
|
+
? hierarchy(nestedData).sum(index => typeof index === 'number' && getNumber(data[index], config.value, index))
|
|
39
|
+
: hierarchy(nestedData).count();
|
|
40
|
+
const treemapLayout = treemap()
|
|
41
|
+
.size([this._width, this._height])
|
|
42
|
+
.round(true)
|
|
43
|
+
.padding(this.config.tilePadding);
|
|
44
|
+
if (this.config.tilePaddingTop !== undefined) {
|
|
45
|
+
treemapLayout.paddingTop(this.config.tilePaddingTop);
|
|
46
|
+
}
|
|
47
|
+
const treemapData = treemapLayout(rootNode);
|
|
48
|
+
const descendants = treemapData.descendants();
|
|
49
|
+
// Set up the opacity scale based on depth
|
|
50
|
+
const maxDepth = max(descendants, d => d.depth);
|
|
51
|
+
const opacity = scaleLinear()
|
|
52
|
+
.domain([1, maxDepth])
|
|
53
|
+
.range([1, 0.2]);
|
|
54
|
+
// Set fill color and opacity for each node
|
|
55
|
+
treemapData
|
|
56
|
+
.eachBefore((node) => {
|
|
57
|
+
if (!node.children)
|
|
58
|
+
return;
|
|
59
|
+
node.children.forEach((child, i) => {
|
|
60
|
+
const treemapChild = child;
|
|
61
|
+
// Calculate color for this child using the color accessor function
|
|
62
|
+
const color = getColor(treemapChild, config.tileColor, i, treemapChild.depth !== 1);
|
|
63
|
+
// If no color for this child, use the parent's color
|
|
64
|
+
treemapChild._fill = color !== null && color !== void 0 ? color : node._fill;
|
|
65
|
+
// Set opacity based on depth
|
|
66
|
+
treemapChild._fillOpacity = color === null ? opacity(treemapChild.depth) : null;
|
|
67
|
+
});
|
|
68
|
+
});
|
|
69
|
+
// Render tiles
|
|
70
|
+
const visibleNodes = descendants.filter(d => d.depth > 0);
|
|
71
|
+
const tiles = this.tiles
|
|
72
|
+
.selectAll(`g.${tile}`)
|
|
73
|
+
.data(visibleNodes, d => d._id);
|
|
74
|
+
const tilesEnter = tiles
|
|
75
|
+
.enter()
|
|
76
|
+
.append('g')
|
|
77
|
+
.attr('class', tile);
|
|
78
|
+
// Tile background rectangles
|
|
79
|
+
tilesEnter
|
|
80
|
+
.append('rect')
|
|
81
|
+
.attr('class', tileBackground)
|
|
82
|
+
// Initialize tile positions so that the initial transition is smooth
|
|
83
|
+
.attr('x', d => d.x0)
|
|
84
|
+
.attr('y', d => d.y0)
|
|
85
|
+
.attr('width', d => d.x1 - d.x0)
|
|
86
|
+
.attr('height', d => d.y1 - d.y0);
|
|
87
|
+
tiles.merge(tilesEnter).select(`rect.${tileBackground}`)
|
|
88
|
+
.call(selection => smartTransition(selection, duration)
|
|
89
|
+
.attr('x', d => d.x0)
|
|
90
|
+
.attr('y', d => d.y0)
|
|
91
|
+
.attr('width', d => d.x1 - d.x0)
|
|
92
|
+
.attr('height', d => d.y1 - d.y0));
|
|
93
|
+
// Tile foreground rectangles
|
|
94
|
+
tilesEnter
|
|
95
|
+
.append('rect')
|
|
96
|
+
.attr('class', tileForeground)
|
|
97
|
+
// Initialize tile positions so that the initial transition is smooth
|
|
98
|
+
.attr('x', d => d.x0)
|
|
99
|
+
.attr('y', d => d.y0)
|
|
100
|
+
.attr('width', d => d.x1 - d.x0)
|
|
101
|
+
.attr('height', d => d.y1 - d.y0)
|
|
102
|
+
.style('fill', d => { var _a; return (_a = d._fill) !== null && _a !== void 0 ? _a : getColor(d, config.tileColor); })
|
|
103
|
+
// Make the tiles fade in on enter
|
|
104
|
+
.style('fill-opacity', 0);
|
|
105
|
+
tiles.merge(tilesEnter).select(`rect.${tileForeground}`)
|
|
106
|
+
.call(selection => smartTransition(selection, duration)
|
|
107
|
+
.style('fill', d => { var _a; return (_a = d._fill) !== null && _a !== void 0 ? _a : getColor(d, config.tileColor); })
|
|
108
|
+
.style('fill-opacity', d => { var _a; return (_a = d._fillOpacity) !== null && _a !== void 0 ? _a : 1; })
|
|
109
|
+
.attr('x', d => d.x0)
|
|
110
|
+
.attr('y', d => d.y0)
|
|
111
|
+
.attr('width', d => d.x1 - d.x0)
|
|
112
|
+
.attr('height', d => d.y1 - d.y0));
|
|
113
|
+
// Tile labels
|
|
114
|
+
tilesEnter
|
|
115
|
+
.append('text')
|
|
116
|
+
.attr('class', label);
|
|
117
|
+
tiles.merge(tilesEnter)
|
|
118
|
+
.filter(config.labelInternalNodes
|
|
119
|
+
? () => true
|
|
120
|
+
: d => !d.children)
|
|
121
|
+
.select(`text.${label}`)
|
|
122
|
+
.attr('x', d => d.x0 + config.labelOffsetX)
|
|
123
|
+
.attr('y', d => d.y0 + config.labelOffsetY)
|
|
124
|
+
.text(d => {
|
|
125
|
+
if (typeof d.data === 'number') {
|
|
126
|
+
const index = d.data;
|
|
127
|
+
// Leaf node case
|
|
128
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
129
|
+
// @ts-ignore
|
|
130
|
+
return config.value(data[index]);
|
|
131
|
+
}
|
|
132
|
+
else {
|
|
133
|
+
// Internal node case
|
|
134
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
135
|
+
// @ts-ignore
|
|
136
|
+
return d.data[0];
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
// Exit
|
|
140
|
+
const tilesExit = tiles.exit();
|
|
141
|
+
smartTransition(tilesExit, duration)
|
|
142
|
+
.style('opacity', 0)
|
|
143
|
+
.remove();
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
Treemap.selectors = style;
|
|
147
|
+
|
|
148
|
+
export { Treemap };
|
|
149
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/treemap/index.ts"],"sourcesContent":["import { Selection } from 'd3-selection'\nimport { hierarchy, treemap } from 'd3-hierarchy'\nimport { group, max } from 'd3-array'\nimport { scaleLinear } from 'd3-scale'\nimport { ComponentCore } from 'core/component'\nimport { SeriesDataModel } from 'data-models/series'\nimport { getColor } from 'utils/color'\nimport { getString, getNumber, isNumber } from 'utils/data'\nimport { smartTransition } from 'utils/d3'\nimport { TreemapConfigInterface, TreemapDefaultConfig } from './config'\nimport { TreemapNode } from './types'\n\nimport * as s from './style'\n\nexport class Treemap<Datum> extends ComponentCore<Datum[], TreemapConfigInterface<Datum>> {\n static selectors = s\n protected _defaultConfig = TreemapDefaultConfig as TreemapConfigInterface<Datum>\n public config: TreemapConfigInterface<Datum> = this._defaultConfig\n\n datamodel: SeriesDataModel<Datum> = new SeriesDataModel()\n tiles: Selection<SVGGElement, unknown, SVGGElement, unknown>\n\n constructor (config?: TreemapConfigInterface<Datum>) {\n super()\n if (config) this.setConfig(config)\n this.tiles = this.g.append('g').attr('class', s.tiles)\n }\n\n _render (customDuration?: number): void {\n const { config, datamodel: { data } } = this\n const duration = isNumber(customDuration) ? customDuration : config.duration\n\n if (!config.layers?.length) {\n console.warn('Unovis | Treemap: No layers defined')\n return\n }\n\n // Map each layer accessor function to get string values from the data array\n const layerAccessors = config.layers.map(layerAccessor => {\n return (i: number) => getString(data[i], layerAccessor, i)\n })\n\n // Group the data indices by the layer accessors to create a hierarchical structure\n const nestedData = group(data.keys(), ...layerAccessors as [(d: number) => string])\n\n const rootNode = config.value !== undefined\n ? hierarchy(nestedData).sum(index => typeof index === 'number' && getNumber(data[index], config.value, index))\n : hierarchy(nestedData).count()\n\n const treemapLayout = treemap()\n .size([this._width, this._height])\n .round(true)\n .padding(this.config.tilePadding)\n\n if (this.config.tilePaddingTop !== undefined) {\n treemapLayout.paddingTop(this.config.tilePaddingTop)\n }\n\n const treemapData = treemapLayout(rootNode) as TreemapNode<Datum>\n\n const descendants = treemapData.descendants()\n\n // Set up the opacity scale based on depth\n const maxDepth = max(descendants, d => d.depth)\n const opacity = scaleLinear()\n .domain([1, maxDepth])\n .range([1, 0.2])\n\n // Set fill color and opacity for each node\n treemapData\n .eachBefore((node) => {\n if (!node.children) return\n node.children.forEach((child, i) => {\n const treemapChild = child as TreemapNode<Datum>\n\n // Calculate color for this child using the color accessor function\n const color = getColor(treemapChild, config.tileColor, i, treemapChild.depth !== 1)\n\n // If no color for this child, use the parent's color\n treemapChild._fill = color ?? (node as TreemapNode<Datum>)._fill\n\n // Set opacity based on depth\n treemapChild._fillOpacity = color === null ? opacity(treemapChild.depth) : null\n })\n })\n\n // Render tiles\n const visibleNodes = descendants.filter(d => d.depth > 0)\n const tiles = this.tiles\n .selectAll<SVGGElement, TreemapNode<Datum>>(`g.${s.tile}`)\n .data(visibleNodes, d => d._id)\n const tilesEnter = tiles\n .enter()\n .append('g')\n .attr('class', s.tile)\n\n // Tile background rectangles\n tilesEnter\n .append('rect')\n .attr('class', s.tileBackground)\n\n // Initialize tile positions so that the initial transition is smooth\n .attr('x', d => d.x0)\n .attr('y', d => d.y0)\n .attr('width', d => d.x1 - d.x0)\n .attr('height', d => d.y1 - d.y0)\n\n tiles.merge(tilesEnter).select(`rect.${s.tileBackground}`)\n .call(selection => smartTransition(selection, duration)\n .attr('x', d => d.x0)\n .attr('y', d => d.y0)\n .attr('width', d => d.x1 - d.x0)\n .attr('height', d => d.y1 - d.y0)\n )\n\n // Tile foreground rectangles\n tilesEnter\n .append('rect')\n .attr('class', s.tileForeground)\n // Initialize tile positions so that the initial transition is smooth\n .attr('x', d => d.x0)\n .attr('y', d => d.y0)\n .attr('width', d => d.x1 - d.x0)\n .attr('height', d => d.y1 - d.y0)\n .style('fill', d => d._fill ?? getColor(d, config.tileColor))\n\n // Make the tiles fade in on enter\n .style('fill-opacity', 0)\n\n tiles.merge(tilesEnter).select(`rect.${s.tileForeground}`)\n .call(selection => smartTransition(selection, duration)\n .style('fill', d => d._fill ?? getColor(d, config.tileColor))\n .style('fill-opacity', d => d._fillOpacity ?? 1)\n .attr('x', d => d.x0)\n .attr('y', d => d.y0)\n .attr('width', d => d.x1 - d.x0)\n .attr('height', d => d.y1 - d.y0)\n )\n\n // Tile labels\n tilesEnter\n .append('text')\n .attr('class', s.label)\n tiles.merge(tilesEnter)\n .filter(config.labelInternalNodes\n ? () => true\n : d => !d.children\n )\n .select(`text.${s.label}`)\n .attr('x', d => d.x0 + config.labelOffsetX)\n .attr('y', d => d.y0 + config.labelOffsetY)\n .text(d => {\n if (typeof d.data === 'number') {\n const index = d.data\n // Leaf node case\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return config.value(data[index])\n } else {\n // Internal node case\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n return d.data[0]\n }\n })\n\n // Exit\n const tilesExit = tiles.exit()\n smartTransition(tilesExit, duration)\n .style('opacity', 0)\n .remove()\n }\n}\n"],"names":["s.tiles","s.tile","s.tileBackground","s.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CAAC,KAAK,CAAC,UAAU,CAAC;aACpB,MAAM,CAAC,MAAM,CAAC,kBAAkB;AAC/B,cAAE,MAAM,IAAI;cACV,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CACnB;AACA,aAAA,MAAM,CAAC,CAAQ,KAAA,EAAAA,KAAO,EAAE,CAAC;AACzB,aAAA,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,GAAG,MAAM,CAAC,YAAY,CAAC;AAC1C,aAAA,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,GAAG,MAAM,CAAC,YAAY,CAAC;aAC1C,IAAI,CAAC,CAAC,IAAG;AACR,YAAA,IAAI,OAAO,CAAC,CAAC,IAAI,KAAK,QAAQ,EAAE;AAC9B,gBAAA,MAAM,KAAK,GAAG,CAAC,CAAC,IAAI,CAAA;;;;gBAIpB,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAA;AACjC,aAAA;AAAM,iBAAA;;;;AAIL,gBAAA,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAA;AACjB,aAAA;AACH,SAAC,CAAC,CAAA;;AAGJ,QAAA,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,EAAE,CAAA;AAC9B,QAAA,eAAe,CAAC,SAAS,EAAE,QAAQ,CAAC;AACjC,aAAA,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC;AACnB,aAAA,MAAM,EAAE,CAAA;KACZ;;AA5JM,OAAS,CAAA,SAAA,GAAGC,KAAC;;;;"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare const root: string;
|
|
2
|
+
export declare const variables: {
|
|
3
|
+
treemapTileStrokeColor: "--vis-treemap-tile-stroke-color";
|
|
4
|
+
treemapTileStrokeWidth: "--vis-treemap-tile-stroke-width";
|
|
5
|
+
treemapTileFillColor: "--vis-treemap-tile-fill-color";
|
|
6
|
+
treemapTileBackgroundColor: "--vis-treemap-tile-background-color";
|
|
7
|
+
treemapTileCursor: "--vis-treemap-tile-cursor";
|
|
8
|
+
treemapLabelFontFamily: "--vis-treemap-label-font-family";
|
|
9
|
+
treemapLabelTextColor: "--vis-treemap-label-text-color";
|
|
10
|
+
treemapLabelFontSize: "--vis-treemap-label-font-size";
|
|
11
|
+
darkTreemapTileStrokeColor: "--vis-dark-treemap-tile-stroke-color";
|
|
12
|
+
darkTreemapTileFillColor: "--vis-dark-treemap-tile-fill-color";
|
|
13
|
+
darkTreemapLabelTextColor: "--vis-dark-treemap-label-text-color";
|
|
14
|
+
};
|
|
15
|
+
export declare const tiles: string;
|
|
16
|
+
export declare const tile: string;
|
|
17
|
+
export declare const tileBackground: string;
|
|
18
|
+
export declare const tileForeground: string;
|
|
19
|
+
export declare const label: string;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { css } from '@emotion/css';
|
|
2
|
+
import { getCssVarNames, injectGlobalCssVariables } from '../../utils/style.js';
|
|
3
|
+
|
|
4
|
+
const cssVarDefaults = {
|
|
5
|
+
'--vis-treemap-tile-stroke-color': '#fff',
|
|
6
|
+
'--vis-treemap-tile-stroke-width': '1px',
|
|
7
|
+
'--vis-treemap-tile-fill-color': '#B9BEC3',
|
|
8
|
+
'--vis-treemap-tile-background-color': '#fff',
|
|
9
|
+
'--vis-treemap-tile-cursor': 'default',
|
|
10
|
+
/* Undefined by default to allow proper fallback to var(--vis-font-family) */
|
|
11
|
+
'--vis-treemap-label-font-family': undefined,
|
|
12
|
+
'--vis-treemap-label-text-color': '#5b5f6d',
|
|
13
|
+
'--vis-treemap-label-font-size': '12px',
|
|
14
|
+
/* Dark Theme */
|
|
15
|
+
'--vis-dark-treemap-tile-stroke-color': '#2c2c2c',
|
|
16
|
+
'--vis-dark-treemap-tile-fill-color': '#5b5f6d',
|
|
17
|
+
'--vis-dark-treemap-label-text-color': '#fff',
|
|
18
|
+
};
|
|
19
|
+
const root = css `
|
|
20
|
+
label: treemap-component;
|
|
21
|
+
width: 100%;
|
|
22
|
+
height: 100%;
|
|
23
|
+
position: relative;
|
|
24
|
+
`;
|
|
25
|
+
const variables = getCssVarNames(cssVarDefaults);
|
|
26
|
+
injectGlobalCssVariables(cssVarDefaults, root);
|
|
27
|
+
const tiles = css `
|
|
28
|
+
label: g-tiles;
|
|
29
|
+
`;
|
|
30
|
+
const tile = css `
|
|
31
|
+
label: tile;
|
|
32
|
+
`;
|
|
33
|
+
const tileBackground = css `
|
|
34
|
+
label: tile-background;
|
|
35
|
+
fill: var(--vis-treemap-tile-background-color);
|
|
36
|
+
`;
|
|
37
|
+
const tileForeground = css `
|
|
38
|
+
label: tile-foreground;
|
|
39
|
+
`;
|
|
40
|
+
const label = css `
|
|
41
|
+
label: label;
|
|
42
|
+
text-anchor: start;
|
|
43
|
+
dominant-baseline: hanging;
|
|
44
|
+
user-select: none;
|
|
45
|
+
font-size: var(--vis-treemap-label-font-size);
|
|
46
|
+
`;
|
|
47
|
+
|
|
48
|
+
export { label, root, tile, tileBackground, tileForeground, tiles, variables };
|
|
49
|
+
//# sourceMappingURL=style.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"style.js","sources":["../../../src/components/treemap/style.ts"],"sourcesContent":["import { css } from '@emotion/css'\n\n// Utils\nimport { getCssVarNames, injectGlobalCssVariables } from 'utils/style'\n\nconst cssVarDefaults = {\n '--vis-treemap-tile-stroke-color': '#fff',\n '--vis-treemap-tile-stroke-width': '1px',\n '--vis-treemap-tile-fill-color': '#B9BEC3',\n '--vis-treemap-tile-background-color': '#fff',\n '--vis-treemap-tile-cursor': 'default',\n /* Undefined by default to allow proper fallback to var(--vis-font-family) */\n '--vis-treemap-label-font-family': undefined as undefined,\n '--vis-treemap-label-text-color': '#5b5f6d',\n '--vis-treemap-label-font-size': '12px',\n\n /* Dark Theme */\n '--vis-dark-treemap-tile-stroke-color': '#2c2c2c',\n '--vis-dark-treemap-tile-fill-color': '#5b5f6d',\n '--vis-dark-treemap-label-text-color': '#fff',\n}\n\nexport const root = css`\n label: treemap-component;\n width: 100%;\n height: 100%;\n position: relative;\n`\n\nexport const variables = getCssVarNames(cssVarDefaults)\ninjectGlobalCssVariables(cssVarDefaults, root)\n\nexport const tiles = css`\n label: g-tiles;\n`\n\nexport const tile = css`\n label: tile;\n`\n\nexport const tileBackground = css`\n label: tile-background;\n fill: var(--vis-treemap-tile-background-color);\n`\n\nexport const tileForeground = css`\n label: tile-foreground;\n`\n\nexport const label = css`\n label: label;\n text-anchor: start;\n dominant-baseline: hanging;\n user-select: none;\n font-size: var(--vis-treemap-label-font-size);\n`\n"],"names":[],"mappings":";;;AAKA,MAAM,cAAc,GAAG;AACrB,IAAA,iCAAiC,EAAE,MAAM;AACzC,IAAA,iCAAiC,EAAE,KAAK;AACxC,IAAA,+BAA+B,EAAE,SAAS;AAC1C,IAAA,qCAAqC,EAAE,MAAM;AAC7C,IAAA,2BAA2B,EAAE,SAAS;;AAEtC,IAAA,iCAAiC,EAAE,SAAsB;AACzD,IAAA,gCAAgC,EAAE,SAAS;AAC3C,IAAA,+BAA+B,EAAE,MAAM;;AAGvC,IAAA,sCAAsC,EAAE,SAAS;AACjD,IAAA,oCAAoC,EAAE,SAAS;AAC/C,IAAA,qCAAqC,EAAE,MAAM;CAC9C,CAAA;AAEM,MAAM,IAAI,GAAG,GAAG,CAAA,CAAA;;;;;EAKtB;MAEY,SAAS,GAAG,cAAc,CAAC,cAAc,EAAC;AACvD,wBAAwB,CAAC,cAAc,EAAE,IAAI,CAAC,CAAA;AAEvC,MAAM,KAAK,GAAG,GAAG,CAAA,CAAA;;EAEvB;AAEM,MAAM,IAAI,GAAG,GAAG,CAAA,CAAA;;EAEtB;AAEM,MAAM,cAAc,GAAG,GAAG,CAAA,CAAA;;;EAGhC;AAEM,MAAM,cAAc,GAAG,GAAG,CAAA,CAAA;;EAEhC;AAEM,MAAM,KAAK,GAAG,GAAG,CAAA,CAAA;;;;;;;;;;"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { HierarchyRectangularNode } from 'd3-hierarchy';
|
|
2
|
+
export declare type TreemapDatum<Datum> = {
|
|
3
|
+
datum: Datum;
|
|
4
|
+
index: number;
|
|
5
|
+
};
|
|
6
|
+
export interface TreemapNode<Datum> extends HierarchyRectangularNode<TreemapDatum<Datum>> {
|
|
7
|
+
_id: string;
|
|
8
|
+
_fill?: string;
|
|
9
|
+
_fillOpacity?: number | null;
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
package/components.d.ts
CHANGED
|
@@ -27,6 +27,7 @@ export { FreeBrush } from './components/free-brush';
|
|
|
27
27
|
export { XYLabels } from './components/xy-labels';
|
|
28
28
|
export { NestedDonut } from './components/nested-donut';
|
|
29
29
|
export { Annotations } from "./components/annotations";
|
|
30
|
+
export { Treemap } from './components/treemap';
|
|
30
31
|
export * from './components/donut/constants';
|
|
31
32
|
export type { LineConfigInterface } from './components/line/config';
|
|
32
33
|
export type { StackedBarConfigInterface } from './components/stacked-bar/config';
|
|
@@ -52,3 +53,4 @@ export type { FreeBrushConfigInterface } from './components/free-brush/config';
|
|
|
52
53
|
export type { XYLabelsConfigInterface } from './components/xy-labels/config';
|
|
53
54
|
export type { NestedDonutConfigInterface } from './components/nested-donut/config';
|
|
54
55
|
export type { AnnotationsConfigInterface } from './components/annotations/config';
|
|
56
|
+
export type { TreemapConfigInterface } from './components/treemap/config';
|
package/components.js
CHANGED
|
@@ -25,6 +25,7 @@ export { FreeBrush } from './components/free-brush/index.js';
|
|
|
25
25
|
export { XYLabels } from './components/xy-labels/index.js';
|
|
26
26
|
export { NestedDonut } from './components/nested-donut/index.js';
|
|
27
27
|
export { Annotations } from './components/annotations/index.js';
|
|
28
|
+
export { Treemap } from './components/treemap/index.js';
|
|
28
29
|
export { DONUT_HALF_ANGLE_RANGES, DONUT_HALF_ANGLE_RANGE_BOTTOM, DONUT_HALF_ANGLE_RANGE_LEFT, DONUT_HALF_ANGLE_RANGE_RIGHT, DONUT_HALF_ANGLE_RANGE_TOP } from './components/donut/constants.js';
|
|
29
30
|
|
|
30
31
|
// Core
|
package/components.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.js","sources":["../src/components.ts"],"sourcesContent":["// Core\nexport { ComponentCore } from 'core/component'\nexport type { ComponentConfigInterface } from 'core/component/config'\nexport { XYComponentCore } from 'core/xy-component'\nexport type { XYComponentConfigInterface } from 'core/xy-component/config'\n\n// Components\nexport { Tooltip } from 'components/tooltip'\nexport { Line } from './components/line'\nexport { StackedBar } from './components/stacked-bar'\nexport { GroupedBar } from './components/grouped-bar'\nexport { Axis } from './components/axis'\nexport { Scatter } from './components/scatter'\nexport { Brush } from './components/brush'\nexport { BulletLegend } from './components/bullet-legend'\nexport { FlowLegend } from './components/flow-legend'\nexport { Crosshair } from './components/crosshair'\nexport { Timeline } from './components/timeline'\nexport { Sankey } from './components/sankey'\nexport { Area } from './components/area'\nexport { TopoJSONMap } from './components/topojson-map'\nexport { LeafletMap } from './components/leaflet-map'\nexport { MapLibreArcticDark, MapLibreArcticLight } from './components/leaflet-map/renderer/map-style'\nexport { LeafletFlowMap } from './components/leaflet-flow-map'\nexport { ChordDiagram } from './components/chord-diagram'\nexport { Graph } from './components/graph'\nexport { VisControls } from './components/vis-controls'\nexport { Donut } from './components/donut'\nexport { FreeBrush } from './components/free-brush'\nexport { XYLabels } from './components/xy-labels'\nexport { NestedDonut } from './components/nested-donut'\nexport { Annotations } from 'components/annotations'\n\n// Constants\nexport * from './components/donut/constants'\n\n// Config Interfaces\nexport type { LineConfigInterface } from './components/line/config'\nexport type { StackedBarConfigInterface } from './components/stacked-bar/config'\nexport type { GroupedBarConfigInterface } from './components/grouped-bar/config'\nexport type { ScatterConfigInterface } from './components/scatter/config'\nexport type { TooltipConfigInterface } from './components/tooltip/config'\nexport type { BrushConfigInterface } from './components/brush/config'\nexport type { AxisConfigInterface } from './components/axis/config'\nexport type { BulletLegendConfigInterface } from './components/bullet-legend/config'\nexport type { FlowLegendConfigInterface } from './components/flow-legend/config'\nexport type { CrosshairConfigInterface } from './components/crosshair/config'\nexport type { TimelineConfigInterface } from './components/timeline/config'\nexport type { SankeyConfigInterface } from './components/sankey/config'\nexport type { AreaConfigInterface } from './components/area/config'\nexport type { TopoJSONMapConfigInterface } from './components/topojson-map/config'\nexport type { LeafletMapConfigInterface } from './components/leaflet-map/config'\nexport type { LeafletFlowMapConfigInterface } from './components/leaflet-flow-map/config'\nexport type { ChordDiagramConfigInterface } from './components/chord-diagram/config'\nexport type { GraphConfigInterface } from './components/graph/config'\nexport type { VisControlsConfigInterface } from './components/vis-controls/config'\nexport type { DonutConfigInterface } from './components/donut/config'\nexport type { FreeBrushConfigInterface } from './components/free-brush/config'\nexport type { XYLabelsConfigInterface } from './components/xy-labels/config'\nexport type { NestedDonutConfigInterface } from './components/nested-donut/config'\nexport type { AnnotationsConfigInterface } from './components/annotations/config'\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"components.js","sources":["../src/components.ts"],"sourcesContent":["// Core\nexport { ComponentCore } from 'core/component'\nexport type { ComponentConfigInterface } from 'core/component/config'\nexport { XYComponentCore } from 'core/xy-component'\nexport type { XYComponentConfigInterface } from 'core/xy-component/config'\n\n// Components\nexport { Tooltip } from 'components/tooltip'\nexport { Line } from './components/line'\nexport { StackedBar } from './components/stacked-bar'\nexport { GroupedBar } from './components/grouped-bar'\nexport { Axis } from './components/axis'\nexport { Scatter } from './components/scatter'\nexport { Brush } from './components/brush'\nexport { BulletLegend } from './components/bullet-legend'\nexport { FlowLegend } from './components/flow-legend'\nexport { Crosshair } from './components/crosshair'\nexport { Timeline } from './components/timeline'\nexport { Sankey } from './components/sankey'\nexport { Area } from './components/area'\nexport { TopoJSONMap } from './components/topojson-map'\nexport { LeafletMap } from './components/leaflet-map'\nexport { MapLibreArcticDark, MapLibreArcticLight } from './components/leaflet-map/renderer/map-style'\nexport { LeafletFlowMap } from './components/leaflet-flow-map'\nexport { ChordDiagram } from './components/chord-diagram'\nexport { Graph } from './components/graph'\nexport { VisControls } from './components/vis-controls'\nexport { Donut } from './components/donut'\nexport { FreeBrush } from './components/free-brush'\nexport { XYLabels } from './components/xy-labels'\nexport { NestedDonut } from './components/nested-donut'\nexport { Annotations } from 'components/annotations'\nexport { Treemap } from './components/treemap'\n\n// Constants\nexport * from './components/donut/constants'\n\n// Config Interfaces\nexport type { LineConfigInterface } from './components/line/config'\nexport type { StackedBarConfigInterface } from './components/stacked-bar/config'\nexport type { GroupedBarConfigInterface } from './components/grouped-bar/config'\nexport type { ScatterConfigInterface } from './components/scatter/config'\nexport type { TooltipConfigInterface } from './components/tooltip/config'\nexport type { BrushConfigInterface } from './components/brush/config'\nexport type { AxisConfigInterface } from './components/axis/config'\nexport type { BulletLegendConfigInterface } from './components/bullet-legend/config'\nexport type { FlowLegendConfigInterface } from './components/flow-legend/config'\nexport type { CrosshairConfigInterface } from './components/crosshair/config'\nexport type { TimelineConfigInterface } from './components/timeline/config'\nexport type { SankeyConfigInterface } from './components/sankey/config'\nexport type { AreaConfigInterface } from './components/area/config'\nexport type { TopoJSONMapConfigInterface } from './components/topojson-map/config'\nexport type { LeafletMapConfigInterface } from './components/leaflet-map/config'\nexport type { LeafletFlowMapConfigInterface } from './components/leaflet-flow-map/config'\nexport type { ChordDiagramConfigInterface } from './components/chord-diagram/config'\nexport type { GraphConfigInterface } from './components/graph/config'\nexport type { VisControlsConfigInterface } from './components/vis-controls/config'\nexport type { DonutConfigInterface } from './components/donut/config'\nexport type { FreeBrushConfigInterface } from './components/free-brush/config'\nexport type { XYLabelsConfigInterface } from './components/xy-labels/config'\nexport type { NestedDonutConfigInterface } from './components/nested-donut/config'\nexport type { AnnotationsConfigInterface } from './components/annotations/config'\nexport type { TreemapConfigInterface } from './components/treemap/config'\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA"}
|
package/data-models/graph.d.ts
CHANGED
|
@@ -10,11 +10,11 @@ export declare class GraphDataModel<N extends GraphInputNode, L extends GraphInp
|
|
|
10
10
|
private _nodes;
|
|
11
11
|
private _links;
|
|
12
12
|
private _inputNodesMap;
|
|
13
|
-
private
|
|
13
|
+
private _nodesMap;
|
|
14
14
|
nodeId: ((n: N) => string | undefined);
|
|
15
15
|
linkId: ((n: L) => string | undefined);
|
|
16
16
|
nodeSort: ((a: N, b: N) => number);
|
|
17
|
-
|
|
17
|
+
getNodeById(id: string | number): OutNode;
|
|
18
18
|
get data(): GraphData<N, L>;
|
|
19
19
|
set data(inputData: GraphData<N, L>);
|
|
20
20
|
get nodes(): OutNode[];
|
|
@@ -23,4 +23,5 @@ export declare class GraphDataModel<N extends GraphInputNode, L extends GraphInp
|
|
|
23
23
|
get nonConnectedNodes(): OutNode[];
|
|
24
24
|
private findNode;
|
|
25
25
|
private transferState;
|
|
26
|
+
setNodeStateById(id: string, state: Record<string, any>): void;
|
|
26
27
|
}
|
package/data-models/graph.js
CHANGED
|
@@ -7,13 +7,13 @@ class GraphDataModel extends CoreDataModel {
|
|
|
7
7
|
this._nodes = [];
|
|
8
8
|
this._links = [];
|
|
9
9
|
this._inputNodesMap = new Map();
|
|
10
|
-
this.
|
|
10
|
+
this._nodesMap = new Map();
|
|
11
11
|
// Model configuration
|
|
12
12
|
this.nodeId = n => (isString(n.id) || isFinite(n.id)) ? `${n.id}` : undefined;
|
|
13
13
|
this.linkId = l => (isString(l.id) || isFinite(l.id)) ? `${l.id}` : undefined;
|
|
14
14
|
}
|
|
15
|
-
|
|
16
|
-
return this.
|
|
15
|
+
getNodeById(id) {
|
|
16
|
+
return this._nodesMap.get(id);
|
|
17
17
|
}
|
|
18
18
|
get data() {
|
|
19
19
|
return this._data;
|
|
@@ -26,7 +26,8 @@ class GraphDataModel extends CoreDataModel {
|
|
|
26
26
|
const prevNodes = this.nodes;
|
|
27
27
|
const prevLinks = this.links;
|
|
28
28
|
this._inputNodesMap.clear();
|
|
29
|
-
this.
|
|
29
|
+
this._nodesMap.clear();
|
|
30
|
+
// Todo: Figure out why TypeScript complains about types
|
|
30
31
|
const nodes = cloneDeep((_a = inputData === null || inputData === void 0 ? void 0 : inputData.nodes) !== null && _a !== void 0 ? _a : []);
|
|
31
32
|
const links = cloneDeep((_b = inputData === null || inputData === void 0 ? void 0 : inputData.links) !== null && _b !== void 0 ? _b : []);
|
|
32
33
|
// Every node or link can have a private state used for rendering needs
|
|
@@ -38,7 +39,7 @@ class GraphDataModel extends CoreDataModel {
|
|
|
38
39
|
node._index = i;
|
|
39
40
|
node._id = this.nodeId(node) || `${i}`;
|
|
40
41
|
this._inputNodesMap.set(node, inputData.nodes[i]);
|
|
41
|
-
this.
|
|
42
|
+
this._nodesMap.set(node._id, node);
|
|
42
43
|
});
|
|
43
44
|
// Sort nodes
|
|
44
45
|
if (isFunction(this.nodeSort))
|
|
@@ -94,7 +95,7 @@ class GraphDataModel extends CoreDataModel {
|
|
|
94
95
|
else if (isObject(nodeIdentifier))
|
|
95
96
|
foundNode = nodes.find(node => isEqual(this._inputNodesMap.get(node), nodeIdentifier));
|
|
96
97
|
if (!foundNode) {
|
|
97
|
-
console.warn(`Node ${nodeIdentifier} is missing from the nodes list`);
|
|
98
|
+
console.warn(`Unovis | Graph Data Model: Node ${nodeIdentifier} is missing from the nodes list`);
|
|
98
99
|
}
|
|
99
100
|
return foundNode;
|
|
100
101
|
}
|
|
@@ -107,6 +108,14 @@ class GraphDataModel extends CoreDataModel {
|
|
|
107
108
|
item._state = {};
|
|
108
109
|
}
|
|
109
110
|
}
|
|
111
|
+
setNodeStateById(id, state) {
|
|
112
|
+
const node = this.getNodeById(id);
|
|
113
|
+
if (!node) {
|
|
114
|
+
console.warn(`Unovis | Graph Data Model: Node ${id} not found`);
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
node._state = state;
|
|
118
|
+
}
|
|
110
119
|
}
|
|
111
120
|
|
|
112
121
|
export { GraphDataModel };
|
package/data-models/graph.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"graph.js","sources":["../../src/data-models/graph.ts"],"sourcesContent":["import { isNumber, isUndefined, cloneDeep, isFunction, without, isString, isObject, isEqual } from 'utils/data'\n\n// Types\nimport { GraphInputLink, GraphInputNode, GraphLinkCore, GraphNodeCore } from 'types/graph'\n\n// Core Data Model\nimport { CoreDataModel } from './core'\n\nexport type GraphData<N extends GraphInputNode, L extends GraphInputLink> = {\n nodes: N[];\n links?: L[];\n}\n\nexport class GraphDataModel<\n N extends GraphInputNode,\n L extends GraphInputLink,\n OutNode extends GraphNodeCore<N, L> = GraphNodeCore<N, L>,\n OutLink extends GraphLinkCore<N, L> = GraphLinkCore<N, L>,\n> extends CoreDataModel<GraphData<N, L>> {\n private _nonConnectedNodes: OutNode[]\n private _connectedNodes: OutNode[]\n private _nodes: OutNode[] = []\n private _links: OutLink[] = []\n private _inputNodesMap = new Map<OutNode, N>()\n private _nodeIds = new Map<string | number, OutNode>()\n\n // Model configuration\n public nodeId: ((n: N) => string | undefined) = n => (isString(n.id) || isFinite(n.id as number)) ? `${n.id}` : undefined\n public linkId: ((n: L) => string | undefined) = l => (isString(l.id) || isFinite(l.id as number)) ? `${l.id}` : undefined\n public nodeSort: ((a: N, b: N) => number)\n\n public getNodeFromId (id: string | number): OutNode {\n return this._nodeIds.get(id)\n }\n\n get data (): GraphData<N, L> {\n return this._data\n }\n\n set data (inputData: GraphData<N, L>) {\n if (!inputData) return\n this._data = inputData\n const prevNodes = this.nodes\n const prevLinks = this.links\n\n this._inputNodesMap.clear()\n this._nodeIds.clear()\n const nodes = cloneDeep(inputData?.nodes ?? []) as OutNode[]\n const links = cloneDeep(inputData?.links ?? []) as OutLink[]\n\n // Every node or link can have a private state used for rendering needs\n // On data update we transfer state between objects with same ids\n this.transferState(nodes, prevNodes, this.nodeId)\n this.transferState(links, prevLinks, this.linkId)\n\n // Set node `_id` and `_index`\n nodes.forEach((node, i) => {\n node._index = i\n node._id = this.nodeId(node) || `${i}`\n this._inputNodesMap.set(node, inputData.nodes[i])\n this._nodeIds.set(node._id, node)\n })\n\n // Sort nodes\n if (isFunction(this.nodeSort)) nodes.sort(this.nodeSort)\n\n // Fill link source and target\n links.forEach((link, i) => {\n link._indexGlobal = i\n link.source = this.findNode(nodes, link.source)\n link.target = this.findNode(nodes, link.target)\n })\n\n // Set link index for multiple link rendering\n links.forEach((link, i) => {\n if (!isUndefined(link._index) && !isUndefined(link._neighbours)) return\n\n const linksFiltered = links.filter(l =>\n ((link.source === l.source) && (link.target === l.target)) ||\n ((link.source === l.target) && (link.target === l.source))\n )\n\n linksFiltered.forEach((l, i) => {\n l._index = i\n l._id = this.linkId(l) || `${l.source?._id}-${l.target?._id}-${i}`\n l._neighbours = linksFiltered.length\n l._direction = ((link.source === l.source) && (link.target === l.target)) ? 1 : -1\n })\n })\n\n nodes.forEach(d => {\n // Determine if a node is connected or not and store it as a property\n d.links = links.filter(l => (l.source === d) || (l.target === d))\n d._isConnected = d.links.length !== 0\n })\n\n this._nonConnectedNodes = nodes.filter(d => !d._isConnected)\n this._connectedNodes = without(nodes, ...this._nonConnectedNodes)\n\n this._nodes = nodes\n this._links = links.filter(l => l.source && l.target)\n }\n\n get nodes (): OutNode[] {\n return this._nodes\n }\n\n get links (): OutLink[] {\n return this._links\n }\n\n get connectedNodes (): OutNode[] {\n return this._connectedNodes\n }\n\n get nonConnectedNodes (): OutNode[] {\n return this._nonConnectedNodes\n }\n\n private findNode (nodes: OutNode[], nodeIdentifier: number | string | N): OutNode | undefined {\n let foundNode: OutNode | undefined\n\n if (isNumber(nodeIdentifier)) foundNode = nodes[nodeIdentifier as number]\n else if (isString(nodeIdentifier)) foundNode = nodes.find(node => this.nodeId(node) === nodeIdentifier)\n else if (isObject(nodeIdentifier)) foundNode = nodes.find(node => isEqual(this._inputNodesMap.get(node), nodeIdentifier))\n\n if (!foundNode) {\n console.warn(`Node ${nodeIdentifier} is missing from the nodes list`)\n }\n\n return foundNode\n }\n\n private transferState<T extends { _state: Record<string, any>}> (\n items: T[],\n itemsPrev: T[],\n getId: (d: T) => string\n ): void {\n for (const item of items) {\n const dPrev = itemsPrev.find((dp) => getId(dp) === getId(item))\n if (dPrev) item._state = { ...dPrev._state }\n else item._state = {}\n }\n }\n}\n"],"names":[],"mappings":";;;AAaM,MAAO,cAKX,SAAQ,aAA8B,CAAA;AALxC,IAAA,WAAA,GAAA;;QAQU,IAAM,CAAA,MAAA,GAAc,EAAE,CAAA;QACtB,IAAM,CAAA,MAAA,GAAc,EAAE,CAAA;AACtB,QAAA,IAAA,CAAA,cAAc,GAAG,IAAI,GAAG,EAAc,CAAA;AACtC,QAAA,IAAA,CAAA,QAAQ,GAAG,IAAI,GAAG,EAA4B,CAAA;;AAG/C,QAAA,IAAA,CAAA,MAAM,GAAmC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,EAAY,CAAC,IAAI,CAAG,EAAA,CAAC,CAAC,EAAE,CAAE,CAAA,GAAG,SAAS,CAAA;AAClH,QAAA,IAAA,CAAA,MAAM,GAAmC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,EAAY,CAAC,IAAI,CAAG,EAAA,CAAC,CAAC,EAAE,CAAE,CAAA,GAAG,SAAS,CAAA;KAoH1H;AAjHQ,IAAA,aAAa,CAAE,EAAmB,EAAA;QACvC,OAAO,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAA;KAC7B;AAED,IAAA,IAAI,IAAI,GAAA;QACN,OAAO,IAAI,CAAC,KAAK,CAAA;KAClB;IAED,IAAI,IAAI,CAAE,SAA0B,EAAA;;AAClC,QAAA,IAAI,CAAC,SAAS;YAAE,OAAM;AACtB,QAAA,IAAI,CAAC,KAAK,GAAG,SAAS,CAAA;AACtB,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,gBAAA,IAAI,CAAC,MAAM,GAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAQ,KAAK,CAAC,MAAM,CAAE,CAAA;;AACvC,gBAAA,IAAI,CAAC,MAAM,GAAG,EAAE,CAAA;AACtB,SAAA;KACF;AACF;;;;"}
|
|
1
|
+
{"version":3,"file":"graph.js","sources":["../../src/data-models/graph.ts"],"sourcesContent":["import { isNumber, isUndefined, cloneDeep, isFunction, without, isString, isObject, isEqual } from 'utils/data'\n\n// Types\nimport { GraphInputLink, GraphInputNode, GraphLinkCore, GraphNodeCore } from 'types/graph'\n\n// Core Data Model\nimport { CoreDataModel } from './core'\n\nexport type GraphData<N extends GraphInputNode, L extends GraphInputLink> = {\n nodes: N[];\n links?: L[];\n}\n\nexport class GraphDataModel<\n N extends GraphInputNode,\n L extends GraphInputLink,\n OutNode extends GraphNodeCore<N, L> = GraphNodeCore<N, L>,\n OutLink extends GraphLinkCore<N, L> = GraphLinkCore<N, L>,\n> extends CoreDataModel<GraphData<N, L>> {\n private _nonConnectedNodes: OutNode[]\n private _connectedNodes: OutNode[]\n private _nodes: OutNode[] = []\n private _links: OutLink[] = []\n private _inputNodesMap = new Map<OutNode, N>()\n private _nodesMap = new Map<string | number, OutNode>()\n\n // Model configuration\n public nodeId: ((n: N) => string | undefined) = n => (isString(n.id) || isFinite(n.id as number)) ? `${n.id}` : undefined\n public linkId: ((n: L) => string | undefined) = l => (isString(l.id) || isFinite(l.id as number)) ? `${l.id}` : undefined\n public nodeSort: ((a: N, b: N) => number)\n\n public getNodeById (id: string | number): OutNode {\n return this._nodesMap.get(id)\n }\n\n get data (): GraphData<N, L> {\n return this._data\n }\n\n set data (inputData: GraphData<N, L>) {\n if (!inputData) return\n this._data = inputData\n const prevNodes = this.nodes\n const prevLinks = this.links\n\n this._inputNodesMap.clear()\n this._nodesMap.clear()\n\n // Todo: Figure out why TypeScript complains about types\n const nodes = cloneDeep(inputData?.nodes ?? []) as undefined as OutNode[]\n const links = cloneDeep(inputData?.links ?? []) as undefined as OutLink[]\n\n // Every node or link can have a private state used for rendering needs\n // On data update we transfer state between objects with same ids\n this.transferState(nodes, prevNodes, this.nodeId)\n this.transferState(links, prevLinks, this.linkId)\n\n // Set node `_id` and `_index`\n nodes.forEach((node, i) => {\n node._index = i\n node._id = this.nodeId(node) || `${i}`\n this._inputNodesMap.set(node, inputData.nodes[i])\n this._nodesMap.set(node._id, node)\n })\n\n // Sort nodes\n if (isFunction(this.nodeSort)) nodes.sort(this.nodeSort)\n\n // Fill link source and target\n links.forEach((link, i) => {\n link._indexGlobal = i\n link.source = this.findNode(nodes, link.source)\n link.target = this.findNode(nodes, link.target)\n })\n\n // Set link index for multiple link rendering\n links.forEach((link, i) => {\n if (!isUndefined(link._index) && !isUndefined(link._neighbours)) return\n\n const linksFiltered = links.filter(l =>\n ((link.source === l.source) && (link.target === l.target)) ||\n ((link.source === l.target) && (link.target === l.source))\n )\n\n linksFiltered.forEach((l, i) => {\n l._index = i\n l._id = this.linkId(l) || `${l.source?._id}-${l.target?._id}-${i}`\n l._neighbours = linksFiltered.length\n l._direction = ((link.source === l.source) && (link.target === l.target)) ? 1 : -1\n })\n })\n\n nodes.forEach(d => {\n // Determine if a node is connected or not and store it as a property\n d.links = links.filter(l => (l.source === d) || (l.target === d))\n d._isConnected = d.links.length !== 0\n })\n\n this._nonConnectedNodes = nodes.filter(d => !d._isConnected)\n this._connectedNodes = without(nodes, ...this._nonConnectedNodes)\n\n this._nodes = nodes\n this._links = links.filter(l => l.source && l.target)\n }\n\n get nodes (): OutNode[] {\n return this._nodes\n }\n\n get links (): OutLink[] {\n return this._links\n }\n\n get connectedNodes (): OutNode[] {\n return this._connectedNodes\n }\n\n get nonConnectedNodes (): OutNode[] {\n return this._nonConnectedNodes\n }\n\n private findNode (nodes: OutNode[], nodeIdentifier: number | string | N): OutNode | undefined {\n let foundNode: OutNode | undefined\n\n if (isNumber(nodeIdentifier)) foundNode = nodes[nodeIdentifier as number]\n else if (isString(nodeIdentifier)) foundNode = nodes.find(node => this.nodeId(node) === nodeIdentifier)\n else if (isObject(nodeIdentifier)) foundNode = nodes.find(node => isEqual(this._inputNodesMap.get(node), nodeIdentifier))\n\n if (!foundNode) {\n console.warn(`Unovis | Graph Data Model: Node ${nodeIdentifier} is missing from the nodes list`)\n }\n\n return foundNode\n }\n\n private transferState<T extends { _state: Record<string, any>}> (\n items: T[],\n itemsPrev: T[],\n getId: (d: T) => string\n ): void {\n for (const item of items) {\n const dPrev = itemsPrev.find((dp) => getId(dp) === getId(item))\n if (dPrev) item._state = { ...dPrev._state }\n else item._state = {}\n }\n }\n\n public setNodeStateById (id: string, state: Record<string, any>): void {\n const node = this.getNodeById(id)\n if (!node) {\n console.warn(`Unovis | Graph Data Model: Node ${id} not found`)\n return\n }\n\n node._state = state\n }\n}\n"],"names":[],"mappings":";;;AAaM,MAAO,cAKX,SAAQ,aAA8B,CAAA;AALxC,IAAA,WAAA,GAAA;;QAQU,IAAM,CAAA,MAAA,GAAc,EAAE,CAAA;QACtB,IAAM,CAAA,MAAA,GAAc,EAAE,CAAA;AACtB,QAAA,IAAA,CAAA,cAAc,GAAG,IAAI,GAAG,EAAc,CAAA;AACtC,QAAA,IAAA,CAAA,SAAS,GAAG,IAAI,GAAG,EAA4B,CAAA;;AAGhD,QAAA,IAAA,CAAA,MAAM,GAAmC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,EAAY,CAAC,IAAI,CAAG,EAAA,CAAC,CAAC,EAAE,CAAE,CAAA,GAAG,SAAS,CAAA;AAClH,QAAA,IAAA,CAAA,MAAM,GAAmC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,QAAQ,CAAC,CAAC,CAAC,EAAY,CAAC,IAAI,CAAG,EAAA,CAAC,CAAC,EAAE,CAAE,CAAA,GAAG,SAAS,CAAA;KAgI1H;AA7HQ,IAAA,WAAW,CAAE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AAO,SAAS,CAAA;KACjB;AAEO,IAAA,aAAa,CACnB,KAAU,EACV,SAAc,EACd,KAAuB,EAAA;AAEvB,QAAA,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE;YACxB,MAAM,KAAK,GAAG,SAAS,CAAC,IAAI,CAAC,CAAC,EAAE,KAAK,KAAK,CAAC,EAAE,CAAC,KAAK,KAAK,CAAC,IAAI,CAAC,CAAC,CAAA;AAC/D,YAAA,IAAI,KAAK;AAAE,gBAAA,IAAI,CAAC,MAAM,GAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAQ,KAAK,CAAC,MAAM,CAAE,CAAA;;AACvC,gBAAA,IAAI,CAAC,MAAM,GAAG,EAAE,CAAA;AACtB,SAAA;KACF;IAEM,gBAAgB,CAAE,EAAU,EAAE,KAA0B,EAAA;QAC7D,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,EAAE,CAAC,CAAA;QACjC,IAAI,CAAC,IAAI,EAAE;AACT,YAAA,OAAO,CAAC,IAAI,CAAC,mCAAmC,EAAE,CAAA,UAAA,CAAY,CAAC,CAAA;YAC/D,OAAM;AACP,SAAA;AAED,QAAA,IAAI,CAAC,MAAM,GAAG,KAAK,CAAA;KACpB;AACF;;;;"}
|
package/index.js
CHANGED
|
@@ -34,6 +34,7 @@ export { FreeBrush } from './components/free-brush/index.js';
|
|
|
34
34
|
export { XYLabels } from './components/xy-labels/index.js';
|
|
35
35
|
export { NestedDonut } from './components/nested-donut/index.js';
|
|
36
36
|
export { Annotations } from './components/annotations/index.js';
|
|
37
|
+
export { Treemap } from './components/treemap/index.js';
|
|
37
38
|
export { DONUT_HALF_ANGLE_RANGES, DONUT_HALF_ANGLE_RANGE_BOTTOM, DONUT_HALF_ANGLE_RANGE_LEFT, DONUT_HALF_ANGLE_RANGE_RIGHT, DONUT_HALF_ANGLE_RANGE_TOP } from './components/donut/constants.js';
|
|
38
39
|
export { Curve, CurveType } from './types/curve.js';
|
|
39
40
|
export { Symbol, SymbolType } from './types/symbol.js';
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unovis/ts",
|
|
3
3
|
"description": "Modular data visualization framework for React, Angular, Svelte, Vue, Solid, and vanilla TypeScript or JavaScript",
|
|
4
|
-
"version": "1.5.1-exf.
|
|
4
|
+
"version": "1.5.1-exf.4",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/f5/unovis.git",
|
package/types.d.ts
CHANGED
package/types.js
CHANGED
|
@@ -26,6 +26,7 @@ export { BulletLegendOrientation, BulletShape } from './components/bullet-legend
|
|
|
26
26
|
export { XYLabelPositioning } from './components/xy-labels/types.js';
|
|
27
27
|
export { NestedDonutDirection, NestedDonutSegmentLabelAlignment } from './components/nested-donut/types.js';
|
|
28
28
|
import './components/annotations/types.js';
|
|
29
|
+
import './components/treemap/types.js';
|
|
29
30
|
|
|
30
31
|
/* eslint-disable max-len */
|
|
31
32
|
//# sourceMappingURL=types.js.map
|
package/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sources":["../src/types.ts"],"sourcesContent":["/* eslint-disable max-len */\n// Global Types\nexport * from 'types/accessor'\nexport * from 'types/curve'\nexport * from 'types/symbol'\nexport * from 'types/scale'\nexport * from 'types/position'\nexport * from 'types/shape'\nexport * from 'types/component'\nexport * from 'types/text'\nexport * from 'types/map'\nexport * from 'types/spacing'\nexport * from 'types/graph'\nexport * from 'types/data'\nexport * from 'types/direction'\n\n// Component Types\nexport * from 'core/component/types'\nexport * from 'components/crosshair/types'\nexport * from 'components/axis/types'\nexport * from 'components/chord-diagram/types'\nexport * from 'components/topojson-map/types'\nexport * from 'components/leaflet-map/types'\nexport * from 'components/leaflet-map/renderer/map-style'\nexport * from 'components/graph/types'\nexport * from 'components/sankey/types'\nexport * from 'components/vis-controls/types'\nexport * from 'components/free-brush/types'\nexport * from 'components/bullet-legend/types'\nexport * from 'components/xy-labels/types'\nexport * from 'components/nested-donut/types'\nexport * from 'components/annotations/types'\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../src/types.ts"],"sourcesContent":["/* eslint-disable max-len */\n// Global Types\nexport * from 'types/accessor'\nexport * from 'types/curve'\nexport * from 'types/symbol'\nexport * from 'types/scale'\nexport * from 'types/position'\nexport * from 'types/shape'\nexport * from 'types/component'\nexport * from 'types/text'\nexport * from 'types/map'\nexport * from 'types/spacing'\nexport * from 'types/graph'\nexport * from 'types/data'\nexport * from 'types/direction'\n\n// Component Types\nexport * from 'core/component/types'\nexport * from 'components/crosshair/types'\nexport * from 'components/axis/types'\nexport * from 'components/chord-diagram/types'\nexport * from 'components/topojson-map/types'\nexport * from 'components/leaflet-map/types'\nexport * from 'components/leaflet-map/renderer/map-style'\nexport * from 'components/graph/types'\nexport * from 'components/sankey/types'\nexport * from 'components/vis-controls/types'\nexport * from 'components/free-brush/types'\nexport * from 'components/bullet-legend/types'\nexport * from 'components/xy-labels/types'\nexport * from 'components/nested-donut/types'\nexport * from 'components/annotations/types'\nexport * from 'components/treemap/types'\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA"}
|