@unovis/ts 1.4.0-beta.6 → 1.4.0
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/annotations/index.d.ts +4 -2
- package/components/annotations/index.js +30 -37
- package/components/annotations/index.js.map +1 -1
- package/components/annotations/style.d.ts +4 -1
- package/components/annotations/style.js +8 -4
- package/components/annotations/style.js.map +1 -1
- package/components/annotations/types.d.ts +2 -13
- package/components/annotations/types.js +0 -6
- package/components/annotations/types.js.map +1 -1
- package/components/area/index.js +2 -0
- package/components/area/index.js.map +1 -1
- package/components/chord-diagram/modules/label.js +1 -0
- package/components/chord-diagram/modules/label.js.map +1 -1
- package/components/chord-diagram/modules/link.js +1 -1
- package/components/chord-diagram/modules/link.js.map +1 -1
- package/components/crosshair/config.d.ts +4 -0
- package/components/crosshair/config.js +1 -1
- package/components/crosshair/config.js.map +1 -1
- package/components/crosshair/index.js +12 -4
- package/components/crosshair/index.js.map +1 -1
- package/components/crosshair/style.js +4 -2
- package/components/crosshair/style.js.map +1 -1
- package/components/crosshair/types.d.ts +2 -0
- package/components/graph/config.d.ts +22 -15
- package/components/graph/config.js +4 -2
- package/components/graph/config.js.map +1 -1
- package/components/graph/index.d.ts +7 -2
- package/components/graph/index.js +114 -110
- package/components/graph/index.js.map +1 -1
- package/components/graph/modules/layout.js +30 -19
- package/components/graph/modules/layout.js.map +1 -1
- package/components/graph/modules/link/helper.d.ts +4 -6
- package/components/graph/modules/link/helper.js +15 -25
- package/components/graph/modules/link/helper.js.map +1 -1
- package/components/graph/modules/link/index.d.ts +3 -3
- package/components/graph/modules/link/index.js +111 -89
- package/components/graph/modules/link/index.js.map +1 -1
- package/components/graph/modules/link/style.d.ts +5 -5
- package/components/graph/modules/link/style.js +26 -22
- package/components/graph/modules/link/style.js.map +1 -1
- package/components/graph/modules/node/helper.d.ts +1 -0
- package/components/graph/modules/node/helper.js +4 -1
- package/components/graph/modules/node/helper.js.map +1 -1
- package/components/graph/modules/node/index.js +28 -11
- package/components/graph/modules/node/index.js.map +1 -1
- package/components/graph/modules/node/style.d.ts +1 -1
- package/components/graph/modules/node/style.js +13 -6
- package/components/graph/modules/node/style.js.map +1 -1
- package/components/graph/modules/shape.d.ts +0 -2
- package/components/graph/modules/shape.js +7 -9
- package/components/graph/modules/shape.js.map +1 -1
- package/components/graph/types.d.ts +63 -5
- package/components/graph/types.js +1 -0
- package/components/graph/types.js.map +1 -1
- package/components/sankey/modules/node.js +1 -1
- package/components/sankey/modules/node.js.map +1 -1
- package/components/tooltip/config.d.ts +1 -1
- package/components/tooltip/config.js.map +1 -1
- package/components/tooltip/index.js +3 -1
- package/components/tooltip/index.js.map +1 -1
- package/components/xy-labels/index.js +1 -1
- package/components/xy-labels/index.js.map +1 -1
- package/containers/single-container/config.js +1 -1
- package/containers/single-container/config.js.map +1 -1
- package/containers/xy-container/config.js +1 -1
- package/containers/xy-container/config.js.map +1 -1
- package/containers/xy-container/index.js.map +1 -1
- package/core/component/index.d.ts +3 -3
- package/core/component/index.js +1 -1
- package/core/component/index.js.map +1 -1
- package/index.js +0 -1
- package/index.js.map +1 -1
- package/package.json +1 -1
- package/types.js +1 -1
- package/utils/data.js +1 -1
- package/utils/data.js.map +1 -1
- package/utils/svg.d.ts +3 -0
- package/utils/svg.js +61 -0
- package/utils/svg.js.map +1 -0
- package/utils/text.js.map +1 -1
|
@@ -1,21 +1,19 @@
|
|
|
1
1
|
import { select } from 'd3-selection';
|
|
2
2
|
import { polygon } from '../../../utils/path.js';
|
|
3
3
|
import { getString } from '../../../utils/data.js';
|
|
4
|
+
import { isStringSvg, sanitizeSvgString } from '../../../utils/svg.js';
|
|
4
5
|
import { GraphNodeShape } from '../types.js';
|
|
5
6
|
import { getNodeSize } from './node/helper.js';
|
|
6
7
|
|
|
7
|
-
function isCustomXml(shape) {
|
|
8
|
-
return /<[a-z][\s\S]*>/i.test(shape);
|
|
9
|
-
}
|
|
10
8
|
function appendShape(selection, shapeAccessor, shapeSelector, customShapeSelector, index, insertSelector = ':last-child') {
|
|
11
9
|
selection.each((d, i, elements) => {
|
|
12
10
|
const element = select(elements[i]);
|
|
13
11
|
const shape = getString(d, shapeAccessor, index);
|
|
14
12
|
let shapeElement;
|
|
15
|
-
const
|
|
16
|
-
if (
|
|
13
|
+
const isCustomShape = isStringSvg(shape);
|
|
14
|
+
if (isCustomShape) {
|
|
17
15
|
shapeElement = element.insert('g', insertSelector)
|
|
18
|
-
.html(shape);
|
|
16
|
+
.html(sanitizeSvgString(shape));
|
|
19
17
|
}
|
|
20
18
|
else {
|
|
21
19
|
switch (shape) {
|
|
@@ -33,7 +31,7 @@ function appendShape(selection, shapeAccessor, shapeSelector, customShapeSelecto
|
|
|
33
31
|
shapeElement = element.insert('circle', insertSelector);
|
|
34
32
|
}
|
|
35
33
|
}
|
|
36
|
-
shapeElement.classed(customShapeSelector,
|
|
34
|
+
shapeElement.classed(customShapeSelector, isCustomShape);
|
|
37
35
|
return shapeElement.attr('class', shapeSelector);
|
|
38
36
|
});
|
|
39
37
|
}
|
|
@@ -66,7 +64,7 @@ function updateShape(selection, shape, size, index) {
|
|
|
66
64
|
return polygon(nodeSize, n);
|
|
67
65
|
});
|
|
68
66
|
selection.filter('g')
|
|
69
|
-
.filter(() => !
|
|
67
|
+
.filter(() => !isStringSvg(getString(d, shape, index)))
|
|
70
68
|
.html(getString(d, shape, index));
|
|
71
69
|
selection.filter('g')
|
|
72
70
|
.each((d, i, elements) => {
|
|
@@ -76,5 +74,5 @@ function updateShape(selection, shape, size, index) {
|
|
|
76
74
|
});
|
|
77
75
|
}
|
|
78
76
|
|
|
79
|
-
export { appendShape,
|
|
77
|
+
export { appendShape, updateShape };
|
|
80
78
|
//# sourceMappingURL=shape.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shape.js","sources":["../../../../src/components/graph/modules/shape.ts"],"sourcesContent":["import { Selection, select } from 'd3-selection'\n\n// Types\nimport { NumericAccessor, StringAccessor } from 'types/accessor'\n\n// Utils\nimport { polygon } from 'utils/path'\nimport { getString } from 'utils/data'\n\n// Types\n\n// Local Types\nimport { GraphNodeShape } from '../types'\n\n// Helpers\nimport { getNodeSize } from './node/helper'\n\nexport function
|
|
1
|
+
{"version":3,"file":"shape.js","sources":["../../../../src/components/graph/modules/shape.ts"],"sourcesContent":["import { Selection, select } from 'd3-selection'\n\n// Types\nimport { NumericAccessor, StringAccessor } from 'types/accessor'\n\n// Utils\nimport { polygon } from 'utils/path'\nimport { getString } from 'utils/data'\nimport { isStringSvg, sanitizeSvgString } from 'utils/svg'\n\n// Types\n\n// Local Types\nimport { GraphNodeShape } from '../types'\n\n// Helpers\nimport { getNodeSize } from './node/helper'\n\nexport function appendShape<T> (\n selection: Selection<SVGGElement, T, SVGGElement, unknown>,\n shapeAccessor: StringAccessor<T>,\n shapeSelector: string,\n customShapeSelector: string,\n index?: number,\n insertSelector = ':last-child'\n): void {\n selection.each((d, i, elements) => {\n const element = select(elements[i])\n const shape = getString(d, shapeAccessor, index) as GraphNodeShape\n\n let shapeElement: Selection<SVGPathElement, unknown, null, undefined>\n | Selection<SVGRectElement, unknown, null, undefined>\n | Selection<SVGGElement, unknown, null, undefined>\n | Selection<SVGCircleElement, unknown, null, undefined>\n const isCustomShape = isStringSvg(shape)\n if (isCustomShape) {\n shapeElement = element.insert('g', insertSelector)\n .html(sanitizeSvgString(shape))\n } else {\n switch (shape) {\n case GraphNodeShape.Square:\n shapeElement = element.insert('rect', insertSelector)\n .attr('rx', 5)\n .attr('ry', 5)\n break\n case GraphNodeShape.Hexagon:\n case GraphNodeShape.Triangle:\n shapeElement = element.insert('path', insertSelector)\n break\n case GraphNodeShape.Circle:\n default:\n shapeElement = element.insert('circle', insertSelector)\n }\n }\n\n shapeElement.classed(customShapeSelector, isCustomShape)\n return shapeElement.attr('class', shapeSelector)\n })\n}\n\nexport function updateShape<T> (\n selection: Selection<SVGGElement, T, SVGGElement, unknown>,\n shape: StringAccessor<T>,\n size: NumericAccessor<T>,\n index: number\n): void {\n if (selection.size() === 0) return\n\n const d: T = selection.datum()\n const nodeSize = getNodeSize(d, size, index)\n selection.filter('circle')\n .attr('r', nodeSize / 2)\n\n selection.filter('rect')\n .attr('width', nodeSize)\n .attr('height', nodeSize)\n .attr('x', -nodeSize / 2)\n .attr('y', -nodeSize / 2)\n\n selection.filter('path')\n .attr('d', () => {\n let n: number\n switch (getString(d, shape, index)) {\n case GraphNodeShape.Square:\n n = 4\n break\n case GraphNodeShape.Triangle:\n n = 3\n break\n case GraphNodeShape.Hexagon:\n default:\n n = 6\n }\n\n return polygon(nodeSize, n)\n })\n\n selection.filter('g')\n .filter(() => !isStringSvg(getString(d, shape, index) as GraphNodeShape))\n .html(getString(d, shape, index))\n\n selection.filter('g')\n .each((d, i, elements) => {\n const el = select(elements[i])\n const bBox = el.node().getBBox()\n el.attr('transform', `translate(${-bBox.width / 2},${-bBox.height / 2})`)\n })\n}\n"],"names":[],"mappings":";;;;;;;AAkBgB,SAAA,WAAW,CACzB,SAA0D,EAC1D,aAAgC,EAChC,aAAqB,EACrB,mBAA2B,EAC3B,KAAc,EACd,cAAc,GAAG,aAAa,EAAA;IAE9B,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,QAAQ,KAAI;QAChC,MAAM,OAAO,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAA;QACnC,MAAM,KAAK,GAAG,SAAS,CAAC,CAAC,EAAE,aAAa,EAAE,KAAK,CAAmB,CAAA;AAElE,QAAA,IAAI,YAGmD,CAAA;AACvD,QAAA,MAAM,aAAa,GAAG,WAAW,CAAC,KAAK,CAAC,CAAA;AACxC,QAAA,IAAI,aAAa,EAAE;YACjB,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,GAAG,EAAE,cAAc,CAAC;AAC/C,iBAAA,IAAI,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAA;AAClC,SAAA;AAAM,aAAA;AACL,YA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AC,KAAK,GAAG,CAAC,CAAA,CAAA,EAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAG,CAAA,CAAA,CAAC,CAAA;AAC3E,KAAC,CAAC,CAAA;AACN;;;;"}
|
|
@@ -16,6 +16,10 @@ export declare type GraphNode<N extends GraphInputNode = GraphInputNode, L exten
|
|
|
16
16
|
_panels?: GraphPanel<N, L>[];
|
|
17
17
|
_isConnected?: boolean;
|
|
18
18
|
};
|
|
19
|
+
export declare type GraphForceSimulationNode<N extends GraphInputNode = GraphInputNode, L extends GraphInputLink = GraphInputLink> = GraphNode<N, L> & {
|
|
20
|
+
fx?: number;
|
|
21
|
+
fy?: number;
|
|
22
|
+
};
|
|
19
23
|
export declare type GraphLink<N extends GraphInputNode = GraphInputNode, L extends GraphInputLink = GraphInputLink> = GraphLinkCore<N, L> & {
|
|
20
24
|
id?: number | string;
|
|
21
25
|
source: number | string | GraphNode<N>;
|
|
@@ -38,7 +42,8 @@ export declare enum GraphLayoutType {
|
|
|
38
42
|
ParallelHorizontal = "parallel horizontal",
|
|
39
43
|
Dagre = "dagre",
|
|
40
44
|
Force = "force",
|
|
41
|
-
Elk = "elk"
|
|
45
|
+
Elk = "elk",
|
|
46
|
+
Precalculated = "precalculated"
|
|
42
47
|
}
|
|
43
48
|
export declare type GraphCircleLabel = {
|
|
44
49
|
text: string;
|
|
@@ -48,6 +53,7 @@ export declare type GraphCircleLabel = {
|
|
|
48
53
|
fontSize?: string | null;
|
|
49
54
|
radius?: number;
|
|
50
55
|
};
|
|
56
|
+
export declare type GraphLinkLabel = GraphCircleLabel;
|
|
51
57
|
export declare enum GraphLinkStyle {
|
|
52
58
|
Dashed = "dashed",
|
|
53
59
|
Solid = "solid"
|
|
@@ -110,16 +116,68 @@ export declare type GraphNodeAnimationState = {
|
|
|
110
116
|
export declare type GraphNodeAnimatedElement<T = SVGElement> = T & {
|
|
111
117
|
_animState: GraphNodeAnimationState;
|
|
112
118
|
};
|
|
113
|
-
export declare type GraphForceLayoutSettings = {
|
|
119
|
+
export declare type GraphForceLayoutSettings<N extends GraphInputNode = GraphInputNode, L extends GraphInputLink = GraphInputLink> = {
|
|
114
120
|
/** Preferred Link Distance. Default: `60` */
|
|
115
|
-
linkDistance?: number;
|
|
121
|
+
linkDistance?: number | ((l: GraphLink<N, L>, i: number) => number);
|
|
116
122
|
/** Link Strength [0:1]. Default: `0.45` */
|
|
117
|
-
linkStrength?: number;
|
|
123
|
+
linkStrength?: number | ((l: GraphLink<N, L>, i: number) => number);
|
|
118
124
|
/** Charge Force (<0 repulsion, >0 attraction). Default: `-500` */
|
|
119
|
-
charge?: number;
|
|
125
|
+
charge?: number | ((l: GraphNode<N, L>, i: number) => number);
|
|
120
126
|
/** X-centring force. Default: `0.15` */
|
|
121
127
|
forceXStrength?: number;
|
|
122
128
|
/** Y-centring force. Default: `0.25` */
|
|
123
129
|
forceYStrength?: number;
|
|
130
|
+
/** Number if simulation iterations. Default: automatic */
|
|
131
|
+
numIterations?: number;
|
|
132
|
+
/** Set to true if you want to fix the node positions after the simulation
|
|
133
|
+
* Helpful when you want to update graph settings without re-calculating the layout.
|
|
134
|
+
* Default: `false` */
|
|
135
|
+
fixNodePositionAfterSimulation?: boolean;
|
|
124
136
|
};
|
|
125
137
|
export declare type GraphElkLayoutSettings = Record<string, string>;
|
|
138
|
+
/**
|
|
139
|
+
* Settings for configuring the layout of a Dagre graph.
|
|
140
|
+
*/
|
|
141
|
+
export declare type GraphDagreLayoutSetting = {
|
|
142
|
+
/**
|
|
143
|
+
* Direction for rank nodes. Can be TB, BT, LR, or RL, where T = top, B = bottom, L = left, and R = right.
|
|
144
|
+
* Additional custom values can also be provided as a string.
|
|
145
|
+
*/
|
|
146
|
+
rankdir?: 'TB' | 'BT' | 'LR' | 'RL' | string;
|
|
147
|
+
/**
|
|
148
|
+
* Alignment for rank nodes. Can be UL, UR, DL, or DR, where U = up, D = down, L = left, and R = right.
|
|
149
|
+
* Additional custom values can also be provided as a string.
|
|
150
|
+
*/
|
|
151
|
+
align?: 'UL' | 'UR' | 'DL' | 'DR' | string;
|
|
152
|
+
/**
|
|
153
|
+
* Number of pixels that separate nodes horizontally in the layout.
|
|
154
|
+
*/
|
|
155
|
+
nodesep?: number;
|
|
156
|
+
/**
|
|
157
|
+
* Number of pixels that separate edges horizontally in the layout.
|
|
158
|
+
*/
|
|
159
|
+
edgesep?: number;
|
|
160
|
+
/**
|
|
161
|
+
* Number of pixels between each rank in the layout.
|
|
162
|
+
*/
|
|
163
|
+
ranksep?: number;
|
|
164
|
+
/**
|
|
165
|
+
* Number of pixels to use as a margin around the left and right of the graph.
|
|
166
|
+
*/
|
|
167
|
+
marginx?: number;
|
|
168
|
+
/**
|
|
169
|
+
* Number of pixels to use as a margin around the top and bottom of the graph.
|
|
170
|
+
*/
|
|
171
|
+
marginy?: number;
|
|
172
|
+
/**
|
|
173
|
+
* If set to 'greedy', uses a greedy heuristic for finding a feedback arc set for a graph.
|
|
174
|
+
* A feedback arc set is a set of edges that can be removed to make a graph acyclic.
|
|
175
|
+
*/
|
|
176
|
+
acyclicer?: 'greedy' | undefined;
|
|
177
|
+
/**
|
|
178
|
+
* Type of algorithm to assign a rank to each node in the input graph.
|
|
179
|
+
* Possible values are 'network-simplex', 'tight-tree', or 'longest-path'.
|
|
180
|
+
* Additional custom values can also be provided as a string.
|
|
181
|
+
*/
|
|
182
|
+
ranker?: 'network-simplex' | 'tight-tree' | 'longest-path' | string;
|
|
183
|
+
};
|
|
@@ -7,6 +7,7 @@ var GraphLayoutType;
|
|
|
7
7
|
GraphLayoutType["Dagre"] = "dagre";
|
|
8
8
|
GraphLayoutType["Force"] = "force";
|
|
9
9
|
GraphLayoutType["Elk"] = "elk";
|
|
10
|
+
GraphLayoutType["Precalculated"] = "precalculated";
|
|
10
11
|
})(GraphLayoutType || (GraphLayoutType = {}));
|
|
11
12
|
var GraphLinkStyle;
|
|
12
13
|
(function (GraphLinkStyle) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sources":["../../../src/components/graph/types.ts"],"sourcesContent":["// Types\nimport { Position } from 'types/position'\nimport { GraphInputLink, GraphInputNode, GraphNodeCore, GraphLinkCore } from 'types/graph'\nimport { Spacing } from 'types/spacing'\n\nexport type GraphNode<\n N extends GraphInputNode = GraphInputNode,\n L extends GraphInputLink = GraphInputLink,\n> = GraphNodeCore<N, L> & {\n x?: number;\n y?: number;\n\n _id?: number | string;\n _index?: number;\n _state?: {\n isDragged?: boolean;\n fx?: number;\n fy?: number;\n selected?: boolean;\n greyout?: boolean;\n };\n\n _panels?: GraphPanel<N, L>[];\n _isConnected?: boolean;\n}\n\nexport type GraphLink<\n N extends GraphInputNode = GraphInputNode,\n L extends GraphInputLink = GraphInputLink,\n> = GraphLinkCore<N, L> & {\n id?: number | string;\n source: number | string | GraphNode<N>;\n target: number | string | GraphNode<N>;\n\n _id?: number | string;\n _direction?: number;\n _index?: number;\n _neighbours?: number;\n\n _state?: {\n flowAnimTime?: number;\n hovered?: boolean;\n selected?: boolean;\n greyout?: boolean;\n };\n}\n\nexport enum GraphLayoutType {\n Circular = 'circular',\n Concentric = 'concentric',\n Parallel = 'parallel',\n ParallelHorizontal = 'parallel horizontal',\n Dagre = 'dagre',\n Force = 'force',\n Elk = 'elk',\n}\n\nexport type GraphCircleLabel = {\n text: string;\n textColor?: string | null;\n color?: string | null;\n cursor?: string | null;\n fontSize?: string | null;\n radius?: number;\n}\n\nexport enum GraphLinkStyle {\n Dashed = 'dashed',\n Solid = 'solid',\n}\n\nexport enum GraphLinkArrowStyle {\n Single = 'single',\n Double = 'double',\n}\n\nexport enum GraphNodeShape {\n Circle = 'circle',\n Square = 'square',\n Hexagon = 'hexagon',\n Triangle = 'triangle',\n}\n\nexport type GraphPanelConfig = {\n /** Panel nodes references by unique ids */\n nodes: (string|number)[];\n /** Panel label */\n label?: string;\n /** Position of the label */\n labelPosition?: Position.Top | Position.Bottom | string;\n /** Color of the panel's border */\n borderColor?: string;\n /** Border width of the panel in pixels */\n borderWidth?: number;\n /** Inner padding */\n padding?: number | Spacing;\n /** Dashed outline showing that the panel is selected */\n dashedOutline?: boolean;\n /** Side icon symbol */\n sideIconSymbol?: string;\n /** Size of the icon as a CSS string. e.g.: `12pt` or `12px` */\n sideIconFontSize?: string;\n /** Color of the icon */\n sideIconSymbolColor?: string;\n /** Shape of the icon's background */\n sideIconShape?: GraphNodeShape | string;\n /** Size of the icon's background shape */\n sideIconShapeSize?: number;\n /** Stroke color of the icon's background shape */\n sideIconShapeStroke?: string;\n /** Cursor, when hovering over the icon */\n sideIconCursor?: string;\n}\n\nexport type GraphPanel<\n N extends GraphInputNode = GraphInputNode,\n L extends GraphInputLink = GraphInputLink,\n> = GraphPanelConfig & {\n _numNodes?: number;\n _x?: number;\n _y?: number;\n _width?: number;\n _height?: number;\n _disabled?: boolean;\n _padding?: Spacing;\n}\n\nexport type GraphNodeAnimationState = {\n endAngle: number;\n nodeIndex: number;\n nodeSize?: number;\n borderWidth?: number;\n}\n\nexport type GraphNodeAnimatedElement<T = SVGElement> = T & {\n _animState: GraphNodeAnimationState;\n}\n\nexport type GraphForceLayoutSettings = {\n /** Preferred Link Distance. Default: `60` */\n linkDistance?: number;\n /** Link Strength [0:1]. Default: `0.45` */\n linkStrength?: number;\n /** Charge Force (<0 repulsion, >0 attraction). Default: `-500` */\n charge?: number;\n /** X-centring force. Default: `0.15` */\n forceXStrength?: number;\n /** Y-centring force. Default: `0.25` */\n forceYStrength?: number;\n}\n\nexport type GraphElkLayoutSettings = Record<string, string>\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sources":["../../../src/components/graph/types.ts"],"sourcesContent":["// Types\nimport { Position } from 'types/position'\nimport { GraphInputLink, GraphInputNode, GraphNodeCore, GraphLinkCore } from 'types/graph'\nimport { Spacing } from 'types/spacing'\n\nexport type GraphNode<\n N extends GraphInputNode = GraphInputNode,\n L extends GraphInputLink = GraphInputLink,\n> = GraphNodeCore<N, L> & {\n x?: number;\n y?: number;\n\n _id?: number | string;\n _index?: number;\n _state?: {\n isDragged?: boolean;\n fx?: number;\n fy?: number;\n selected?: boolean;\n greyout?: boolean;\n };\n\n _panels?: GraphPanel<N, L>[];\n _isConnected?: boolean;\n}\n\nexport type GraphForceSimulationNode<\n N extends GraphInputNode = GraphInputNode,\n L extends GraphInputLink = GraphInputLink,\n> = GraphNode<N, L> & {\n fx?: number;\n fy?: number;\n}\n\nexport type GraphLink<\n N extends GraphInputNode = GraphInputNode,\n L extends GraphInputLink = GraphInputLink,\n> = GraphLinkCore<N, L> & {\n id?: number | string;\n source: number | string | GraphNode<N>;\n target: number | string | GraphNode<N>;\n\n _id?: number | string;\n _direction?: number;\n _index?: number;\n _neighbours?: number;\n\n _state?: {\n flowAnimTime?: number;\n hovered?: boolean;\n selected?: boolean;\n greyout?: boolean;\n };\n}\n\nexport enum GraphLayoutType {\n Circular = 'circular',\n Concentric = 'concentric',\n Parallel = 'parallel',\n ParallelHorizontal = 'parallel horizontal',\n Dagre = 'dagre',\n Force = 'force',\n Elk = 'elk',\n Precalculated = 'precalculated',\n}\n\nexport type GraphCircleLabel = {\n text: string;\n textColor?: string | null;\n color?: string | null;\n cursor?: string | null;\n fontSize?: string | null;\n radius?: number;\n}\n\nexport type GraphLinkLabel = GraphCircleLabel\n\nexport enum GraphLinkStyle {\n Dashed = 'dashed',\n Solid = 'solid',\n}\n\nexport enum GraphLinkArrowStyle {\n Single = 'single',\n Double = 'double',\n}\n\nexport enum GraphNodeShape {\n Circle = 'circle',\n Square = 'square',\n Hexagon = 'hexagon',\n Triangle = 'triangle',\n}\n\nexport type GraphPanelConfig = {\n /** Panel nodes references by unique ids */\n nodes: (string|number)[];\n /** Panel label */\n label?: string;\n /** Position of the label */\n labelPosition?: Position.Top | Position.Bottom | string;\n /** Color of the panel's border */\n borderColor?: string;\n /** Border width of the panel in pixels */\n borderWidth?: number;\n /** Inner padding */\n padding?: number | Spacing;\n /** Dashed outline showing that the panel is selected */\n dashedOutline?: boolean;\n /** Side icon symbol */\n sideIconSymbol?: string;\n /** Size of the icon as a CSS string. e.g.: `12pt` or `12px` */\n sideIconFontSize?: string;\n /** Color of the icon */\n sideIconSymbolColor?: string;\n /** Shape of the icon's background */\n sideIconShape?: GraphNodeShape | string;\n /** Size of the icon's background shape */\n sideIconShapeSize?: number;\n /** Stroke color of the icon's background shape */\n sideIconShapeStroke?: string;\n /** Cursor, when hovering over the icon */\n sideIconCursor?: string;\n}\n\nexport type GraphPanel<\n N extends GraphInputNode = GraphInputNode,\n L extends GraphInputLink = GraphInputLink,\n> = GraphPanelConfig & {\n _numNodes?: number;\n _x?: number;\n _y?: number;\n _width?: number;\n _height?: number;\n _disabled?: boolean;\n _padding?: Spacing;\n}\n\nexport type GraphNodeAnimationState = {\n endAngle: number;\n nodeIndex: number;\n nodeSize?: number;\n borderWidth?: number;\n}\n\nexport type GraphNodeAnimatedElement<T = SVGElement> = T & {\n _animState: GraphNodeAnimationState;\n}\n\nexport type GraphForceLayoutSettings<\n N extends GraphInputNode = GraphInputNode,\n L extends GraphInputLink = GraphInputLink,\n> = {\n /** Preferred Link Distance. Default: `60` */\n linkDistance?: number | ((l: GraphLink<N, L>, i: number) => number);\n /** Link Strength [0:1]. Default: `0.45` */\n linkStrength?: number | ((l: GraphLink<N, L>, i: number) => number);\n /** Charge Force (<0 repulsion, >0 attraction). Default: `-500` */\n charge?: number | ((l: GraphNode<N, L>, i: number) => number);\n /** X-centring force. Default: `0.15` */\n forceXStrength?: number;\n /** Y-centring force. Default: `0.25` */\n forceYStrength?: number;\n /** Number if simulation iterations. Default: automatic */\n numIterations?: number;\n /** Set to true if you want to fix the node positions after the simulation\n * Helpful when you want to update graph settings without re-calculating the layout.\n * Default: `false` */\n fixNodePositionAfterSimulation?: boolean;\n}\n\nexport type GraphElkLayoutSettings = Record<string, string>\n\n/**\n * Settings for configuring the layout of a Dagre graph.\n */\nexport type GraphDagreLayoutSetting = {\n /**\n * Direction for rank nodes. Can be TB, BT, LR, or RL, where T = top, B = bottom, L = left, and R = right.\n * Additional custom values can also be provided as a string.\n */\n rankdir?: 'TB' | 'BT' | 'LR' | 'RL' | string;\n\n /**\n * Alignment for rank nodes. Can be UL, UR, DL, or DR, where U = up, D = down, L = left, and R = right.\n * Additional custom values can also be provided as a string.\n */\n align?: 'UL' | 'UR' | 'DL' | 'DR' | string;\n\n /**\n * Number of pixels that separate nodes horizontally in the layout.\n */\n nodesep?: number;\n\n /**\n * Number of pixels that separate edges horizontally in the layout.\n */\n edgesep?: number;\n\n /**\n * Number of pixels between each rank in the layout.\n */\n ranksep?: number;\n\n /**\n * Number of pixels to use as a margin around the left and right of the graph.\n */\n marginx?: number;\n\n /**\n * Number of pixels to use as a margin around the top and bottom of the graph.\n */\n marginy?: number;\n\n /**\n * If set to 'greedy', uses a greedy heuristic for finding a feedback arc set for a graph.\n * A feedback arc set is a set of edges that can be removed to make a graph acyclic.\n */\n acyclicer?: 'greedy' | undefined;\n\n /**\n * Type of algorithm to assign a rank to each node in the input graph.\n * Possible values are 'network-simplex', 'tight-tree', or 'longest-path'.\n * Additional custom values can also be provided as a string.\n */\n ranker?: 'network-simplex' | 'tight-tree' | 'longest-path' | string;\n}\n\n"],"names":[],"mappings":"IAuDY,gBASX;AATD,CAAA,UAAY,eAAe,EAAA;AACzB,IAAA,eAAA,CAAA,UAAA,CAAA,GAAA,UAAqB,CAAA;AACrB,IAAA,eAAA,CAAA,YAAA,CAAA,GAAA,YAAyB,CAAA;AACzB,IAAA,eAAA,CAAA,UAAA,CAAA,GAAA,UAAqB,CAAA;AACrB,IAAA,eAAA,CAAA,oBAAA,CAAA,GAAA,qBAA0C,CAAA;AAC1C,IAAA,eAAA,CAAA,OAAA,CAAA,GAAA,OAAe,CAAA;AACf,IAAA,eAAA,CAAA,OAAA,CAAA,GAAA,OAAe,CAAA;AACf,IAAA,eAAA,CAAA,KAAA,CAAA,GAAA,KAAW,CAAA;AACX,IAAA,eAAA,CAAA,eAAA,CAAA,GAAA,eAA+B,CAAA;AACjC,CAAC,EATW,eAAe,KAAf,eAAe,GAS1B,EAAA,CAAA,CAAA,CAAA;IAaW,eAGX;AAHD,CAAA,UAAY,cAAc,EAAA;AACxB,IAAA,cAAA,CAAA,QAAA,CAAA,GAAA,QAAiB,CAAA;AACjB,IAAA,cAAA,CAAA,OAAA,CAAA,GAAA,OAAe,CAAA;AACjB,CAAC,EAHW,cAAc,KAAd,cAAc,GAGzB,EAAA,CAAA,CAAA,CAAA;IAEW,oBAGX;AAHD,CAAA,UAAY,mBAAmB,EAAA;AAC7B,IAAA,mBAAA,CAAA,QAAA,CAAA,GAAA,QAAiB,CAAA;AACjB,IAAA,mBAAA,CAAA,QAAA,CAAA,GAAA,QAAiB,CAAA;AACnB,CAAC,EAHW,mBAAmB,KAAnB,mBAAmB,GAG9B,EAAA,CAAA,CAAA,CAAA;IAEW,eAKX;AALD,CAAA,UAAY,cAAc,EAAA;AACxB,IAAA,cAAA,CAAA,QAAA,CAAA,GAAA,QAAiB,CAAA;AACjB,IAAA,cAAA,CAAA,QAAA,CAAA,GAAA,QAAiB,CAAA;AACjB,IAAA,cAAA,CAAA,SAAA,CAAA,GAAA,SAAmB,CAAA;AACnB,IAAA,cAAA,CAAA,UAAA,CAAA,GAAA,UAAqB,CAAA;AACvB,CAAC,EALW,cAAc,KAAd,cAAc,GAKzB,EAAA,CAAA,CAAA;;;;"}
|
|
@@ -61,7 +61,7 @@ function updateNodes(sel, config, width, bleed, hasLinks, duration) {
|
|
|
61
61
|
nodeIcon$1
|
|
62
62
|
.attr('visibility', null)
|
|
63
63
|
.attr('text-anchor', 'middle')
|
|
64
|
-
.
|
|
64
|
+
.style('dominant-baseline', 'central')
|
|
65
65
|
.style('stroke', (d) => getColor(d, config.nodeIconColor))
|
|
66
66
|
.style('fill', (d) => getColor(d, config.nodeIconColor))
|
|
67
67
|
.style('font-size', (d) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"node.js","sources":["../../../../src/components/sankey/modules/node.ts"],"sourcesContent":["import { select, Selection } from 'd3-selection'\n\n// Utils\nimport { getColor } from 'utils/color'\nimport { getString } from 'utils/data'\nimport { smartTransition } from 'utils/d3'\n\n// Types\nimport { Spacing } from 'types/spacing'\n\n// Local Types\nimport { SankeyEnterTransitionType, SankeyExitTransitionType, SankeyInputLink, SankeyInputNode, SankeyNode, SankeyNodeAlign } from '../types'\n\n// Config\nimport { SankeyConfigInterface } from '../config'\n\n// Helpers\nimport { renderLabel } from './label'\n\n// Styles\nimport * as s from '../style'\n\nexport function createNodes<N extends SankeyInputNode, L extends SankeyInputLink> (\n sel: Selection<SVGGElement, SankeyNode<N, L>, SVGGElement, unknown>,\n config: SankeyConfigInterface<N, L>,\n width: number,\n bleed: Spacing\n): void {\n const { enterTransitionType } = config\n\n // Node\n sel.append('rect')\n .attr('class', s.node)\n .attr('width', config.nodeWidth)\n .attr('height', d => d.y1 - d.y0)\n .style('fill', node => getColor(node, config.nodeColor))\n\n // Labels\n const labelGroup = sel.append('g').attr('class', s.labelGroup)\n labelGroup.append('path').attr('class', s.labelBackground)\n labelGroup.append('text').attr('class', s.label)\n labelGroup.append('text').attr('class', s.sublabel)\n\n // Node icon\n sel.append('text').attr('class', s.nodeIcon)\n .attr('text-anchor', 'middle')\n .attr('dy', '0.5px')\n\n sel\n .attr('transform', d => {\n const x = (enterTransitionType === SankeyEnterTransitionType.FromAncestor && d.targetLinks?.[0]) ? d.targetLinks[0].source.x0 : d.x0\n return `translate(${sel.size() === 1 ? width * 0.5 - bleed.left : x}, ${d.y0})`\n })\n .style('opacity', 0)\n}\n\nfunction getNodeXPos<N extends SankeyInputNode, L extends SankeyInputLink> (\n d: SankeyNode<N, L>,\n config: SankeyConfigInterface<N, L>,\n width: number,\n bleed: Spacing,\n hasLinks: boolean\n): number {\n if (hasLinks) return d.x0\n\n switch (config.nodeAlign) {\n case SankeyNodeAlign.Left: return d.x0\n case SankeyNodeAlign.Right: return width - bleed.right\n case SankeyNodeAlign.Center:\n case SankeyNodeAlign.Justify:\n default: return width * 0.5 - bleed.left\n }\n}\n\nexport function updateNodes<N extends SankeyInputNode, L extends SankeyInputLink> (\n sel: Selection<SVGGElement, SankeyNode<N, L>, SVGGElement, unknown>,\n config: SankeyConfigInterface<N, L>,\n width: number,\n bleed: Spacing,\n hasLinks: boolean,\n duration: number\n): void {\n smartTransition(sel, duration)\n .attr('transform', d => `translate(${getNodeXPos(d, config, width, bleed, hasLinks)},${d.y0})`)\n .style('opacity', d => d._state.greyout ? 0.2 : 1)\n\n // Node\n smartTransition(sel.select(`.${s.node}`), duration)\n .attr('width', config.nodeWidth)\n .attr('height', (d: SankeyNode<N, L>) => d.y1 - d.y0)\n .style('cursor', (d: SankeyNode<N, L>) => getString(d, config.nodeCursor))\n .style('fill', (d: SankeyNode<N, L>) => getColor(d, config.nodeColor))\n\n // Label Rendering\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n renderNodeLabels(sel, config, width, duration)\n\n // Node Icon\n const nodeIcon = sel.select(`.${s.nodeIcon}`)\n if (config.nodeIcon) {\n nodeIcon\n .attr('visibility', null)\n .attr('text-anchor', 'middle')\n .attr('alignment-baseline', 'middle')\n .style('stroke', (d: SankeyNode<N, L>) => getColor(d, config.nodeIconColor))\n .style('fill', (d: SankeyNode<N, L>) => getColor(d, config.nodeIconColor))\n .style('font-size', (d: SankeyNode<N, L>) => {\n const nodeHeight = d.y1 - d.y0\n return nodeHeight < s.SANKEY_ICON_SIZE ? `${nodeHeight * 0.65}px` : null\n })\n .html((d: SankeyNode<N, L>) => getString(d, config.nodeIcon))\n\n smartTransition(nodeIcon, duration)\n .attr('x', config.nodeWidth / 2)\n .attr('y', (d: SankeyNode<N, L>) => (d.y1 - d.y0) / 2)\n } else {\n nodeIcon\n .attr('visibility', 'hidden')\n }\n}\n\nexport function renderNodeLabels<N extends SankeyInputNode, L extends SankeyInputLink> (\n sel: Selection<SVGGElement, SankeyNode<N, L>, SVGGElement, unknown>,\n config: SankeyConfigInterface<N, L>,\n width: number,\n duration: number,\n enforceNodeVisibility?: SankeyNode<N, L>\n): void {\n // Label Rendering\n const labelGroupSelection: Selection<SVGGElement, SankeyNode<N, L>, SVGGElement, any> = sel.select(`.${s.labelGroup}`)\n const labelGroupEls = labelGroupSelection.nodes() || []\n\n // After rendering Label return a BBox so we can do intersection detection and hide some of tem\n const labelGroupBBoxes = labelGroupEls.map(g => {\n const gSelection: Selection<SVGGElement, SankeyNode<N, L>, SVGGElement, any> = select(g)\n const datum = gSelection.datum()\n return renderLabel(gSelection, datum, config, width, duration, enforceNodeVisibility === datum)\n })\n\n if (config.labelVisibility) {\n for (const b of labelGroupBBoxes) {\n const datum = b.selection.datum() as SankeyNode<N, L>\n const box = { x: b.x, y: b.y, width: b.width, height: b.height }\n b.hidden = !config.labelVisibility(datum, box, enforceNodeVisibility === datum)\n }\n } else {\n // Detect intersecting labels\n const maxLayer = Math.max(...labelGroupBBoxes.map(b => b.layer))\n for (let layer = 0; layer <= maxLayer; layer += 1) {\n const boxes = labelGroupBBoxes.filter(b => (b.layer === layer))\n boxes.sort((a, b) => a.y - b.y)\n\n let lastVisibleIdx = 0\n for (let i = 1; i < boxes.length; i += 1) {\n const b0 = boxes[lastVisibleIdx]\n const b1 = boxes[i]\n\n const shouldBeHidden = b1.y < (b0.y + b0.height)\n if (shouldBeHidden) {\n if (b1.selection.datum() === enforceNodeVisibility) b0.hidden = true // If the hovered node should be hidden, hide the previous one instead\n else b1.hidden = true\n }\n\n if (!b1.hidden) lastVisibleIdx = i\n }\n }\n }\n\n // Hide intersecting labels\n for (const b of labelGroupBBoxes) {\n b.selection.classed(s.hidden, b.hidden)\n }\n}\n\nexport function removeNodes<N extends SankeyInputNode, L extends SankeyInputLink> (\n selection: Selection<SVGGElement, SankeyNode<N, L>, SVGGElement, unknown>,\n config: SankeyConfigInterface<N, L>,\n duration: number\n): void {\n const { exitTransitionType } = config\n\n selection.each((d, i, els) => {\n const node = select(els[i])\n const transition = smartTransition(node, duration)\n if ((exitTransitionType === SankeyExitTransitionType.ToAncestor) && d.targetLinks?.[0]) {\n transition.attr('transform', `translate(${d.targetLinks[0].source.x0},${d.y0})`)\n }\n\n transition\n .style('opacity', 0)\n .remove()\n })\n}\n\nexport function onNodeMouseOver<N extends SankeyInputNode, L extends SankeyInputLink> (\n d: SankeyNode<N, L>,\n nodeSelection: Selection<SVGGElement, SankeyNode<N, L>, SVGGElement, unknown>,\n config: SankeyConfigInterface<N, L>,\n width: number\n): void {\n const labelGroup = nodeSelection.raise()\n .select<SVGGElement>(`.${s.labelGroup}`)\n\n if ((config.labelExpandTrimmedOnHover && labelGroup.classed(s.labelTrimmed)) || labelGroup.classed(s.hidden)) {\n renderLabel(labelGroup, d, config, width, 0, true)\n }\n labelGroup.classed(s.forceShow, true)\n}\n\nexport function onNodeMouseOut<N extends SankeyInputNode, L extends SankeyInputLink> (\n d: SankeyNode<N, L>,\n nodeSelection: Selection<SVGGElement, SankeyNode<N, L>, SVGGElement, unknown>,\n config: SankeyConfigInterface<N, L>,\n width: number\n): void {\n const labelGroup = nodeSelection.select<SVGGElement>(`.${s.labelGroup}`)\n if (config.labelExpandTrimmedOnHover || labelGroup.classed(s.hidden)) {\n renderLabel(labelGroup, d, config, width, 0)\n }\n labelGroup.classed(s.forceShow, false)\n}\n"],"names":["s.node","labelGroup","s.labelGroup","s.labelBackground","s.label","s.sublabel","s.nodeIcon","nodeIcon","s.SANKEY_ICON_SIZE","s.hidden","s.labelTrimmed","s.forceShow"],"mappings":";;;;;;;;AAsBM,SAAU,WAAW,CACzB,GAAmE,EACnE,MAAmC,EACnC,KAAa,EACb,KAAc,EAAA;AAEd,IAAA,MAAM,EAAE,mBAAmB,EAAE,GAAG,MAAM,CAAA;;AAGtC,IAAA,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC;AACf,SAAA,IAAI,CAAC,OAAO,EAAEA,IAAM,CAAC;AACrB,SAAA,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,SAAS,CAAC;AAC/B,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AA;QAED,UAAU;AACP,aAAA,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC;AACnB,aAAA,MAAM,EAAE,CAAA;AACb,KAAC,CAAC,CAAA;AACJ,CAAC;AAEK,SAAU,eAAe,CAC7B,CAAmB,EACnB,aAA6E,EAC7E,MAAmC,EACnC,KAAa,EAAA;AAEb,IAAA,MAAMR,YAAU,GAAG,aAAa,CAAC,KAAK,EAAE;AACrC,SAAA,MAAM,CAAc,CAAI,CAAA,EAAAC,UAAY,CAAA,CAAE,CAAC,CAAA;IAE1C,IAAI,CAAC,MAAM,CAAC,yBAAyB,IAAID,YAAU,CAAC,OAAO,CAACS,YAAc,CAAC,KAAKT,YAAU,CAAC,OAAO,CAACQ,MAAQ,CAAC,EAAE;AAC5G,QAAA,WAAW,CAACR,YAAU,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,CAAC,CAAA;AACnD,KAAA;IACDA,YAAU,CAAC,OAAO,CAACU,SAAW,EAAE,IAAI,CAAC,CAAA;AACvC,CAAC;AAEK,SAAU,cAAc,CAC5B,CAAmB,EACnB,aAA6E,EAC7E,MAAmC,EACnC,KAAa,EAAA;AAEb,IAAA,MAAMV,YAAU,GAAG,aAAa,CAAC,MAAM,CAAc,CAAI,CAAA,EAAAC,UAAY,CAAE,CAAA,CAAC,CAAA;AACxE,IAAA,IAAI,MAAM,CAAC,yBAAyB,IAAID,YAAU,CAAC,OAAO,CAACQ,MAAQ,CAAC,EAAE;QACpE,WAAW,CAACR,YAAU,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,CAAA;AAC7C,KAAA;IACDA,YAAU,CAAC,OAAO,CAACU,SAAW,EAAE,KAAK,CAAC,CAAA;AACxC;;;;"}
|
|
1
|
+
{"version":3,"file":"node.js","sources":["../../../../src/components/sankey/modules/node.ts"],"sourcesContent":["import { select, Selection } from 'd3-selection'\n\n// Utils\nimport { getColor } from 'utils/color'\nimport { getString } from 'utils/data'\nimport { smartTransition } from 'utils/d3'\n\n// Types\nimport { Spacing } from 'types/spacing'\n\n// Local Types\nimport { SankeyEnterTransitionType, SankeyExitTransitionType, SankeyInputLink, SankeyInputNode, SankeyNode, SankeyNodeAlign } from '../types'\n\n// Config\nimport { SankeyConfigInterface } from '../config'\n\n// Helpers\nimport { renderLabel } from './label'\n\n// Styles\nimport * as s from '../style'\n\nexport function createNodes<N extends SankeyInputNode, L extends SankeyInputLink> (\n sel: Selection<SVGGElement, SankeyNode<N, L>, SVGGElement, unknown>,\n config: SankeyConfigInterface<N, L>,\n width: number,\n bleed: Spacing\n): void {\n const { enterTransitionType } = config\n\n // Node\n sel.append('rect')\n .attr('class', s.node)\n .attr('width', config.nodeWidth)\n .attr('height', d => d.y1 - d.y0)\n .style('fill', node => getColor(node, config.nodeColor))\n\n // Labels\n const labelGroup = sel.append('g').attr('class', s.labelGroup)\n labelGroup.append('path').attr('class', s.labelBackground)\n labelGroup.append('text').attr('class', s.label)\n labelGroup.append('text').attr('class', s.sublabel)\n\n // Node icon\n sel.append('text').attr('class', s.nodeIcon)\n .attr('text-anchor', 'middle')\n .attr('dy', '0.5px')\n\n sel\n .attr('transform', d => {\n const x = (enterTransitionType === SankeyEnterTransitionType.FromAncestor && d.targetLinks?.[0]) ? d.targetLinks[0].source.x0 : d.x0\n return `translate(${sel.size() === 1 ? width * 0.5 - bleed.left : x}, ${d.y0})`\n })\n .style('opacity', 0)\n}\n\nfunction getNodeXPos<N extends SankeyInputNode, L extends SankeyInputLink> (\n d: SankeyNode<N, L>,\n config: SankeyConfigInterface<N, L>,\n width: number,\n bleed: Spacing,\n hasLinks: boolean\n): number {\n if (hasLinks) return d.x0\n\n switch (config.nodeAlign) {\n case SankeyNodeAlign.Left: return d.x0\n case SankeyNodeAlign.Right: return width - bleed.right\n case SankeyNodeAlign.Center:\n case SankeyNodeAlign.Justify:\n default: return width * 0.5 - bleed.left\n }\n}\n\nexport function updateNodes<N extends SankeyInputNode, L extends SankeyInputLink> (\n sel: Selection<SVGGElement, SankeyNode<N, L>, SVGGElement, unknown>,\n config: SankeyConfigInterface<N, L>,\n width: number,\n bleed: Spacing,\n hasLinks: boolean,\n duration: number\n): void {\n smartTransition(sel, duration)\n .attr('transform', d => `translate(${getNodeXPos(d, config, width, bleed, hasLinks)},${d.y0})`)\n .style('opacity', d => d._state.greyout ? 0.2 : 1)\n\n // Node\n smartTransition(sel.select(`.${s.node}`), duration)\n .attr('width', config.nodeWidth)\n .attr('height', (d: SankeyNode<N, L>) => d.y1 - d.y0)\n .style('cursor', (d: SankeyNode<N, L>) => getString(d, config.nodeCursor))\n .style('fill', (d: SankeyNode<N, L>) => getColor(d, config.nodeColor))\n\n // Label Rendering\n // eslint-disable-next-line @typescript-eslint/no-use-before-define\n renderNodeLabels(sel, config, width, duration)\n\n // Node Icon\n const nodeIcon = sel.select(`.${s.nodeIcon}`)\n if (config.nodeIcon) {\n nodeIcon\n .attr('visibility', null)\n .attr('text-anchor', 'middle')\n .style('dominant-baseline', 'central')\n .style('stroke', (d: SankeyNode<N, L>) => getColor(d, config.nodeIconColor))\n .style('fill', (d: SankeyNode<N, L>) => getColor(d, config.nodeIconColor))\n .style('font-size', (d: SankeyNode<N, L>) => {\n const nodeHeight = d.y1 - d.y0\n return nodeHeight < s.SANKEY_ICON_SIZE ? `${nodeHeight * 0.65}px` : null\n })\n .html((d: SankeyNode<N, L>) => getString(d, config.nodeIcon))\n\n smartTransition(nodeIcon, duration)\n .attr('x', config.nodeWidth / 2)\n .attr('y', (d: SankeyNode<N, L>) => (d.y1 - d.y0) / 2)\n } else {\n nodeIcon\n .attr('visibility', 'hidden')\n }\n}\n\nexport function renderNodeLabels<N extends SankeyInputNode, L extends SankeyInputLink> (\n sel: Selection<SVGGElement, SankeyNode<N, L>, SVGGElement, unknown>,\n config: SankeyConfigInterface<N, L>,\n width: number,\n duration: number,\n enforceNodeVisibility?: SankeyNode<N, L>\n): void {\n // Label Rendering\n const labelGroupSelection: Selection<SVGGElement, SankeyNode<N, L>, SVGGElement, any> = sel.select(`.${s.labelGroup}`)\n const labelGroupEls = labelGroupSelection.nodes() || []\n\n // After rendering Label return a BBox so we can do intersection detection and hide some of tem\n const labelGroupBBoxes = labelGroupEls.map(g => {\n const gSelection: Selection<SVGGElement, SankeyNode<N, L>, SVGGElement, any> = select(g)\n const datum = gSelection.datum()\n return renderLabel(gSelection, datum, config, width, duration, enforceNodeVisibility === datum)\n })\n\n if (config.labelVisibility) {\n for (const b of labelGroupBBoxes) {\n const datum = b.selection.datum() as SankeyNode<N, L>\n const box = { x: b.x, y: b.y, width: b.width, height: b.height }\n b.hidden = !config.labelVisibility(datum, box, enforceNodeVisibility === datum)\n }\n } else {\n // Detect intersecting labels\n const maxLayer = Math.max(...labelGroupBBoxes.map(b => b.layer))\n for (let layer = 0; layer <= maxLayer; layer += 1) {\n const boxes = labelGroupBBoxes.filter(b => (b.layer === layer))\n boxes.sort((a, b) => a.y - b.y)\n\n let lastVisibleIdx = 0\n for (let i = 1; i < boxes.length; i += 1) {\n const b0 = boxes[lastVisibleIdx]\n const b1 = boxes[i]\n\n const shouldBeHidden = b1.y < (b0.y + b0.height)\n if (shouldBeHidden) {\n if (b1.selection.datum() === enforceNodeVisibility) b0.hidden = true // If the hovered node should be hidden, hide the previous one instead\n else b1.hidden = true\n }\n\n if (!b1.hidden) lastVisibleIdx = i\n }\n }\n }\n\n // Hide intersecting labels\n for (const b of labelGroupBBoxes) {\n b.selection.classed(s.hidden, b.hidden)\n }\n}\n\nexport function removeNodes<N extends SankeyInputNode, L extends SankeyInputLink> (\n selection: Selection<SVGGElement, SankeyNode<N, L>, SVGGElement, unknown>,\n config: SankeyConfigInterface<N, L>,\n duration: number\n): void {\n const { exitTransitionType } = config\n\n selection.each((d, i, els) => {\n const node = select(els[i])\n const transition = smartTransition(node, duration)\n if ((exitTransitionType === SankeyExitTransitionType.ToAncestor) && d.targetLinks?.[0]) {\n transition.attr('transform', `translate(${d.targetLinks[0].source.x0},${d.y0})`)\n }\n\n transition\n .style('opacity', 0)\n .remove()\n })\n}\n\nexport function onNodeMouseOver<N extends SankeyInputNode, L extends SankeyInputLink> (\n d: SankeyNode<N, L>,\n nodeSelection: Selection<SVGGElement, SankeyNode<N, L>, SVGGElement, unknown>,\n config: SankeyConfigInterface<N, L>,\n width: number\n): void {\n const labelGroup = nodeSelection.raise()\n .select<SVGGElement>(`.${s.labelGroup}`)\n\n if ((config.labelExpandTrimmedOnHover && labelGroup.classed(s.labelTrimmed)) || labelGroup.classed(s.hidden)) {\n renderLabel(labelGroup, d, config, width, 0, true)\n }\n labelGroup.classed(s.forceShow, true)\n}\n\nexport function onNodeMouseOut<N extends SankeyInputNode, L extends SankeyInputLink> (\n d: SankeyNode<N, L>,\n nodeSelection: Selection<SVGGElement, SankeyNode<N, L>, SVGGElement, unknown>,\n config: SankeyConfigInterface<N, L>,\n width: number\n): void {\n const labelGroup = nodeSelection.select<SVGGElement>(`.${s.labelGroup}`)\n if (config.labelExpandTrimmedOnHover || labelGroup.classed(s.hidden)) {\n renderLabel(labelGroup, d, config, width, 0)\n }\n labelGroup.classed(s.forceShow, false)\n}\n"],"names":["s.node","labelGroup","s.labelGroup","s.labelBackground","s.label","s.sublabel","s.nodeIcon","nodeIcon","s.SANKEY_ICON_SIZE","s.hidden","s.labelTrimmed","s.forceShow"],"mappings":";;;;;;;;AAsBM,SAAU,WAAW,CACzB,GAAmE,EACnE,MAAmC,EACnC,KAAa,EACb,KAAc,EAAA;AAEd,IAAA,MAAM,EAAE,mBAAmB,EAAE,GAAG,MAAM,CAAA;;AAGtC,IAAA,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC;AACf,SAAA,IAAI,CAAC,OAAO,EAAEA,IAAM,CAAC;AACrB,SAAA,IAAI,CAAC,OAAO,EAAE,MAAM,CAAC,SAAS,CAAC;AAC/B,SAAA,IAAI,CAAC,QAAQ,EAAE,CAAC,IAAI,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC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AACb,KAAC,CAAC,CAAA;AACJ,CAAC;AAEK,SAAU,eAAe,CAC7B,CAAmB,EACnB,aAA6E,EAC7E,MAAmC,EACnC,KAAa,EAAA;AAEb,IAAA,MAAMR,YAAU,GAAG,aAAa,CAAC,KAAK,EAAE;AACrC,SAAA,MAAM,CAAc,CAAI,CAAA,EAAAC,UAAY,CAAA,CAAE,CAAC,CAAA;IAE1C,IAAI,CAAC,MAAM,CAAC,yBAAyB,IAAID,YAAU,CAAC,OAAO,CAACS,YAAc,CAAC,KAAKT,YAAU,CAAC,OAAO,CAACQ,MAAQ,CAAC,EAAE;AAC5G,QAAA,WAAW,CAACR,YAAU,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,CAAC,CAAA;AACnD,KAAA;IACDA,YAAU,CAAC,OAAO,CAACU,SAAW,EAAE,IAAI,CAAC,CAAA;AACvC,CAAC;AAEK,SAAU,cAAc,CAC5B,CAAmB,EACnB,aAA6E,EAC7E,MAAmC,EACnC,KAAa,EAAA;AAEb,IAAA,MAAMV,YAAU,GAAG,aAAa,CAAC,MAAM,CAAc,CAAI,CAAA,EAAAC,UAAY,CAAE,CAAA,CAAC,CAAA;AACxE,IAAA,IAAI,MAAM,CAAC,yBAAyB,IAAID,YAAU,CAAC,OAAO,CAACQ,MAAQ,CAAC,EAAE;QACpE,WAAW,CAACR,YAAU,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC,CAAA;AAC7C,KAAA;IACDA,YAAU,CAAC,OAAO,CAACU,SAAW,EAAE,KAAK,CAAC,CAAA;AACxC;;;;"}
|
|
@@ -29,7 +29,7 @@ export interface TooltipConfigInterface {
|
|
|
29
29
|
* ```
|
|
30
30
|
*/
|
|
31
31
|
triggers?: {
|
|
32
|
-
[selector: string]: (data: any, i: number, elements: (HTMLElement | SVGElement)[]) => string | HTMLElement | undefined | null;
|
|
32
|
+
[selector: string]: ((data: any, i: number, elements: (HTMLElement | SVGElement)[]) => string | HTMLElement | undefined | null) | undefined | null;
|
|
33
33
|
};
|
|
34
34
|
/** Custom DOM attributes for the tooltip. Useful when you need to refer to a specific tooltip instance
|
|
35
35
|
* by using a CSS selector. Attributes configuration object has the following structure:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sources":["../../../src/components/tooltip/config.ts"],"sourcesContent":["/* eslint-disable no-irregular-whitespace */\nimport { ComponentCore } from 'core/component'\n\n// Types\nimport { Position } from 'types/position'\n\nexport interface TooltipConfigInterface {\n /** An array of visualization components to interact with. Default: `[]` */\n components?: ComponentCore<unknown>[];\n /** Container to where the Tooltip component should be inserted. Default: `undefined` */\n container?: HTMLElement;\n /** Horizontal placement of the tooltip. Default: `Position.Auto` */\n horizontalPlacement?: Position | string | undefined;\n /** Horizontal shift of the tooltip in pixels. Default: `0` */\n horizontalShift?: number;\n /** Vertical placement of the tooltip. Default: `Position.Top` */\n verticalPlacement?: Position | string | undefined;\n /** Vertical shift of the tooltip in pixels. Default: `0` */\n verticalShift?: number;\n /** Defines the content of the tooltip and hovering over which elements should trigger it.\n * An object containing properties in the following format:\n *\n * ```\n * {\n * [selectorString]: (d: unknown) => string | HTMLElement\n * }\n * ```\n * e.g.:\n * ```\n * {\n * [Area.selectors.area]: (d: AreaDatum[]) => `<div>${d.value.toString()}</div>\n * }\n * ```\n */\n triggers?: {\n [selector: string]: (data: any, i: number, elements: (HTMLElement | SVGElement)[]) => string | HTMLElement | undefined | null;\n };\n /** Custom DOM attributes for the tooltip. Useful when you need to refer to a specific tooltip instance\n * by using a CSS selector. Attributes configuration object has the following structure:\n *\n * ```\n * {\n * [attributeName]: attribute value\n * }\n * ```\n * e.g.:\n * ```\n * {\n * 'type': 'area-tooltip',\n * 'value': 42\n * }\n * ```\n */\n attributes?: { [attr: string]: string | number | boolean };\n}\n\nexport const TooltipDefaultConfig: TooltipConfigInterface = {\n components: [],\n container: undefined,\n horizontalPlacement: Position.Auto,\n horizontalShift: 0,\n verticalPlacement: Position.Top,\n verticalShift: 0,\n attributes: {},\n triggers: {},\n}\n\n"],"names":[],"mappings":";;AAGA;AAqDa,MAAA,oBAAoB,GAA2B;AAC1D,IAAA,UAAU,EAAE,EAAE;AACd,IAAA,SAAS,EAAE,SAAS;IACpB,mBAAmB,EAAE,QAAQ,CAAC,IAAI;AAClC,IAAA,eAAe,EAAE,CAAC;IAClB,iBAAiB,EAAE,QAAQ,CAAC,GAAG;AAC/B,IAAA,aAAa,EAAE,CAAC;AAChB,IAAA,UAAU,EAAE,EAAE;AACd,IAAA,QAAQ,EAAE,EAAE;;;;;"}
|
|
1
|
+
{"version":3,"file":"config.js","sources":["../../../src/components/tooltip/config.ts"],"sourcesContent":["/* eslint-disable no-irregular-whitespace */\nimport { ComponentCore } from 'core/component'\n\n// Types\nimport { Position } from 'types/position'\n\nexport interface TooltipConfigInterface {\n /** An array of visualization components to interact with. Default: `[]` */\n components?: ComponentCore<unknown>[];\n /** Container to where the Tooltip component should be inserted. Default: `undefined` */\n container?: HTMLElement;\n /** Horizontal placement of the tooltip. Default: `Position.Auto` */\n horizontalPlacement?: Position | string | undefined;\n /** Horizontal shift of the tooltip in pixels. Default: `0` */\n horizontalShift?: number;\n /** Vertical placement of the tooltip. Default: `Position.Top` */\n verticalPlacement?: Position | string | undefined;\n /** Vertical shift of the tooltip in pixels. Default: `0` */\n verticalShift?: number;\n /** Defines the content of the tooltip and hovering over which elements should trigger it.\n * An object containing properties in the following format:\n *\n * ```\n * {\n * [selectorString]: (d: unknown) => string | HTMLElement\n * }\n * ```\n * e.g.:\n * ```\n * {\n * [Area.selectors.area]: (d: AreaDatum[]) => `<div>${d.value.toString()}</div>\n * }\n * ```\n */\n triggers?: {\n [selector: string]: ((data: any, i: number, elements: (HTMLElement | SVGElement)[]) => string | HTMLElement | undefined | null) | undefined | null;\n };\n /** Custom DOM attributes for the tooltip. Useful when you need to refer to a specific tooltip instance\n * by using a CSS selector. Attributes configuration object has the following structure:\n *\n * ```\n * {\n * [attributeName]: attribute value\n * }\n * ```\n * e.g.:\n * ```\n * {\n * 'type': 'area-tooltip',\n * 'value': 42\n * }\n * ```\n */\n attributes?: { [attr: string]: string | number | boolean };\n}\n\nexport const TooltipDefaultConfig: TooltipConfigInterface = {\n components: [],\n container: undefined,\n horizontalPlacement: Position.Auto,\n horizontalShift: 0,\n verticalPlacement: Position.Top,\n verticalShift: 0,\n attributes: {},\n triggers: {},\n}\n\n"],"names":[],"mappings":";;AAGA;AAqDa,MAAA,oBAAoB,GAA2B;AAC1D,IAAA,UAAU,EAAE,EAAE;AACd,IAAA,SAAS,EAAE,SAAS;IACpB,mBAAmB,EAAE,QAAQ,CAAC,IAAI;AAClC,IAAA,eAAe,EAAE,CAAC;IAClB,iBAAiB,EAAE,QAAQ,CAAC,GAAG;AAC/B,IAAA,aAAa,EAAE,CAAC;AAChB,IAAA,UAAU,EAAE,EAAE;AACd,IAAA,QAAQ,EAAE,EAAE;;;;;"}
|
|
@@ -125,7 +125,7 @@ class Tooltip {
|
|
|
125
125
|
var _a;
|
|
126
126
|
// Tooltip position calculation relies on the parent position
|
|
127
127
|
// If it's not set (static), we set it to `relative` (not a good practice)
|
|
128
|
-
if (((_a = getComputedStyle(this._container)) === null || _a === void 0 ? void 0 : _a.position) === 'static') {
|
|
128
|
+
if (this._container !== document.body && ((_a = getComputedStyle(this._container)) === null || _a === void 0 ? void 0 : _a.position) === 'static') {
|
|
129
129
|
this._container.style.position = 'relative';
|
|
130
130
|
}
|
|
131
131
|
}
|
|
@@ -144,6 +144,8 @@ class Tooltip {
|
|
|
144
144
|
// Go through all of the configured triggers
|
|
145
145
|
for (const className of Object.keys(triggers)) {
|
|
146
146
|
const template = triggers[className];
|
|
147
|
+
if (!template)
|
|
148
|
+
continue; // Skip if the trigger is not configured
|
|
147
149
|
const els = selection.selectAll(`.${className}`).nodes();
|
|
148
150
|
// Go through all of the elements in the event path (from the deepest element upwards)
|
|
149
151
|
for (const el of path) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/tooltip/index.ts"],"sourcesContent":["import { select, Selection, pointer } from 'd3-selection'\n\n// Core\nimport { ComponentCore } from 'core/component'\n\n// Types\nimport { Position } from 'types/position'\n\n// Utils\nimport { merge, throttle } from 'utils/data'\n\n// Config\nimport { TooltipDefaultConfig, TooltipConfigInterface } from './config'\n\n// Style\nimport * as s from './style'\n\nexport class Tooltip {\n element: HTMLElement\n div: Selection<HTMLElement, unknown, null, undefined>\n protected _defaultConfig = TooltipDefaultConfig as TooltipConfigInterface\n public config: TooltipConfigInterface = this._defaultConfig\n prevConfig: TooltipConfigInterface\n components: ComponentCore<unknown>[]\n static selectors = s\n private _setUpEventsThrottled = throttle(this._setUpEvents, 500)\n private _setContainerPositionThrottled = throttle(this._setContainerPosition, 500)\n private _isShown = false\n private _container: HTMLElement\n\n constructor (config: TooltipConfigInterface = {}) {\n this.element = document.createElement('div')\n this.div = select(this.element)\n .attr('class', s.tooltip)\n\n this.setConfig(config)\n this.components = this.config.components\n }\n\n public setConfig (config: TooltipConfigInterface): void {\n this.prevConfig = this.config\n this.config = merge(this._defaultConfig, config)\n\n if (this.config.container && (this.config.container !== this.prevConfig?.container)) {\n this.setContainer(this.config.container)\n }\n\n this._setUpAttributes()\n }\n\n public setContainer (container: HTMLElement): void {\n this.element.parentNode?.removeChild(this.element)\n\n this._container = container\n this._container.appendChild(this.element)\n\n this._setContainerPositionThrottled()\n }\n\n public getContainer (): HTMLElement {\n return this._container\n }\n\n public hasContainer (): boolean {\n return !!this._container && this._container.isConnected\n }\n\n public setComponents (components: ComponentCore<unknown>[]): void {\n this.components = components\n }\n\n public update (): void {\n if (!this._container) return\n\n this._setUpEventsThrottled()\n }\n\n public show (html: string | HTMLElement, pos: { x: number; y: number }): void {\n if (html instanceof HTMLElement) {\n const node = this.div.select(':first-child').node()\n if (node !== html) this.div.html('').append(() => html)\n } else {\n this.div.html(html)\n }\n\n this.div\n .classed(s.hidden, false)\n .classed(s.show, true)\n\n this._isShown = true\n this.place(pos)\n }\n\n public hide (): void {\n this.div.classed(s.show, false)\n .on('transitionend', () => {\n // We hide the element once the transition completes\n // This ensures container overflow will not occur when the window is resized\n this.div.classed(s.hidden, !this._isShown)\n })\n\n this._isShown = false\n }\n\n public place (pos: { x: number; y: number }): void {\n if (!this.hasContainer()) {\n console.warn('Unovis | Tooltip: Container was not set or is not initialized yet')\n return\n }\n const { config } = this\n const isContainerBody = this.isContainerBody()\n const width = this.element.offsetWidth\n const height = this.element.offsetHeight\n const containerHeight = isContainerBody ? window.innerHeight : this._container.scrollHeight\n const containerWidth = isContainerBody ? window.innerWidth : this._container.scrollWidth\n\n const horizontalPlacement = config.horizontalPlacement === Position.Auto\n ? (pos.x > containerWidth / 2 ? Position.Left : Position.Right)\n : config.horizontalPlacement\n\n const verticalPlacement = config.verticalPlacement === Position.Auto\n ? (pos.y > containerHeight / 2 ? Position.Top : Position.Bottom)\n : config.verticalPlacement\n\n // dx and dy variables shift the tooltip from the default position (above the cursor, centred horizontally)\n const margin = 5\n const dx = horizontalPlacement === Position.Left ? -width - margin - config.horizontalShift\n : horizontalPlacement === Position.Center ? -width / 2\n : margin + config.horizontalShift\n const dy = verticalPlacement === Position.Bottom ? height + margin + config.verticalShift\n : verticalPlacement === Position.Center ? height / 2\n : -margin - config.verticalShift\n\n // Constraint to container\n const paddingX = 10\n const hitRight = pos.x > (containerWidth - width - dx - paddingX)\n const hitLeft = pos.x < -dx + paddingX\n const constraintX = hitRight ? (containerWidth - width - dx) - pos.x - paddingX\n : hitLeft ? -dx - pos.x + paddingX : 0\n\n const paddingY = 10\n const hitBottom = pos.y > (containerHeight - dy - paddingY)\n const hitTop = pos.y < (height - dy + paddingY)\n const constraintY = hitBottom ? containerHeight - dy - pos.y - paddingY\n : hitTop ? height - dy - pos.y + paddingY : 0\n\n // Placing\n // If the container size is smaller than the the tooltip size we just stick the tooltip to the top / left\n const x = containerWidth < width ? 0 : pos.x + constraintX + dx\n const y = containerHeight < height ? height : pos.y + constraintY + dy\n\n this.div\n .classed(s.positionFixed, isContainerBody)\n .style('top', isContainerBody ? `${y - height}px` : 'unset')\n .style('bottom', !isContainerBody ? `${containerHeight - y}px` : 'unset')\n .style('left', `${x}px`)\n }\n\n public isContainerBody (): boolean {\n return this._container === document.body\n }\n\n private _setContainerPosition (): void {\n // Tooltip position calculation relies on the parent position\n // If it's not set (static), we set it to `relative` (not a good practice)\n if (getComputedStyle(this._container)?.position === 'static') {\n this._container.style.position = 'relative'\n }\n }\n\n private _setUpEvents (): void {\n const { config: { triggers } } = this\n const isContainerBody = this.isContainerBody()\n\n // We use the Event Delegation pattern to set up Tooltip events\n // Every component will have single `mousemove` and `mouseleave` event listener functions, where we'll check\n // the `path` of the event and trigger corresponding callbacks\n this.components.forEach(component => {\n const selection = select(component.element)\n selection\n .on('mousemove.tooltip', (e: MouseEvent) => {\n const [x, y] = isContainerBody ? [e.clientX, e.clientY] : pointer(e, this._container)\n const path: (HTMLElement | SVGGElement)[] = (e.composedPath && e.composedPath()) || (e as any).path || [e.target]\n\n // Go through all of the configured triggers\n for (const className of Object.keys(triggers)) {\n const template = triggers[className]\n const els = selection.selectAll<HTMLElement | SVGGElement, unknown>(`.${className}`).nodes()\n\n // Go through all of the elements in the event path (from the deepest element upwards)\n for (const el of path) {\n if (el === selection.node()) break // Break on the component's level (usually the `<g>` element)\n if (el.classList.contains(className)) { // If there's a match, show the tooltip\n const i = els.indexOf(el)\n const d = select(el).datum()\n const content = template(d, i, els)\n if (content) this.show(content, { x, y })\n else this.hide()\n\n e.stopPropagation() // Stop propagation to prevent other interfering events from being triggered, e.g. Crosshair\n return // Stop looking for other matches\n }\n }\n }\n\n // Hide the tooltip if the event didn't pass through any of the configured triggers.\n // We use the `this._isShown` condition as a little performance optimization tweak\n // (we don't want the tooltip to update its class on every mouse movement, see `this.hide()`).\n if (this._isShown) this.hide()\n })\n .on('mouseleave.tooltip', (e: MouseEvent) => {\n e.stopPropagation() // Stop propagation to prevent other interfering events from being triggered, e.g. Crosshair\n this.hide()\n })\n })\n }\n\n private _setUpAttributes (): void {\n const attributesMap = this.config.attributes\n if (!attributesMap) return\n\n Object.keys(attributesMap).forEach(attr => {\n this.div.attr(attr, attributesMap[attr])\n })\n }\n\n public destroy (): void {\n this.div?.remove()\n }\n}\n"],"names":["s.tooltip","s.hidden","s.show","s.positionFixed","s"],"mappings":";;;;;;;MAiBa,OAAO,CAAA;AAalB,IAAA,WAAA,CAAa,SAAiC,EAAE,EAAA;QAVtC,IAAc,CAAA,cAAA,GAAG,oBAA8C,CAAA;AAClE,QAAA,IAAA,CAAA,MAAM,GAA2B,IAAI,CAAC,cAAc,CAAA;QAInD,IAAqB,CAAA,qBAAA,GAAG,QAAQ,CAAC,IAAI,CAAC,YAAY,EAAE,GAAG,CAAC,CAAA;QACxD,IAA8B,CAAA,8BAAA,GAAG,QAAQ,CAAC,IAAI,CAAC,qBAAqB,EAAE,GAAG,CAAC,CAAA;QAC1E,IAAQ,CAAA,QAAA,GAAG,KAAK,CAAA;QAItB,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC,CAAA;QAC5C,IAAI,CAAC,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC;AAC5B,aAAA,IAAI,CAAC,OAAO,EAAEA,OAAS,CAAC,CAAA;AAE3B,QAAA,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;QACtB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAA;KACzC;AAEM,IAAA,SAAS,CAAE,MAA8B,EAAA;;AAC9C,QAAA,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,MAAM,CAAA;QAC7B,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,IAAI,CAAC,cAAc,EAAE,MAAM,CAAC,CAAA;QAEhD,IAAI,IAAI,CAAC,MAAM,CAAC,SAAS,KAAK,IAAI,CAAC,MAAM,CAAC,SAA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AAC,MAAM,CAAC,UAAU,CAAA;AAC5C,QAAA,IAAI,CAAC,aAAa;YAAE,OAAM;QAE1B,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC,IAAI,IAAG;AACxC,YAAA,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC,CAAA;AAC1C,SAAC,CAAC,CAAA;KACH;IAEM,OAAO,GAAA;;AACZ,QAAA,CAAA,EAAA,GAAA,IAAI,CAAC,GAAG,MAAE,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,MAAM,EAAE,CAAA;KACnB;;AA5MM,OAAS,CAAA,SAAA,GAAGC,KAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/tooltip/index.ts"],"sourcesContent":["import { select, Selection, pointer } from 'd3-selection'\n\n// Core\nimport { ComponentCore } from 'core/component'\n\n// Types\nimport { Position } from 'types/position'\n\n// Utils\nimport { merge, throttle } from 'utils/data'\n\n// Config\nimport { TooltipDefaultConfig, TooltipConfigInterface } from './config'\n\n// Style\nimport * as s from './style'\n\nexport class Tooltip {\n element: HTMLElement\n div: Selection<HTMLElement, unknown, null, undefined>\n protected _defaultConfig = TooltipDefaultConfig as TooltipConfigInterface\n public config: TooltipConfigInterface = this._defaultConfig\n prevConfig: TooltipConfigInterface\n components: ComponentCore<unknown>[]\n static selectors = s\n private _setUpEventsThrottled = throttle(this._setUpEvents, 500)\n private _setContainerPositionThrottled = throttle(this._setContainerPosition, 500)\n private _isShown = false\n private _container: HTMLElement\n\n constructor (config: TooltipConfigInterface = {}) {\n this.element = document.createElement('div')\n this.div = select(this.element)\n .attr('class', s.tooltip)\n\n this.setConfig(config)\n this.components = this.config.components\n }\n\n public setConfig (config: TooltipConfigInterface): void {\n this.prevConfig = this.config\n this.config = merge(this._defaultConfig, config)\n\n if (this.config.container && (this.config.container !== this.prevConfig?.container)) {\n this.setContainer(this.config.container)\n }\n\n this._setUpAttributes()\n }\n\n public setContainer (container: HTMLElement): void {\n this.element.parentNode?.removeChild(this.element)\n\n this._container = container\n this._container.appendChild(this.element)\n\n this._setContainerPositionThrottled()\n }\n\n public getContainer (): HTMLElement {\n return this._container\n }\n\n public hasContainer (): boolean {\n return !!this._container && this._container.isConnected\n }\n\n public setComponents (components: ComponentCore<unknown>[]): void {\n this.components = components\n }\n\n public update (): void {\n if (!this._container) return\n\n this._setUpEventsThrottled()\n }\n\n public show (html: string | HTMLElement, pos: { x: number; y: number }): void {\n if (html instanceof HTMLElement) {\n const node = this.div.select(':first-child').node()\n if (node !== html) this.div.html('').append(() => html)\n } else {\n this.div.html(html)\n }\n\n this.div\n .classed(s.hidden, false)\n .classed(s.show, true)\n\n this._isShown = true\n this.place(pos)\n }\n\n public hide (): void {\n this.div.classed(s.show, false)\n .on('transitionend', () => {\n // We hide the element once the transition completes\n // This ensures container overflow will not occur when the window is resized\n this.div.classed(s.hidden, !this._isShown)\n })\n\n this._isShown = false\n }\n\n public place (pos: { x: number; y: number }): void {\n if (!this.hasContainer()) {\n console.warn('Unovis | Tooltip: Container was not set or is not initialized yet')\n return\n }\n const { config } = this\n const isContainerBody = this.isContainerBody()\n const width = this.element.offsetWidth\n const height = this.element.offsetHeight\n const containerHeight = isContainerBody ? window.innerHeight : this._container.scrollHeight\n const containerWidth = isContainerBody ? window.innerWidth : this._container.scrollWidth\n\n const horizontalPlacement = config.horizontalPlacement === Position.Auto\n ? (pos.x > containerWidth / 2 ? Position.Left : Position.Right)\n : config.horizontalPlacement\n\n const verticalPlacement = config.verticalPlacement === Position.Auto\n ? (pos.y > containerHeight / 2 ? Position.Top : Position.Bottom)\n : config.verticalPlacement\n\n // dx and dy variables shift the tooltip from the default position (above the cursor, centred horizontally)\n const margin = 5\n const dx = horizontalPlacement === Position.Left ? -width - margin - config.horizontalShift\n : horizontalPlacement === Position.Center ? -width / 2\n : margin + config.horizontalShift\n const dy = verticalPlacement === Position.Bottom ? height + margin + config.verticalShift\n : verticalPlacement === Position.Center ? height / 2\n : -margin - config.verticalShift\n\n // Constraint to container\n const paddingX = 10\n const hitRight = pos.x > (containerWidth - width - dx - paddingX)\n const hitLeft = pos.x < -dx + paddingX\n const constraintX = hitRight ? (containerWidth - width - dx) - pos.x - paddingX\n : hitLeft ? -dx - pos.x + paddingX : 0\n\n const paddingY = 10\n const hitBottom = pos.y > (containerHeight - dy - paddingY)\n const hitTop = pos.y < (height - dy + paddingY)\n const constraintY = hitBottom ? containerHeight - dy - pos.y - paddingY\n : hitTop ? height - dy - pos.y + paddingY : 0\n\n // Placing\n // If the container size is smaller than the the tooltip size we just stick the tooltip to the top / left\n const x = containerWidth < width ? 0 : pos.x + constraintX + dx\n const y = containerHeight < height ? height : pos.y + constraintY + dy\n\n this.div\n .classed(s.positionFixed, isContainerBody)\n .style('top', isContainerBody ? `${y - height}px` : 'unset')\n .style('bottom', !isContainerBody ? `${containerHeight - y}px` : 'unset')\n .style('left', `${x}px`)\n }\n\n public isContainerBody (): boolean {\n return this._container === document.body\n }\n\n private _setContainerPosition (): void {\n // Tooltip position calculation relies on the parent position\n // If it's not set (static), we set it to `relative` (not a good practice)\n if (this._container !== document.body && getComputedStyle(this._container)?.position === 'static') {\n this._container.style.position = 'relative'\n }\n }\n\n private _setUpEvents (): void {\n const { config: { triggers } } = this\n const isContainerBody = this.isContainerBody()\n\n // We use the Event Delegation pattern to set up Tooltip events\n // Every component will have single `mousemove` and `mouseleave` event listener functions, where we'll check\n // the `path` of the event and trigger corresponding callbacks\n this.components.forEach(component => {\n const selection = select(component.element)\n selection\n .on('mousemove.tooltip', (e: MouseEvent) => {\n const [x, y] = isContainerBody ? [e.clientX, e.clientY] : pointer(e, this._container)\n const path: (HTMLElement | SVGGElement)[] = (e.composedPath && e.composedPath()) || (e as any).path || [e.target]\n\n // Go through all of the configured triggers\n for (const className of Object.keys(triggers)) {\n const template = triggers[className]\n if (!template) continue // Skip if the trigger is not configured\n\n const els = selection.selectAll<HTMLElement | SVGGElement, unknown>(`.${className}`).nodes()\n\n // Go through all of the elements in the event path (from the deepest element upwards)\n for (const el of path) {\n if (el === selection.node()) break // Break on the component's level (usually the `<g>` element)\n if (el.classList.contains(className)) { // If there's a match, show the tooltip\n const i = els.indexOf(el)\n const d = select(el).datum()\n const content = template(d, i, els)\n if (content) this.show(content, { x, y })\n else this.hide()\n\n e.stopPropagation() // Stop propagation to prevent other interfering events from being triggered, e.g. Crosshair\n return // Stop looking for other matches\n }\n }\n }\n\n // Hide the tooltip if the event didn't pass through any of the configured triggers.\n // We use the `this._isShown` condition as a little performance optimization tweak\n // (we don't want the tooltip to update its class on every mouse movement, see `this.hide()`).\n if (this._isShown) this.hide()\n })\n .on('mouseleave.tooltip', (e: MouseEvent) => {\n e.stopPropagation() // Stop propagation to prevent other interfering events from being triggered, e.g. Crosshair\n this.hide()\n })\n })\n }\n\n private _setUpAttributes (): void {\n const attributesMap = this.config.attributes\n if (!attributesMap) return\n\n Object.keys(attributesMap).forEach(attr => {\n this.div.attr(attr, attributesMap[attr])\n })\n }\n\n public destroy (): void {\n this.div?.remove()\n }\n}\n"],"names":["s.tooltip","s.hidden","s.show","s.positionFixed","s"],"mappings":";;;;;;;MAiBa,OAAO,CAAA;AAalB,IAAA,WAAA,CAAa,SAAiC,EAAE,EAAA;QAVtC,IAAc,CAAA,cAAA,GAAG,oBAA8C,CAAA;AAClE,QAAA,IAAA,CAAA,MAAM,GAA2B,IAAI,CAAC,cAAc,CAAA;QAInD,IAAqB,CAAA,qBAAA,GAAG,QAAQ,CAAC,IAAI,CAAC,YAAY,EAAE,GAAG,CAAC,CAAA;QACxD,IAA8B,CAAA,8BAAA,GAAG,QAAQ,CAAC,IAAI,CAAC,qBAAqB,EAAE,GAAG,CAAC,CAAA;QAC1E,IAAQ,CAAA,QAAA,GAAG,KAAK,CAAA;QAItB,IAAI,CAAC,OAAO,GAAG,QAAQ,CAAC,aAAa,CAAC,KA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IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAA;;gCACpC,IAAI,CAAC,IAAI,EAAE,CAAA;AAEhB,4BAAA,CAAC,CAAC,eAAe,EAAE,CAAA;AACnB,4BAAA,OAAM;AACP,yBAAA;AACF,qBAAA;AACF,iBAAA;;;;gBAKD,IAAI,IAAI,CAAC,QAAQ;oBAAE,IAAI,CAAC,IAAI,EAAE,CAAA;AAChC,aAAC,CAAC;AACD,iBAAA,EAAE,CAAC,oBAAoB,EAAE,CAAC,CAAa,KAAI;AAC1C,gBAAA,CAAC,CAAC,eAAe,EAAE,CAAA;gBACnB,IAAI,CAAC,IAAI,EAAE,CAAA;AACb,aAAC,CAAC,CAAA;AACN,SAAC,CAAC,CAAA;KACH;IAEO,gBAAgB,GAAA;AACtB,QAAA,MAAM,aAAa,GAAG,IAAI,CAAC,MAAM,CAAC,UAAU,CAAA;AAC5C,QAAA,IAAI,CAAC,aAAa;YAAE,OAAM;QAE1B,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,OAAO,CAAC,IAAI,IAAG;AACxC,YAAA,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC,CAAA;AAC1C,SAAC,CAAC,CAAA;KACH;IAEM,OAAO,GAAA;;AACZ,QAAA,CAAA,EAAA,GAAA,IAAI,CAAC,GAAG,MAAE,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,MAAM,EAAE,CAAA;KACnB;;AA9MM,OAAS,CAAA,SAAA,GAAGC,KAAC;;;;"}
|
|
@@ -52,7 +52,7 @@ class XYLabels extends XYComponentCore {
|
|
|
52
52
|
}
|
|
53
53
|
return acc;
|
|
54
54
|
}, [])) !== null && _b !== void 0 ? _b : [];
|
|
55
|
-
return this._getClusteredLabels(labels);
|
|
55
|
+
return config.clustering ? this._getClusteredLabels(labels) : labels;
|
|
56
56
|
}
|
|
57
57
|
_getClusteredLabels(labels) {
|
|
58
58
|
const labelsNonOverlapping = [...labels];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/xy-labels/index.ts"],"sourcesContent":["// Core\nimport { XYComponentCore } from 'core/xy-component'\n\n// Utils\nimport { getValue, isNumber, isNumberWithinRange } from 'utils/data'\nimport { rectIntersect } from 'utils/misc'\n\n// Local Types\nimport { XYLabelCluster, XYLabel, XYLabelPositioning } from './types'\n\n// Config\nimport { XYLabelsDefaultConfig, XYLabelsConfigInterface } from './config'\n\n// Modules\nimport { createLabels, updateLabels, removeLabels, getLabelRenderProps } from './modules/label'\n\n// Styles\nimport * as s from './style'\n\nexport class XYLabels<Datum> extends XYComponentCore<Datum, XYLabelsConfigInterface<Datum>> {\n static selectors = s\n clippable = false\n protected _defaultConfig = XYLabelsDefaultConfig as XYLabelsConfigInterface<Datum>\n public config: XYLabelsConfigInterface<Datum> = this._defaultConfig\n\n events = {\n [XYLabels.selectors.label]: {},\n }\n\n constructor (config?: XYLabelsConfigInterface<Datum>) {\n super()\n if (config) this.setConfig(config)\n }\n\n _render (customDuration?: number): void {\n const { config } = this\n const duration = isNumber(customDuration) ? customDuration : config.duration\n\n const labelGroups = this.g\n .selectAll<SVGGElement, XYLabel<Datum> | XYLabelCluster<Datum>>(`.${s.labelGroup}`)\n .data(this._getDataToRender())\n\n const labelGroupsExit = labelGroups.exit<XYLabel<Datum> | XYLabelCluster<Datum>>()\n removeLabels(labelGroupsExit, duration)\n\n const labelGroupsEnter = labelGroups.enter().append('g')\n .attr('class', s.labelGroup)\n .call(createLabels)\n\n const labelGroupsMerged = labelGroupsEnter\n .merge(labelGroups)\n .classed(s.cluster, d => !!(d as XYLabelCluster<Datum>).records)\n .classed(s.label, d => !(d as XYLabelCluster<Datum>).records)\n\n labelGroupsMerged.call(updateLabels, config, duration)\n }\n\n private _getDataToRender (): (XYLabel<Datum> | XYLabelCluster<Datum>)[] {\n const { config, datamodel } = this\n\n const xRange = this.xScale.range() as [number, number]\n const yRange = this.xScale.range() as [number, number]\n\n const labels = datamodel.data?.reduce<XYLabel<Datum>[]>((acc, d) => {\n const xPositioning = getValue<Datum, XYLabelPositioning>(d, config.xPositioning)\n const yPositioning = getValue<Datum, XYLabelPositioning>(d, config.yPositioning)\n const props = getLabelRenderProps(d, this.element, config, this.xScale, this.yScale)\n\n if (\n ((xPositioning !== XYLabelPositioning.DataSpace) || isNumberWithinRange(props.x, xRange)) &&\n ((yPositioning !== XYLabelPositioning.DataSpace) || isNumberWithinRange(props.y, yRange))\n ) {\n acc.push({ ...d, _screen: props })\n }\n\n return acc\n }, []) ?? []\n\n return this._getClusteredLabels(labels)\n }\n\n private _getClusteredLabels (labels: XYLabel<Datum>[]): (XYLabel<Datum> | XYLabelCluster<Datum>)[] {\n const labelsNonOverlapping = [...labels]\n const clusterMap = new Map<XYLabel<Datum>, XYLabel<Datum>[]>()\n for (let i = 0; i < labelsNonOverlapping.length; i += 1) {\n const label1 = labelsNonOverlapping[i]\n for (let j = i + 1; j < labelsNonOverlapping.length; j += 1) {\n const label2 = labelsNonOverlapping[j]\n const isIntersecting = rectIntersect(label1._screen, label2._screen)\n if (isIntersecting) {\n if (!clusterMap.has(label1)) clusterMap.set(label1, [label1])\n clusterMap.get(label1).push(label2)\n labelsNonOverlapping.splice(j, 1)\n j -= 1\n }\n }\n\n if (clusterMap.has(label1)) {\n labelsNonOverlapping.splice(i, 1)\n i -= 1\n }\n }\n\n const clusters = Array.from(clusterMap.values()).map(records => ({\n _screen: getLabelRenderProps(records, this.element, this.config, this.xScale, this.yScale),\n records,\n }))\n\n return [...labelsNonOverlapping, ...clusters]\n }\n}\n"],"names":["s.labelGroup","s.cluster","s.label","s"],"mappings":";;;;;;;;;AAAA;AAmBM,MAAO,QAAgB,SAAQ,eAAsD,CAAA;AAUzF,IAAA,WAAA,CAAa,MAAuC,EAAA;AAClD,QAAA,KAAK,EAA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O,GAAG,CAAA;AACZ,SAAC,EAAE,EAAE,CAAC,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAI,EAAE,CAAA;AAEZ,QAAA,OAAO,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAA;
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/xy-labels/index.ts"],"sourcesContent":["// Core\nimport { XYComponentCore } from 'core/xy-component'\n\n// Utils\nimport { getValue, isNumber, isNumberWithinRange } from 'utils/data'\nimport { rectIntersect } from 'utils/misc'\n\n// Local Types\nimport { XYLabelCluster, XYLabel, XYLabelPositioning } from './types'\n\n// Config\nimport { XYLabelsDefaultConfig, XYLabelsConfigInterface } from './config'\n\n// Modules\nimport { createLabels, updateLabels, removeLabels, getLabelRenderProps } from './modules/label'\n\n// Styles\nimport * as s from './style'\n\nexport class XYLabels<Datum> extends XYComponentCore<Datum, XYLabelsConfigInterface<Datum>> {\n static selectors = s\n clippable = false\n protected _defaultConfig = XYLabelsDefaultConfig as XYLabelsConfigInterface<Datum>\n public config: XYLabelsConfigInterface<Datum> = this._defaultConfig\n\n events = {\n [XYLabels.selectors.label]: {},\n }\n\n constructor (config?: XYLabelsConfigInterface<Datum>) {\n super()\n if (config) this.setConfig(config)\n }\n\n _render (customDuration?: number): void {\n const { config } = this\n const duration = isNumber(customDuration) ? customDuration : config.duration\n\n const labelGroups = this.g\n .selectAll<SVGGElement, XYLabel<Datum> | XYLabelCluster<Datum>>(`.${s.labelGroup}`)\n .data(this._getDataToRender())\n\n const labelGroupsExit = labelGroups.exit<XYLabel<Datum> | XYLabelCluster<Datum>>()\n removeLabels(labelGroupsExit, duration)\n\n const labelGroupsEnter = labelGroups.enter().append('g')\n .attr('class', s.labelGroup)\n .call(createLabels)\n\n const labelGroupsMerged = labelGroupsEnter\n .merge(labelGroups)\n .classed(s.cluster, d => !!(d as XYLabelCluster<Datum>).records)\n .classed(s.label, d => !(d as XYLabelCluster<Datum>).records)\n\n labelGroupsMerged.call(updateLabels, config, duration)\n }\n\n private _getDataToRender (): (XYLabel<Datum> | XYLabelCluster<Datum>)[] {\n const { config, datamodel } = this\n\n const xRange = this.xScale.range() as [number, number]\n const yRange = this.xScale.range() as [number, number]\n\n const labels = datamodel.data?.reduce<XYLabel<Datum>[]>((acc, d) => {\n const xPositioning = getValue<Datum, XYLabelPositioning>(d, config.xPositioning)\n const yPositioning = getValue<Datum, XYLabelPositioning>(d, config.yPositioning)\n const props = getLabelRenderProps(d, this.element, config, this.xScale, this.yScale)\n\n if (\n ((xPositioning !== XYLabelPositioning.DataSpace) || isNumberWithinRange(props.x, xRange)) &&\n ((yPositioning !== XYLabelPositioning.DataSpace) || isNumberWithinRange(props.y, yRange))\n ) {\n acc.push({ ...d, _screen: props })\n }\n\n return acc\n }, []) ?? []\n\n return config.clustering ? this._getClusteredLabels(labels) : labels\n }\n\n private _getClusteredLabels (labels: XYLabel<Datum>[]): (XYLabel<Datum> | XYLabelCluster<Datum>)[] {\n const labelsNonOverlapping = [...labels]\n const clusterMap = new Map<XYLabel<Datum>, XYLabel<Datum>[]>()\n for (let i = 0; i < labelsNonOverlapping.length; i += 1) {\n const label1 = labelsNonOverlapping[i]\n for (let j = i + 1; j < labelsNonOverlapping.length; j += 1) {\n const label2 = labelsNonOverlapping[j]\n const isIntersecting = rectIntersect(label1._screen, label2._screen)\n if (isIntersecting) {\n if (!clusterMap.has(label1)) clusterMap.set(label1, [label1])\n clusterMap.get(label1).push(label2)\n labelsNonOverlapping.splice(j, 1)\n j -= 1\n }\n }\n\n if (clusterMap.has(label1)) {\n labelsNonOverlapping.splice(i, 1)\n i -= 1\n }\n }\n\n const clusters = Array.from(clusterMap.values()).map(records => ({\n _screen: getLabelRenderProps(records, this.element, this.config, this.xScale, this.yScale),\n records,\n }))\n\n return [...labelsNonOverlapping, ...clusters]\n }\n}\n"],"names":["s.labelGroup","s.cluster","s.label","s"],"mappings":";;;;;;;;;AAAA;AAmBM,MAAO,QA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AC,CAAA;oBACjC,CAAC,IAAI,CAAC,CAAA;AACP,iBAAA;AACF,aAAA;AAED,YAAA,IAAI,UAAU,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;AAC1B,gBAAA,oBAAoB,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;gBACjC,CAAC,IAAI,CAAC,CAAA;AACP,aAAA;AACF,SAAA;AAED,QAAA,MAAM,QAAQ,GAAG,KAAK,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,CAAC,OAAO,KAAK;YAC/D,OAAO,EAAE,mBAAmB,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC;YAC1F,OAAO;AACR,SAAA,CAAC,CAAC,CAAA;AAEH,QAAA,OAAO,CAAC,GAAG,oBAAoB,EAAE,GAAG,QAAQ,CAAC,CAAA;KAC9C;;AAzFM,QAAS,CAAA,SAAA,GAAGC,KAAC;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ContainerDefaultConfig } from '../../core/container/config.js';
|
|
2
2
|
|
|
3
3
|
// Core
|
|
4
|
-
const SingleContainerDefaultConfig = Object.assign(Object.assign({}, ContainerDefaultConfig), { tooltip: undefined });
|
|
4
|
+
const SingleContainerDefaultConfig = Object.assign(Object.assign({}, ContainerDefaultConfig), { tooltip: undefined, annotations: undefined });
|
|
5
5
|
|
|
6
6
|
export { SingleContainerDefaultConfig };
|
|
7
7
|
//# sourceMappingURL=config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sources":["../../../src/containers/single-container/config.ts"],"sourcesContent":["// Core\nimport { ContainerDefaultConfig, ContainerConfigInterface } from 'core/container/config'\nimport { ComponentCore } from 'core/component'\nimport { Tooltip } from 'components/tooltip'\nimport { Annotations } from 'components/annotations'\n\nexport interface SingleContainerConfigInterface<Datum> extends ContainerConfigInterface {\n /** Visualization component. Default: `undefined` */\n component?: ComponentCore<Datum>;\n /** Tooltip component. Default: `undefined` */\n tooltip?: Tooltip;\n /** Annotations component. Default: `undefined` */\n annotations?: Annotations | undefined;\n}\n\nexport const SingleContainerDefaultConfig: SingleContainerConfigInterface<unknown> = {\n ...ContainerDefaultConfig,\n tooltip: undefined,\n}\n"],"names":[],"mappings":";;AAAA;
|
|
1
|
+
{"version":3,"file":"config.js","sources":["../../../src/containers/single-container/config.ts"],"sourcesContent":["// Core\nimport { ContainerDefaultConfig, ContainerConfigInterface } from 'core/container/config'\nimport { ComponentCore } from 'core/component'\nimport { Tooltip } from 'components/tooltip'\nimport { Annotations } from 'components/annotations'\n\nexport interface SingleContainerConfigInterface<Datum> extends ContainerConfigInterface {\n /** Visualization component. Default: `undefined` */\n component?: ComponentCore<Datum>;\n /** Tooltip component. Default: `undefined` */\n tooltip?: Tooltip;\n /** Annotations component. Default: `undefined` */\n annotations?: Annotations | undefined;\n}\n\nexport const SingleContainerDefaultConfig: SingleContainerConfigInterface<unknown> = {\n ...ContainerDefaultConfig,\n tooltip: undefined,\n annotations: undefined,\n}\n"],"names":[],"mappings":";;AAAA;AAeO,MAAM,4BAA4B,GAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EACpC,sBAAsB,CACzB,EAAA,EAAA,OAAO,EAAE,SAAS,EAClB,WAAW,EAAE,SAAS;;;;"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ContainerDefaultConfig } from '../../core/container/config.js';
|
|
2
2
|
import { Direction } from '../../types/direction.js';
|
|
3
3
|
|
|
4
|
-
const XYContainerDefaultConfig = Object.assign(Object.assign({}, ContainerDefaultConfig), { components: [], tooltip: undefined, crosshair: undefined, xAxis: undefined, yAxis: undefined, autoMargin: true, xScale: undefined, xDomain: undefined, xDomainMinConstraint: undefined, xDomainMaxConstraint: undefined, xRange: undefined, yScale: undefined, yDomain: undefined, yDomainMinConstraint: undefined, yDomainMaxConstraint: undefined, yRange: undefined, yDirection: Direction.North, preventEmptyDomain: null, scaleByDomain: false
|
|
4
|
+
const XYContainerDefaultConfig = Object.assign(Object.assign({}, ContainerDefaultConfig), { components: [], tooltip: undefined, crosshair: undefined, annotations: undefined, xAxis: undefined, yAxis: undefined, autoMargin: true, xScale: undefined, xDomain: undefined, xDomainMinConstraint: undefined, xDomainMaxConstraint: undefined, xRange: undefined, yScale: undefined, yDomain: undefined, yDomainMinConstraint: undefined, yDomainMaxConstraint: undefined, yRange: undefined, yDirection: Direction.North, preventEmptyDomain: null, scaleByDomain: false });
|
|
5
5
|
|
|
6
6
|
export { XYContainerDefaultConfig };
|
|
7
7
|
//# sourceMappingURL=config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sources":["../../../src/containers/xy-container/config.ts"],"sourcesContent":["// Core\nimport { XYComponentCore } from 'core/xy-component'\nimport { ContainerDefaultConfig, ContainerConfigInterface } from 'core/container/config'\n\n// Components\nimport { Annotations } from 'components/annotations'\nimport { Tooltip } from 'components/tooltip'\nimport { Axis } from 'components/axis'\nimport { Crosshair } from 'components/crosshair'\n\n// Types\nimport { ContinuousScale } from 'types/scale'\nimport { Direction } from 'types/direction'\n\nexport interface XYContainerConfigInterface<Datum> extends ContainerConfigInterface {\n /** An array of visualization components. Default: `[]` */\n components?: XYComponentCore<Datum>[];\n\n /** Scale for X dimension, e.g. Scale.scaleLinear().\n * If set, this value will override the components' xScale and they will have a single shared xScale instance.\n * By default the components have their own scale instances but their `domain` and `range` values are synchronized.\n * Default: `undefined` */\n xScale?: ContinuousScale;\n /** Scale domain (data extent) for X dimension. By default this value is calculated automatically based on data. */\n xDomain?: [number | undefined, number | undefined];\n /** Constraint the minimum value of the X scale domain. Useful when the data is plotted along the X axis.\n * For example, imagine that you have a chart with dynamic data that has negative values. When values are small\n * (let's say in the range of [-0.01, 0]), you might still want the chart to display some meaningful value range (e.g. [-1, 0]). That can\n * be achieved by setting `xDomainMinConstraint` to `[undefined, -1]`. In addition to that, if you want to cut off the\n * values that are too low (let's say lower than -100), you can set the constraint to `[-100, -1]`\n * Default: `undefined` */\n xDomainMinConstraint?: [number | undefined, number | undefined];\n /** Constraint the minimum value of the X scale domain. Useful when the data is plotted along the X axis.\n * For example, imagine that you have a chart with dynamic data. When values are small\n * (let's say < 0.01), you might still want the chart to display some meaningful value range (e.g. [0, 1]). That can\n * be achieved by setting `xDomainMaxConstraint` to `[1, undefined]`. In addition to that, if you want to cut off the\n * values that are too high (let's say higher than 100), you can set the constraint to `[1, 100]`\n * Default: `undefined` */\n xDomainMaxConstraint?: [number | undefined, number | undefined];\n /** Force set the X scale range (in the screen space). By default the range is calculated automatically based on the\n * chart's set up */\n xRange?: [number, number];\n\n /** Scale for Y dimension, e.g. Scale.scaleLinear().\n * If set, this value will override the components' yScale and they will have a single shared yScale instance.\n * By default the components have their own scale instances but their `domain` and `range` values are synchronized.\n * Default: `undefined` */\n yScale?: ContinuousScale;\n /** Scale domain (data extent) for Y dimension. By default this value is calculated automatically based on data. */\n yDomain?: [number | undefined, number | undefined];\n /** Constraint the minimum value of the Y scale domain.\n * For example, imagine that you have a chart with dynamic data that has negative values. When values are small\n * (let's say in the range of [-0.01, 0]), you might still want the chart to display some meaningful value range (e.g. [-1, 0]). That can\n * be achieved by setting `yDomainMinConstraint` to `[undefined, -1]`. In addition to that, if you want to cut off the\n * values that are too low (let's say lower than -100), you can set the constraint to `[-100, -1]`\n * Default: `undefined` */\n yDomainMinConstraint?: [number | undefined, number | undefined];\n /** Constraint the minimum value of the Y scale domain.\n * For example, imagine that you have a chart with dynamic data. When values are small\n * (let's say < 0.01), you might still want the chart to display some meaningful value range (e.g. [0, 1]). That can\n * be achieved by setting `yDomainMaxConstraint` to `[1, undefined]`. In addition to that, if you want to cut off the\n * values that are too high (let's say higher than 100), you can set the constraint to `[1, 100]`\n * Default: `undefined` */\n yDomainMaxConstraint?: [number | undefined, number | undefined];\n /** Force set the Y scale range (in the screen space). By default the range is calculated automatically based on the\n * chart's set up */\n yRange?: [number, number];\n /** Y Axis direction. Default: `Direction.North` */\n yDirection?: Direction.South | Direction.North | string;\n\n /** X Axis component instance. Default: `undefined` */\n xAxis?: Axis<Datum>;\n /** Y Axis component instance. Default: `undefined` */\n yAxis?: Axis<Datum>;\n /** Enables automatic calculation of chart margins based on the size of the axes. Default: `true` */\n autoMargin?: boolean;\n /** Tooltip component. Default: `undefined` */\n tooltip?: Tooltip | undefined;\n /** Crosshair component. Default: `undefined` */\n crosshair?: Crosshair<Datum> | undefined;\n /** Prevents the chart domain from being empty (when domain's min and max values are equal).\n * That usually happens when all the data values are equal or when there's no data.\n * Setting to `true` will automatically extend the domain by `+1` when the domain is empty (domain start equals domain end).\n * Setting to `null` will extend the empty X domain, but only when there's no data.\n * Setting to `false` will keep the domain as is.\n * Default: `null` */\n preventEmptyDomain?: boolean | null;\n /** Sets the Y scale domain based on the current X scale domain (not the whole dataset). Default: `false` */\n scaleByDomain?: boolean;\n /** Annotations component. Default: `undefined` */\n annotations?: Annotations | undefined;\n}\n\n\nexport const XYContainerDefaultConfig: XYContainerConfigInterface<unknown> = {\n ...ContainerDefaultConfig,\n components: [],\n tooltip: undefined,\n crosshair: undefined,\n xAxis: undefined,\n yAxis: undefined,\n autoMargin: true,\n\n xScale: undefined,\n xDomain: undefined,\n xDomainMinConstraint: undefined,\n xDomainMaxConstraint: undefined,\n xRange: undefined,\n\n yScale: undefined,\n yDomain: undefined,\n yDomainMinConstraint: undefined,\n yDomainMaxConstraint: undefined,\n yRange: undefined,\n yDirection: Direction.North,\n\n preventEmptyDomain: null,\n scaleByDomain: false,\n
|
|
1
|
+
{"version":3,"file":"config.js","sources":["../../../src/containers/xy-container/config.ts"],"sourcesContent":["// Core\nimport { XYComponentCore } from 'core/xy-component'\nimport { ContainerDefaultConfig, ContainerConfigInterface } from 'core/container/config'\n\n// Components\nimport { Annotations } from 'components/annotations'\nimport { Tooltip } from 'components/tooltip'\nimport { Axis } from 'components/axis'\nimport { Crosshair } from 'components/crosshair'\n\n// Types\nimport { ContinuousScale } from 'types/scale'\nimport { Direction } from 'types/direction'\n\nexport interface XYContainerConfigInterface<Datum> extends ContainerConfigInterface {\n /** An array of visualization components. Default: `[]` */\n components?: XYComponentCore<Datum>[];\n\n /** Scale for X dimension, e.g. Scale.scaleLinear().\n * If set, this value will override the components' xScale and they will have a single shared xScale instance.\n * By default the components have their own scale instances but their `domain` and `range` values are synchronized.\n * Default: `undefined` */\n xScale?: ContinuousScale;\n /** Scale domain (data extent) for X dimension. By default this value is calculated automatically based on data. */\n xDomain?: [number | undefined, number | undefined];\n /** Constraint the minimum value of the X scale domain. Useful when the data is plotted along the X axis.\n * For example, imagine that you have a chart with dynamic data that has negative values. When values are small\n * (let's say in the range of [-0.01, 0]), you might still want the chart to display some meaningful value range (e.g. [-1, 0]). That can\n * be achieved by setting `xDomainMinConstraint` to `[undefined, -1]`. In addition to that, if you want to cut off the\n * values that are too low (let's say lower than -100), you can set the constraint to `[-100, -1]`\n * Default: `undefined` */\n xDomainMinConstraint?: [number | undefined, number | undefined];\n /** Constraint the minimum value of the X scale domain. Useful when the data is plotted along the X axis.\n * For example, imagine that you have a chart with dynamic data. When values are small\n * (let's say < 0.01), you might still want the chart to display some meaningful value range (e.g. [0, 1]). That can\n * be achieved by setting `xDomainMaxConstraint` to `[1, undefined]`. In addition to that, if you want to cut off the\n * values that are too high (let's say higher than 100), you can set the constraint to `[1, 100]`\n * Default: `undefined` */\n xDomainMaxConstraint?: [number | undefined, number | undefined];\n /** Force set the X scale range (in the screen space). By default the range is calculated automatically based on the\n * chart's set up */\n xRange?: [number, number];\n\n /** Scale for Y dimension, e.g. Scale.scaleLinear().\n * If set, this value will override the components' yScale and they will have a single shared yScale instance.\n * By default the components have their own scale instances but their `domain` and `range` values are synchronized.\n * Default: `undefined` */\n yScale?: ContinuousScale;\n /** Scale domain (data extent) for Y dimension. By default this value is calculated automatically based on data. */\n yDomain?: [number | undefined, number | undefined];\n /** Constraint the minimum value of the Y scale domain.\n * For example, imagine that you have a chart with dynamic data that has negative values. When values are small\n * (let's say in the range of [-0.01, 0]), you might still want the chart to display some meaningful value range (e.g. [-1, 0]). That can\n * be achieved by setting `yDomainMinConstraint` to `[undefined, -1]`. In addition to that, if you want to cut off the\n * values that are too low (let's say lower than -100), you can set the constraint to `[-100, -1]`\n * Default: `undefined` */\n yDomainMinConstraint?: [number | undefined, number | undefined];\n /** Constraint the minimum value of the Y scale domain.\n * For example, imagine that you have a chart with dynamic data. When values are small\n * (let's say < 0.01), you might still want the chart to display some meaningful value range (e.g. [0, 1]). That can\n * be achieved by setting `yDomainMaxConstraint` to `[1, undefined]`. In addition to that, if you want to cut off the\n * values that are too high (let's say higher than 100), you can set the constraint to `[1, 100]`\n * Default: `undefined` */\n yDomainMaxConstraint?: [number | undefined, number | undefined];\n /** Force set the Y scale range (in the screen space). By default the range is calculated automatically based on the\n * chart's set up */\n yRange?: [number, number];\n /** Y Axis direction. Default: `Direction.North` */\n yDirection?: Direction.South | Direction.North | string;\n\n /** X Axis component instance. Default: `undefined` */\n xAxis?: Axis<Datum>;\n /** Y Axis component instance. Default: `undefined` */\n yAxis?: Axis<Datum>;\n /** Enables automatic calculation of chart margins based on the size of the axes. Default: `true` */\n autoMargin?: boolean;\n /** Tooltip component. Default: `undefined` */\n tooltip?: Tooltip | undefined;\n /** Crosshair component. Default: `undefined` */\n crosshair?: Crosshair<Datum> | undefined;\n /** Prevents the chart domain from being empty (when domain's min and max values are equal).\n * That usually happens when all the data values are equal or when there's no data.\n * Setting to `true` will automatically extend the domain by `+1` when the domain is empty (domain start equals domain end).\n * Setting to `null` will extend the empty X domain, but only when there's no data.\n * Setting to `false` will keep the domain as is.\n * Default: `null` */\n preventEmptyDomain?: boolean | null;\n /** Sets the Y scale domain based on the current X scale domain (not the whole dataset). Default: `false` */\n scaleByDomain?: boolean;\n /** Annotations component. Default: `undefined` */\n annotations?: Annotations | undefined;\n}\n\n\nexport const XYContainerDefaultConfig: XYContainerConfigInterface<unknown> = {\n ...ContainerDefaultConfig,\n components: [],\n tooltip: undefined,\n crosshair: undefined,\n annotations: undefined,\n xAxis: undefined,\n yAxis: undefined,\n autoMargin: true,\n\n xScale: undefined,\n xDomain: undefined,\n xDomainMinConstraint: undefined,\n xDomainMaxConstraint: undefined,\n xRange: undefined,\n\n yScale: undefined,\n yDomain: undefined,\n yDomainMinConstraint: undefined,\n yDomainMaxConstraint: undefined,\n yRange: undefined,\n yDirection: Direction.North,\n\n preventEmptyDomain: null,\n scaleByDomain: false,\n}\n\n"],"names":[],"mappings":";;;AA8Fa,MAAA,wBAAwB,mCAChC,sBAAsB,CAAA,EAAA,EACzB,UAAU,EAAE,EAAE,EACd,OAAO,EAAE,SAAS,EAClB,SAAS,EAAE,SAAS,EACpB,WAAW,EAAE,SAAS,EACtB,KAAK,EAAE,SAAS,EAChB,KAAK,EAAE,SAAS,EAChB,UAAU,EAAE,IAAI,EAEhB,MAAM,EAAE,SAAS,EACjB,OAAO,EAAE,SAAS,EAClB,oBAAoB,EAAE,SAAS,EAC/B,oBAAoB,EAAE,SAAS,EAC/B,MAAM,EAAE,SAAS,EAEjB,MAAM,EAAE,SAAS,EACjB,OAAO,EAAE,SAAS,EAClB,oBAAoB,EAAE,SAAS,EAC/B,oBAAoB,EAAE,SAAS,EAC/B,MAAM,EAAE,SAAS,EACjB,UAAU,EAAE,SAAS,CAAC,KAAK,EAE3B,kBAAkB,EAAE,IAAI,EACxB,aAAa,EAAE,KAAK;;;;"}
|