@unovis/ts 1.6.0-pre.1 → 1.6.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.
Files changed (169) hide show
  1. package/components/area/index.js +2 -1
  2. package/components/area/index.js.map +1 -1
  3. package/components/axis/config.d.ts +4 -0
  4. package/components/axis/config.js +2 -2
  5. package/components/axis/config.js.map +1 -1
  6. package/components/axis/index.d.ts +0 -1
  7. package/components/axis/index.js +51 -19
  8. package/components/axis/index.js.map +1 -1
  9. package/components/axis/style.d.ts +40 -1
  10. package/components/axis/style.js +34 -35
  11. package/components/axis/style.js.map +1 -1
  12. package/components/brush/config.d.ts +1 -1
  13. package/components/brush/config.js.map +1 -1
  14. package/components/bullet-legend/config.d.ts +2 -0
  15. package/components/bullet-legend/config.js +1 -0
  16. package/components/bullet-legend/config.js.map +1 -1
  17. package/components/bullet-legend/index.js +10 -2
  18. package/components/bullet-legend/index.js.map +1 -1
  19. package/components/bullet-legend/modules/shape.d.ts +1 -0
  20. package/components/bullet-legend/modules/shape.js +61 -41
  21. package/components/bullet-legend/modules/shape.js.map +1 -1
  22. package/components/bullet-legend/types.d.ts +1 -1
  23. package/components/bullet-legend/types.js.map +1 -1
  24. package/components/crosshair/config.d.ts +20 -7
  25. package/components/crosshair/config.js +1 -1
  26. package/components/crosshair/config.js.map +1 -1
  27. package/components/crosshair/index.d.ts +8 -7
  28. package/components/crosshair/index.js +144 -72
  29. package/components/crosshair/index.js.map +1 -1
  30. package/components/graph/config.d.ts +8 -0
  31. package/components/graph/config.js +1 -1
  32. package/components/graph/config.js.map +1 -1
  33. package/components/graph/index.d.ts +1 -0
  34. package/components/graph/index.js +14 -9
  35. package/components/graph/index.js.map +1 -1
  36. package/components/graph/modules/layout.js +33 -31
  37. package/components/graph/modules/layout.js.map +1 -1
  38. package/components/graph/modules/link/index.js +1 -1
  39. package/components/graph/modules/link/index.js.map +1 -1
  40. package/components/graph/types.d.ts +2 -1
  41. package/components/graph/types.js.map +1 -1
  42. package/components/nested-donut/config.d.ts +1 -1
  43. package/components/nested-donut/config.js.map +1 -1
  44. package/components/plotband/config.d.ts +59 -0
  45. package/components/plotband/config.js +9 -0
  46. package/components/plotband/config.js.map +1 -0
  47. package/components/plotband/constants.d.ts +5 -0
  48. package/components/plotband/constants.js +413 -0
  49. package/components/plotband/constants.js.map +1 -0
  50. package/components/plotband/index.d.ts +15 -0
  51. package/components/plotband/index.js +92 -0
  52. package/components/plotband/index.js.map +1 -0
  53. package/components/plotband/style.d.ts +4 -0
  54. package/components/plotband/style.js +38 -0
  55. package/components/plotband/style.js.map +1 -0
  56. package/components/plotband/types.d.ts +51 -0
  57. package/components/plotband/types.js +27 -0
  58. package/components/plotband/types.js.map +1 -0
  59. package/components/plotline/config.d.ts +91 -0
  60. package/components/plotline/config.js +9 -0
  61. package/components/plotline/config.js.map +1 -0
  62. package/components/plotline/constants.d.ts +6 -0
  63. package/components/plotline/constants.js +58 -0
  64. package/components/plotline/constants.js.map +1 -0
  65. package/components/plotline/index.d.ts +14 -0
  66. package/components/plotline/index.js +102 -0
  67. package/components/plotline/index.js.map +1 -0
  68. package/components/plotline/style.d.ts +4 -0
  69. package/components/plotline/style.js +42 -0
  70. package/components/plotline/style.js.map +1 -0
  71. package/components/plotline/types.d.ts +53 -0
  72. package/components/plotline/types.js +33 -0
  73. package/components/plotline/types.js.map +1 -0
  74. package/components/rolling-pin-legend/config.d.ts +19 -0
  75. package/components/rolling-pin-legend/config.js +11 -0
  76. package/components/rolling-pin-legend/config.js.map +1 -0
  77. package/components/rolling-pin-legend/index.d.ts +16 -0
  78. package/components/rolling-pin-legend/index.js +69 -0
  79. package/components/rolling-pin-legend/index.js.map +1 -0
  80. package/components/rolling-pin-legend/style.d.ts +22 -0
  81. package/components/rolling-pin-legend/style.js +39 -0
  82. package/components/rolling-pin-legend/style.js.map +1 -0
  83. package/components/rolling-pin-legend/types.d.ts +1 -0
  84. package/components/rolling-pin-legend/types.js +2 -0
  85. package/components/rolling-pin-legend/types.js.map +1 -0
  86. package/components/scatter/index.d.ts +1 -0
  87. package/components/scatter/index.js +11 -1
  88. package/components/scatter/index.js.map +1 -1
  89. package/components/timeline/config.d.ts +65 -14
  90. package/components/timeline/config.js +15 -1
  91. package/components/timeline/config.js.map +1 -1
  92. package/components/timeline/constants.d.ts +3 -0
  93. package/components/timeline/constants.js +6 -0
  94. package/components/timeline/constants.js.map +1 -0
  95. package/components/timeline/index.d.ts +21 -10
  96. package/components/timeline/index.js +380 -95
  97. package/components/timeline/index.js.map +1 -1
  98. package/components/timeline/style.d.ts +7 -0
  99. package/components/timeline/style.js +40 -1
  100. package/components/timeline/style.js.map +1 -1
  101. package/components/timeline/types.d.ts +62 -0
  102. package/components/timeline/types.js +2 -0
  103. package/components/timeline/types.js.map +1 -0
  104. package/components/timeline/utils.d.ts +2 -0
  105. package/components/timeline/utils.js +16 -0
  106. package/components/timeline/utils.js.map +1 -0
  107. package/components/tooltip/index.js +4 -3
  108. package/components/tooltip/index.js.map +1 -1
  109. package/components/treemap/config.d.ts +52 -0
  110. package/components/treemap/config.js +6 -0
  111. package/components/treemap/config.js.map +1 -0
  112. package/components/treemap/index.d.ts +18 -0
  113. package/components/treemap/index.js +274 -0
  114. package/components/treemap/index.js.map +1 -0
  115. package/components/treemap/style.d.ts +25 -0
  116. package/components/treemap/style.js +69 -0
  117. package/components/treemap/style.js.map +1 -0
  118. package/components/treemap/types.d.ts +11 -0
  119. package/components/treemap/types.js +2 -0
  120. package/components/treemap/types.js.map +1 -0
  121. package/components/xy-labels/index.js +1 -1
  122. package/components/xy-labels/index.js.map +1 -1
  123. package/components.d.ts +10 -2
  124. package/components.js +4 -0
  125. package/components.js.map +1 -1
  126. package/containers/single-container/index.js +3 -1
  127. package/containers/single-container/index.js.map +1 -1
  128. package/containers/xy-container/config.d.ts +2 -0
  129. package/containers/xy-container/config.js +1 -1
  130. package/containers/xy-container/config.js.map +1 -1
  131. package/containers/xy-container/index.js +17 -7
  132. package/containers/xy-container/index.js.map +1 -1
  133. package/core/component/index.d.ts +4 -0
  134. package/core/component/index.js +6 -0
  135. package/core/component/index.js.map +1 -1
  136. package/core/xy-component/index.d.ts +1 -0
  137. package/core/xy-component/index.js +3 -1
  138. package/core/xy-component/index.js.map +1 -1
  139. package/data-models/graph.js +7 -1
  140. package/data-models/graph.js.map +1 -1
  141. package/index.js +10 -3
  142. package/index.js.map +1 -1
  143. package/package.json +2 -2
  144. package/styles/index.js +1 -0
  145. package/styles/index.js.map +1 -1
  146. package/types/data.d.ts +5 -0
  147. package/types/data.js +7 -0
  148. package/types/data.js.map +1 -1
  149. package/types/position.d.ts +2 -1
  150. package/types/position.js +1 -0
  151. package/types/position.js.map +1 -1
  152. package/types/text.d.ts +1 -1
  153. package/types/text.js.map +1 -1
  154. package/types.d.ts +5 -0
  155. package/types.js +6 -1
  156. package/types.js.map +1 -1
  157. package/utils/color.d.ts +7 -0
  158. package/utils/color.js +14 -2
  159. package/utils/color.js.map +1 -1
  160. package/utils/data.d.ts +4 -4
  161. package/utils/data.js +41 -10
  162. package/utils/data.js.map +1 -1
  163. package/utils/index.js +3 -3
  164. package/utils/path.d.ts +8 -0
  165. package/utils/path.js +109 -1
  166. package/utils/path.js.map +1 -1
  167. package/utils/text.d.ts +3 -2
  168. package/utils/text.js +22 -10
  169. package/utils/text.js.map +1 -1
@@ -5,6 +5,7 @@ import { isArray, isNumber, getNearest, clamp, getNumber, isFunction, getStacked
5
5
  import { smartTransition } from '../../utils/d3.js';
6
6
  import { getColor } from '../../utils/color.js';
7
7
  import { Position } from '../../types/position.js';
8
+ import { FindNearestDirection } from '../../types/data.js';
8
9
  import { CrosshairDefaultConfig } from './config.js';
9
10
  import * as style from './style.js';
10
11
  import { line, circle } from './style.js';
@@ -15,8 +16,9 @@ class Crosshair extends XYComponentCore {
15
16
  this.clippable = true; // Don't apply clipping path to this component. See XYContainer
16
17
  this._defaultConfig = CrosshairDefaultConfig;
17
18
  this.config = this._defaultConfig;
18
- this.x = 0;
19
- this.show = false;
19
+ this._xPx = undefined;
20
+ this._yPx = undefined;
21
+ this._mouseEvent = undefined;
20
22
  this._animFrameId = null;
21
23
  /** Accessors passed externally (e.g. from XYContainer) */
22
24
  this._accessors = {
@@ -27,7 +29,7 @@ class Crosshair extends XYComponentCore {
27
29
  };
28
30
  if (config)
29
31
  this.setConfig(config);
30
- this.g.style('opacity', this.show ? 1 : 0);
32
+ this.g.style('opacity', 0);
31
33
  this.line = this.g.append('line')
32
34
  .attr('class', line);
33
35
  }
@@ -43,26 +45,106 @@ class Crosshair extends XYComponentCore {
43
45
  const baseline = (_a = config.baseline) !== null && _a !== void 0 ? _a : this._accessors.baseline;
44
46
  return { x, y, yStacked, baseline };
45
47
  }
48
+ _isContainerInViewport() {
49
+ var _a;
50
+ if (!((_a = this.container) === null || _a === void 0 ? void 0 : _a.node()))
51
+ return false;
52
+ const containerRect = this.container.node().getBoundingClientRect();
53
+ const viewportWidth = window.innerWidth || document.documentElement.clientWidth;
54
+ const viewportHeight = window.innerHeight || document.documentElement.clientHeight;
55
+ // Calculate the visible area of the container
56
+ const visibleWidth = Math.max(0, Math.min(containerRect.right, viewportWidth) - Math.max(containerRect.left, 0));
57
+ const visibleHeight = Math.max(0, Math.min(containerRect.bottom, viewportHeight) - Math.max(containerRect.top, 0));
58
+ const containerArea = containerRect.width * containerRect.height;
59
+ const visibleArea = visibleWidth * visibleHeight;
60
+ // Container must be at least 35% visible
61
+ return containerArea > 0 && (visibleArea / containerArea) >= 0.35;
62
+ }
46
63
  setContainer(containerSvg) {
47
- // Set up mousemove event for Crosshair
64
+ if (this.container === containerSvg)
65
+ return;
48
66
  this.container = containerSvg;
49
67
  this.container.on('mousemove.crosshair', this._onMouseMove.bind(this));
50
68
  this.container.on('mouseout.crosshair', this._onMouseOut.bind(this));
69
+ this.container.on('wheel.crosshair', this._onWheel.bind(this));
51
70
  }
52
71
  _render(customDuration) {
53
- const { config } = this;
54
- if (config.snapToData && !this.datum)
55
- return;
72
+ var _a, _b, _c, _d, _e;
73
+ const { config, datamodel } = this;
56
74
  const duration = isNumber(customDuration) ? customDuration : config.duration;
75
+ const isForceShowAtDefined = config.forceShowAt !== undefined;
76
+ const xPx = isForceShowAtDefined ? this.xScale(config.forceShowAt) : this._xPx;
77
+ const xValue = this.xScale.invert(xPx);
78
+ const leftNearestDatumIndex = (((_a = datamodel.data) === null || _a === void 0 ? void 0 : _a.length) && this.accessors.x)
79
+ ? datamodel.data.indexOf(getNearest(datamodel.data, xValue, this.accessors.x, FindNearestDirection.Left)) : undefined;
80
+ // If `snapToData` is `true`, we need to find the nearest datum to the crosshair
81
+ // It can be from a mouse interaction or from a `forceShowAt` setting
82
+ let nearestDatum;
83
+ let nearestDatumIndex;
84
+ if (config.snapToData) {
85
+ if (!this.accessors.y && !this.accessors.yStacked && ((_b = datamodel.data) === null || _b === void 0 ? void 0 : _b.length)) {
86
+ console.warn('Unovis | Crosshair: Y accessors have not been configured. Please check if they\'re present in the configuration object');
87
+ }
88
+ // Emit a warning if there's no data to snap to.
89
+ // To keep the console clean, only emit the warning when there's mouse interaction.
90
+ if (!((_c = datamodel.data) === null || _c === void 0 ? void 0 : _c.length) && this._mouseEvent) {
91
+ console.warn('Unovis | Crosshair: No data to snap to. Make sure the data has been passed to the container or to the crosshair itself');
92
+ }
93
+ nearestDatum = getNearest(datamodel.data, xValue, this.accessors.x);
94
+ nearestDatumIndex = datamodel.data.indexOf(nearestDatum);
95
+ }
96
+ const xRange = this.xScale.range();
97
+ const yRange = this.yScale.range();
98
+ const xClamped = config.snapToData && nearestDatum
99
+ ? clamp(Math.round(this.xScale(getNumber(nearestDatum, this.accessors.x, nearestDatumIndex))), 0, this._width)
100
+ : clamp(xPx, xRange[0], xRange[1]);
101
+ const isCrosshairWithinXRange = (xPx >= xRange[0]) && (xPx <= xRange[1]);
102
+ const isCrosshairWithinYRange = (this._yPx >= yRange[1]) && (this._yPx <= yRange[0]);
103
+ let shouldShow = this._xPx ? isCrosshairWithinXRange && isCrosshairWithinYRange : isCrosshairWithinXRange;
104
+ // If the crosshair is far from the mouse pointer (usually when `snapToData` is `true` and data resolution is low), hide it
105
+ if (config.hideWhenFarFromPointer && ((Math.abs(xClamped - (+xPx)) >= config.hideWhenFarFromPointerDistance))) {
106
+ shouldShow = false;
107
+ }
108
+ const tooltip = (_d = config.tooltip) !== null && _d !== void 0 ? _d : this.tooltip;
109
+ if (shouldShow && tooltip && this._isContainerInViewport()) {
110
+ const container = tooltip.getContainer() || this.container.node();
111
+ const isContainerBody = tooltip.isContainerBody();
112
+ if (isForceShowAtDefined) {
113
+ // Convert SVG coordinates to screen coordinates
114
+ const containerRect = this.container.node().getBoundingClientRect();
115
+ // Use the actual left margin from the container
116
+ const screenX = (isContainerBody ? xPx + containerRect.left : xPx) + this._containerMargin.left;
117
+ const screenY = this._height / 2 + (isContainerBody ? containerRect.top : 0);
118
+ const pos = [screenX, screenY];
119
+ this._showTooltip(nearestDatum, xValue, pos, leftNearestDatumIndex);
120
+ }
121
+ else if (this._mouseEvent) {
122
+ const pos = (isContainerBody ? [this._mouseEvent.clientX, this._mouseEvent.clientY] : pointer(this._mouseEvent, container));
123
+ this._showTooltip(nearestDatum, xValue, pos, leftNearestDatumIndex);
124
+ }
125
+ }
126
+ else
127
+ this._hideTooltip();
128
+ // Trigger `onCrosshairMove` if the render was triggered by a mouse move event
129
+ if (this._mouseEvent) {
130
+ (_e = config.onCrosshairMove) === null || _e === void 0 ? void 0 : _e.call(config, shouldShow ? this.xScale.invert(this._xPx) : undefined, nearestDatum, nearestDatumIndex, this._mouseEvent);
131
+ this._mouseEvent = undefined;
132
+ }
57
133
  smartTransition(this.g, duration)
58
- .style('opacity', this.show ? 1 : 0);
134
+ .style('opacity', shouldShow ? 1 : 0);
135
+ // When `config.forceShowAt` becomes `undefined`, the crosshair "jumps" to the edge of the chart.
136
+ // This looks off, so we stop further rendering when the `xPx` value is not finite.
137
+ if (!isFinite(xPx))
138
+ return;
59
139
  this.line
60
140
  .attr('y1', 0)
61
- .attr('y1', this._height);
141
+ .attr('y2', this._height);
62
142
  smartTransition(this.line, duration, easeLinear)
63
- .attr('x1', this.x)
64
- .attr('x2', this.x);
65
- const circleData = this.getCircleData();
143
+ .attr('x1', xClamped)
144
+ .attr('x2', xClamped);
145
+ const circleData = isFunction(config.getCircles)
146
+ ? config.getCircles(xValue, datamodel.data, this.yScale, leftNearestDatumIndex)
147
+ : this.getCircleData(nearestDatum, nearestDatumIndex);
66
148
  const circles = this.g
67
149
  .selectAll('circle')
68
150
  .data(circleData, (d, i) => { var _a; return (_a = d.id) !== null && _a !== void 0 ? _a : i; });
@@ -70,13 +152,13 @@ class Crosshair extends XYComponentCore {
70
152
  .append('circle')
71
153
  .attr('class', circle)
72
154
  .attr('r', 0)
73
- .attr('cx', this.x)
155
+ .attr('cx', xClamped)
74
156
  .attr('cy', d => d.y)
75
157
  .style('fill', d => d.color)
76
158
  .style('stroke', d => d.strokeColor)
77
159
  .style('stroke-width', d => d.strokeWidth);
78
160
  smartTransition(circlesEnter.merge(circles), duration, easeLinear)
79
- .attr('cx', this.x)
161
+ .attr('cx', xClamped)
80
162
  .attr('cy', d => d.y)
81
163
  .attr('r', 4)
82
164
  .style('opacity', d => d.opacity)
@@ -85,62 +167,54 @@ class Crosshair extends XYComponentCore {
85
167
  .style('stroke-width', d => d.strokeWidth);
86
168
  circles.exit().remove();
87
169
  }
88
- hide() {
89
- this._onMouseOut();
170
+ hide(sourceEvent) {
171
+ window.cancelAnimationFrame(this._animFrameId);
172
+ this._animFrameId = window.requestAnimationFrame(() => {
173
+ var _a, _b;
174
+ this._xPx = undefined;
175
+ this._yPx = undefined;
176
+ this._mouseEvent = undefined;
177
+ // We call `onCrosshairMove` with all the arguments set to `undefined` because we want
178
+ // the users to be able to hide the crosshair easily when using `forceShowAt`
179
+ (_b = (_a = this.config).onCrosshairMove) === null || _b === void 0 ? void 0 : _b.call(_a, undefined, undefined, undefined, sourceEvent);
180
+ this._render();
181
+ });
90
182
  }
91
183
  _onMouseMove(event) {
92
- var _a, _b;
93
- const { config, datamodel, element } = this;
184
+ var _a;
185
+ const { datamodel, element } = this;
94
186
  if (!this.accessors.x && ((_a = datamodel.data) === null || _a === void 0 ? void 0 : _a.length)) {
95
187
  console.warn('Unovis | Crosshair: X accessor function has not been configured. Please check if it\'s present in the configuration object');
96
188
  }
97
- const [x] = pointer(event, element);
98
- const xRange = this.xScale.range();
99
- if (config.snapToData) {
100
- if (!this.accessors.y && !this.accessors.yStacked && ((_b = datamodel.data) === null || _b === void 0 ? void 0 : _b.length)) {
101
- console.warn('Unovis | Crosshair: Y accessors have not been configured. Please check if they\'re present in the configuration object');
102
- }
103
- const scaleX = this.xScale;
104
- const valueX = scaleX.invert(x);
105
- this.datum = getNearest(datamodel.data, valueX, this.accessors.x);
106
- this.datumIndex = datamodel.data.indexOf(this.datum);
107
- if (!this.datum)
108
- return;
109
- this.x = clamp(Math.round(scaleX(getNumber(this.datum, this.accessors.x, this.datumIndex))), 0, this._width);
110
- // Show the crosshair only if it's in the chart range and not far from mouse pointer (if configured)
111
- this.show = (this.x >= 0) && (this.x <= this._width) && (!config.hideWhenFarFromPointer || (Math.abs(this.x - x) < config.hideWhenFarFromPointerDistance));
112
- }
113
- else {
114
- const tolerance = 2; // Show the crosshair when it is at least 2 pixels close to the chart area
115
- this.x = clamp(x, xRange[0], xRange[1]);
116
- this.show = (x >= (xRange[0] - tolerance)) && (x <= (xRange[1] + tolerance));
117
- }
189
+ const [x, y] = pointer(event, element);
190
+ this._xPx = x;
191
+ this._yPx = y;
192
+ this._mouseEvent = event;
118
193
  window.cancelAnimationFrame(this._animFrameId);
119
194
  this._animFrameId = window.requestAnimationFrame(() => {
195
+ // We'll call `config.onCrosshairMove` in `_render` with the found `nearestDatum` and `nearestDatumIndex`,
196
+ // which can come from the mouse interaction or from the `forceShowAt` setting
120
197
  this._render();
121
198
  });
122
- if (this.show)
123
- this._showTooltip(event);
124
- else
125
- this._hideTooltip();
126
199
  }
127
- _onMouseOut() {
128
- this.show = false;
129
- window.cancelAnimationFrame(this._animFrameId);
130
- this._animFrameId = window.requestAnimationFrame(() => {
131
- this._render();
132
- });
133
- this._hideTooltip();
200
+ _onMouseOut(event) {
201
+ var _a;
202
+ // Only hide if the mouse actually left the SVG, not just moved to a child
203
+ if (!event || !((_a = this.container) === null || _a === void 0 ? void 0 : _a.node().contains(event.relatedTarget))) {
204
+ this.hide(event);
205
+ }
206
+ }
207
+ _onWheel(event) {
208
+ this.hide(event);
134
209
  }
135
- _showTooltip(event) {
210
+ _showTooltip(datum, xValue, pos, nearestDatumIndex) {
136
211
  var _a;
137
- const { config } = this;
212
+ const { config, datamodel } = this;
138
213
  const tooltip = (_a = config.tooltip) !== null && _a !== void 0 ? _a : this.tooltip;
139
- if (!tooltip)
214
+ if (!tooltip || !pos)
140
215
  return;
141
- const container = tooltip.getContainer() || this.container.node();
142
- const [x, y] = tooltip.isContainerBody() ? [event.clientX, event.clientY] : pointer(event, container);
143
- const content = config.template(this.datum, this.xScale.invert(this.x));
216
+ const [x, y] = pos;
217
+ const content = config.template(datum, xValue, datamodel.data, nearestDatumIndex);
144
218
  // Force set `followCursor` to `true` because we don't want Crosshair's tooltip to be hoverable
145
219
  tooltip.config.followCursor = true;
146
220
  // Set tooltip placement based on Crosshair's position (left / right)
@@ -161,32 +235,30 @@ class Crosshair extends XYComponentCore {
161
235
  getYDataExtent() {
162
236
  return [undefined, undefined];
163
237
  }
164
- getCircleData() {
238
+ getCircleData(datum, datumIndex) {
165
239
  var _a, _b;
166
- const { config, datamodel: { data } } = this;
167
- if (isFunction(config.getCircles))
168
- return config.getCircles(this.xScale.invert(this.x), data, this.yScale);
169
- if (config.snapToData && this.datum) {
240
+ const { config } = this;
241
+ if (config.snapToData && datum) {
170
242
  const yAccessors = (_a = this.accessors.y) !== null && _a !== void 0 ? _a : [];
171
243
  const yStackedAccessors = (_b = this.accessors.yStacked) !== null && _b !== void 0 ? _b : [];
172
- const baselineValue = getNumber(this.datum, this.accessors.baseline, this.datumIndex) || 0;
173
- const stackedValues = getStackedValues(this.datum, this.datumIndex, ...yStackedAccessors)
174
- .map((value, index, arr) => ({
244
+ const baselineValue = getNumber(datum, this.accessors.baseline, datumIndex) || 0;
245
+ const stackedValues = getStackedValues(datum, datumIndex, ...yStackedAccessors)
246
+ .map((value, index) => ({
175
247
  y: this.yScale(value + baselineValue),
176
- opacity: isNumber(getNumber(this.datum, yStackedAccessors[index])) ? 1 : 0,
177
- color: getColor(this.datum, config.color, index),
178
- strokeColor: config.strokeColor ? getColor(this.datum, config.strokeColor, index) : undefined,
179
- strokeWidth: config.strokeWidth ? getNumber(this.datum, config.strokeWidth, index) : undefined,
248
+ opacity: isNumber(getNumber(datum, yStackedAccessors[index], index)) ? 1 : 0,
249
+ color: getColor(datum, config.color, index),
250
+ strokeColor: config.strokeColor ? getColor(datum, config.strokeColor, index) : undefined,
251
+ strokeWidth: config.strokeWidth ? getNumber(datum, config.strokeWidth, index) : undefined,
180
252
  }));
181
253
  const regularValues = yAccessors
182
254
  .map((a, index) => {
183
- const value = getNumber(this.datum, a);
255
+ const value = getNumber(datum, a, datumIndex);
184
256
  return {
185
257
  y: this.yScale(value),
186
258
  opacity: isNumber(value) ? 1 : 0,
187
- color: getColor(this.datum, config.color, stackedValues.length + index),
188
- strokeColor: config.strokeColor ? getColor(this.datum, config.strokeColor, index) : undefined,
189
- strokeWidth: config.strokeWidth ? getNumber(this.datum, config.strokeWidth, index) : undefined,
259
+ color: getColor(datum, config.color, stackedValues.length + index),
260
+ strokeColor: config.strokeColor ? getColor(datum, config.strokeColor, index) : undefined,
261
+ strokeWidth: config.strokeWidth ? getNumber(datum, config.strokeWidth, index) : undefined,
190
262
  };
191
263
  });
192
264
  return stackedValues.concat(regularValues);
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../../src/components/crosshair/index.ts"],"sourcesContent":["import { Selection, pointer } from 'd3-selection'\nimport { easeLinear } from 'd3-ease'\n\n// Core\nimport { XYComponentCore } from 'core/xy-component'\nimport { Tooltip } from 'components/tooltip'\n\n// Utils\nimport { isNumber, isArray, getNumber, clamp, getStackedValues, getNearest, isFunction } from 'utils/data'\nimport { smartTransition } from 'utils/d3'\nimport { getColor } from 'utils/color'\n\n// Types\nimport { Position } from 'types/position'\n\n// Local Types\nimport { CrosshairAccessors, CrosshairCircle } from './types'\n\n// Config\nimport { CrosshairDefaultConfig, CrosshairConfigInterface } from './config'\n\n// Styles\nimport * as s from './style'\n\nexport class Crosshair<Datum> extends XYComponentCore<Datum, CrosshairConfigInterface<Datum>> {\n static selectors = s\n clippable = true // Don't apply clipping path to this component. See XYContainer\n protected _defaultConfig = CrosshairDefaultConfig as CrosshairConfigInterface<Datum>\n public config: CrosshairConfigInterface<Datum> = this._defaultConfig\n container: Selection<SVGSVGElement, any, SVGSVGElement, any>\n line: Selection<SVGLineElement, any, SVGElement, any>\n x = 0\n datum: Datum\n datumIndex: number\n show = false\n private _animFrameId: number = null\n\n /** Tooltip component to be used by Crosshair if not provided by the config.\n * This property is supposed to be set externally by a container component like XYContainer. */\n public tooltip: Tooltip\n\n /** Accessors passed externally (e.g. from XYContainer) */\n private _accessors: CrosshairAccessors<Datum> = {\n x: undefined,\n y: undefined,\n yStacked: undefined,\n baseline: undefined,\n }\n\n public set accessors (accessors: CrosshairAccessors<Datum>) { this._accessors = accessors }\n public get accessors (): CrosshairAccessors<Datum> {\n const { config } = this\n\n const hasConfig = !!(config.x || config.y || config.yStacked)\n const x = hasConfig ? config.x : this._accessors.x\n const yAcc = hasConfig ? config.y : this._accessors.y\n const y = yAcc ? (isArray(yAcc) ? yAcc : [yAcc]) : undefined\n const yStacked = hasConfig ? config.yStacked : this._accessors.yStacked\n const baseline = config.baseline ?? this._accessors.baseline\n\n return { x, y, yStacked, baseline }\n }\n\n constructor (config?: CrosshairConfigInterface<Datum>) {\n super()\n if (config) this.setConfig(config)\n\n this.g.style('opacity', this.show ? 1 : 0)\n this.line = this.g.append('line')\n .attr('class', s.line)\n }\n\n setContainer (containerSvg: Selection<SVGSVGElement, unknown, SVGSVGElement, unknown>): void {\n // Set up mousemove event for Crosshair\n this.container = containerSvg\n this.container.on('mousemove.crosshair', this._onMouseMove.bind(this))\n this.container.on('mouseout.crosshair', this._onMouseOut.bind(this))\n }\n\n _render (customDuration?: number): void {\n const { config } = this\n if (config.snapToData && !this.datum) return\n const duration = isNumber(customDuration) ? customDuration : config.duration\n\n smartTransition(this.g, duration)\n .style('opacity', this.show ? 1 : 0)\n\n this.line\n .attr('y1', 0)\n .attr('y1', this._height)\n\n smartTransition(this.line, duration, easeLinear)\n .attr('x1', this.x)\n .attr('x2', this.x)\n\n const circleData = this.getCircleData()\n const circles = this.g\n .selectAll<SVGCircleElement, CrosshairCircle>('circle')\n .data(circleData, (d, i) => d.id ?? i)\n\n const circlesEnter = circles.enter()\n .append('circle')\n .attr('class', s.circle)\n .attr('r', 0)\n .attr('cx', this.x)\n .attr('cy', d => d.y)\n .style('fill', d => d.color)\n .style('stroke', d => d.strokeColor)\n .style('stroke-width', d => d.strokeWidth)\n\n smartTransition(circlesEnter.merge(circles), duration, easeLinear)\n .attr('cx', this.x)\n .attr('cy', d => d.y)\n .attr('r', 4)\n .style('opacity', d => d.opacity)\n .style('fill', d => d.color)\n .style('stroke', d => d.strokeColor)\n .style('stroke-width', d => d.strokeWidth)\n\n circles.exit().remove()\n }\n\n hide (): void {\n this._onMouseOut()\n }\n\n _onMouseMove (event: MouseEvent): void {\n const { config, datamodel, element } = this\n if (!this.accessors.x && datamodel.data?.length) {\n console.warn('Unovis | Crosshair: X accessor function has not been configured. Please check if it\\'s present in the configuration object')\n }\n const [x] = pointer(event, element)\n const xRange = this.xScale.range()\n\n if (config.snapToData) {\n if (!this.accessors.y && !this.accessors.yStacked && datamodel.data?.length) {\n console.warn('Unovis | Crosshair: Y accessors have not been configured. Please check if they\\'re present in the configuration object')\n }\n const scaleX = this.xScale\n const valueX = scaleX.invert(x) as number\n\n this.datum = getNearest(datamodel.data, valueX, this.accessors.x)\n this.datumIndex = datamodel.data.indexOf(this.datum)\n if (!this.datum) return\n\n this.x = clamp(Math.round(scaleX(getNumber(this.datum, this.accessors.x, this.datumIndex))), 0, this._width)\n\n // Show the crosshair only if it's in the chart range and not far from mouse pointer (if configured)\n this.show = (this.x >= 0) && (this.x <= this._width) && (!config.hideWhenFarFromPointer || (Math.abs(this.x - x) < config.hideWhenFarFromPointerDistance))\n } else {\n const tolerance = 2 // Show the crosshair when it is at least 2 pixels close to the chart area\n this.x = clamp(x, xRange[0], xRange[1])\n this.show = (x >= (xRange[0] - tolerance)) && (x <= (xRange[1] + tolerance))\n }\n\n window.cancelAnimationFrame(this._animFrameId)\n this._animFrameId = window.requestAnimationFrame(() => {\n this._render()\n })\n\n if (this.show) this._showTooltip(event)\n else this._hideTooltip()\n }\n\n _onMouseOut (): void {\n this.show = false\n\n window.cancelAnimationFrame(this._animFrameId)\n this._animFrameId = window.requestAnimationFrame(() => {\n this._render()\n })\n this._hideTooltip()\n }\n\n _showTooltip (event: MouseEvent): void {\n const { config } = this\n const tooltip = config.tooltip ?? this.tooltip\n if (!tooltip) return\n\n const container = tooltip.getContainer() || this.container.node()\n const [x, y] = tooltip.isContainerBody() ? [event.clientX, event.clientY] : pointer(event, container)\n const content = config.template(this.datum, this.xScale.invert(this.x))\n // Force set `followCursor` to `true` because we don't want Crosshair's tooltip to be hoverable\n tooltip.config.followCursor = true\n\n // Set tooltip placement based on Crosshair's position (left / right)\n if (!tooltip.config.horizontalPlacement || tooltip.config.horizontalPlacement === Position.Auto) {\n const xRelative = tooltip.isContainerBody() ? x - this.container.node().getBoundingClientRect().left : x\n tooltip.overrideHorizontalPlacement(xRelative > this._containerWidth / 2 ? Position.Left : Position.Right)\n }\n\n if (content) tooltip.show(content, { x, y })\n }\n\n _hideTooltip (): void {\n const { config } = this\n const tooltip = config.tooltip ?? this.tooltip\n tooltip?.hide()\n }\n\n // We don't want Crosshair to be be taken in to account in domain calculations\n getYDataExtent (): number[] {\n return [undefined, undefined]\n }\n\n private getCircleData (): CrosshairCircle[] {\n const { config, datamodel: { data } } = this\n\n if (isFunction(config.getCircles)) return config.getCircles(this.xScale.invert(this.x), data, this.yScale)\n\n if (config.snapToData && this.datum) {\n const yAccessors = this.accessors.y ?? []\n const yStackedAccessors = this.accessors.yStacked ?? []\n const baselineValue = getNumber(this.datum, this.accessors.baseline, this.datumIndex) || 0\n const stackedValues: CrosshairCircle[] = getStackedValues(this.datum, this.datumIndex, ...yStackedAccessors)\n .map((value, index, arr) => ({\n y: this.yScale(value + baselineValue),\n opacity: isNumber(getNumber(this.datum, yStackedAccessors[index])) ? 1 : 0,\n color: getColor(this.datum, config.color, index),\n strokeColor: config.strokeColor ? getColor(this.datum, config.strokeColor, index) : undefined,\n strokeWidth: config.strokeWidth ? getNumber(this.datum, config.strokeWidth, index) : undefined,\n }))\n\n const regularValues: CrosshairCircle[] = yAccessors\n .map((a, index) => {\n const value = getNumber(this.datum, a)\n return {\n y: this.yScale(value),\n opacity: isNumber(value) ? 1 : 0,\n color: getColor(this.datum, config.color, stackedValues.length + index),\n strokeColor: config.strokeColor ? getColor(this.datum, config.strokeColor, index) : undefined,\n strokeWidth: config.strokeWidth ? getNumber(this.datum, config.strokeWidth, index) : undefined,\n }\n })\n\n return stackedValues.concat(regularValues)\n }\n\n return []\n }\n}\n"],"names":["s.line","s.circle","s"],"mappings":";;;;;;;;;;;AAwBM,MAAO,SAAiB,SAAQ,eAAuD,CAAA;AAuC3F,IAAA,WAAA,CAAa,MAAwC,EAAA;AACnD,QAAA,KAAK,EAAE,CAAA;AAtCT,QAAA,IAAA,CAAA,SAAS,GAAG,IAAI,CAAA;QACN,IAAc,CAAA,cAAA,GAAG,sBAAyD,CAAA;AAC7E,QAAA,IAAA,CAAA,MAAM,GAAoC,IAAI,CAAC,cAAc,CAAA;QAGpE,IAAC,CAAA,CAAA,GAAG,CAAC,CAAA;QAGL,IAAI,CAAA,IAAA,GAAG,KAAK,CAAA;QACJ,IA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AAC;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../../../src/components/crosshair/index.ts"],"sourcesContent":["import { Selection, pointer } from 'd3-selection'\nimport { easeLinear } from 'd3-ease'\n\n// Core\nimport { XYComponentCore } from 'core/xy-component'\nimport { Tooltip } from 'components/tooltip'\n\n// Utils\nimport { isNumber, isArray, getNumber, clamp, getStackedValues, getNearest, isFunction } from 'utils/data'\nimport { smartTransition } from 'utils/d3'\nimport { getColor } from 'utils/color'\n\n// Types\nimport { Position } from 'types/position'\nimport { FindNearestDirection } from 'types/data'\n\n// Local Types\nimport { CrosshairAccessors, CrosshairCircle } from './types'\n\n// Config\nimport { CrosshairDefaultConfig, CrosshairConfigInterface } from './config'\n\n// Styles\nimport * as s from './style'\n\n\nexport class Crosshair<Datum> extends XYComponentCore<Datum, CrosshairConfigInterface<Datum>> {\n static selectors = s\n clippable = true // Don't apply clipping path to this component. See XYContainer\n protected _defaultConfig = CrosshairDefaultConfig as CrosshairConfigInterface<Datum>\n public config: CrosshairConfigInterface<Datum> = this._defaultConfig\n container: Selection<SVGSVGElement, any, SVGSVGElement, any>\n line: Selection<SVGLineElement, any, SVGElement, any>\n private _xPx: number | undefined = undefined\n private _yPx: number | undefined = undefined\n private _mouseEvent: MouseEvent | undefined = undefined\n private _animFrameId: number = null\n\n /** Tooltip component to be used by Crosshair if not provided by the config.\n * This property is supposed to be set externally by a container component like XYContainer. */\n public tooltip: Tooltip\n\n /** Accessors passed externally (e.g. from XYContainer) */\n private _accessors: CrosshairAccessors<Datum> = {\n x: undefined,\n y: undefined,\n yStacked: undefined,\n baseline: undefined,\n }\n\n public set accessors (accessors: CrosshairAccessors<Datum>) { this._accessors = accessors }\n public get accessors (): CrosshairAccessors<Datum> {\n const { config } = this\n\n const hasConfig = !!(config.x || config.y || config.yStacked)\n const x = hasConfig ? config.x : this._accessors.x\n const yAcc = hasConfig ? config.y : this._accessors.y\n const y = yAcc ? (isArray(yAcc) ? yAcc : [yAcc]) : undefined\n const yStacked = hasConfig ? config.yStacked : this._accessors.yStacked\n const baseline = config.baseline ?? this._accessors.baseline\n\n return { x, y, yStacked, baseline }\n }\n\n private _isContainerInViewport (): boolean {\n if (!this.container?.node()) return false\n\n const containerRect = this.container.node().getBoundingClientRect()\n const viewportWidth = window.innerWidth || document.documentElement.clientWidth\n const viewportHeight = window.innerHeight || document.documentElement.clientHeight\n\n // Calculate the visible area of the container\n const visibleWidth = Math.max(0, Math.min(containerRect.right, viewportWidth) - Math.max(containerRect.left, 0))\n const visibleHeight = Math.max(0, Math.min(containerRect.bottom, viewportHeight) - Math.max(containerRect.top, 0))\n const containerArea = containerRect.width * containerRect.height\n const visibleArea = visibleWidth * visibleHeight\n\n // Container must be at least 35% visible\n return containerArea > 0 && (visibleArea / containerArea) >= 0.35\n }\n\n constructor (config?: CrosshairConfigInterface<Datum>) {\n super()\n if (config) this.setConfig(config)\n\n this.g.style('opacity', 0)\n this.line = this.g.append('line')\n .attr('class', s.line)\n }\n\n setContainer (containerSvg: Selection<SVGSVGElement, unknown, SVGSVGElement, unknown>): void {\n if (this.container === containerSvg) return\n\n this.container = containerSvg\n this.container.on('mousemove.crosshair', this._onMouseMove.bind(this))\n this.container.on('mouseout.crosshair', this._onMouseOut.bind(this))\n this.container.on('wheel.crosshair', this._onWheel.bind(this))\n }\n\n _render (customDuration?: number): void {\n const { config, datamodel } = this\n const duration = isNumber(customDuration) ? customDuration : config.duration\n const isForceShowAtDefined = config.forceShowAt !== undefined\n const xPx = isForceShowAtDefined ? this.xScale(config.forceShowAt) : this._xPx\n\n const xValue = this.xScale.invert(xPx) as number\n\n const leftNearestDatumIndex = (datamodel.data?.length && this.accessors.x)\n ? datamodel.data.indexOf(\n getNearest(datamodel.data, xValue, this.accessors.x, FindNearestDirection.Left)\n ) : undefined\n\n // If `snapToData` is `true`, we need to find the nearest datum to the crosshair\n // It can be from a mouse interaction or from a `forceShowAt` setting\n let nearestDatum: Datum | undefined\n let nearestDatumIndex: number | undefined\n if (config.snapToData) {\n if (!this.accessors.y && !this.accessors.yStacked && datamodel.data?.length) {\n console.warn('Unovis | Crosshair: Y accessors have not been configured. Please check if they\\'re present in the configuration object')\n }\n\n // Emit a warning if there's no data to snap to.\n // To keep the console clean, only emit the warning when there's mouse interaction.\n if (!datamodel.data?.length && this._mouseEvent) {\n console.warn('Unovis | Crosshair: No data to snap to. Make sure the data has been passed to the container or to the crosshair itself')\n }\n\n nearestDatum = getNearest(datamodel.data, xValue, this.accessors.x)\n nearestDatumIndex = datamodel.data.indexOf(nearestDatum)\n }\n\n const xRange = this.xScale.range()\n const yRange = this.yScale.range()\n const xClamped = config.snapToData && nearestDatum\n ? clamp(Math.round(this.xScale(getNumber(nearestDatum, this.accessors.x, nearestDatumIndex))), 0, this._width)\n : clamp(xPx, xRange[0], xRange[1])\n\n const isCrosshairWithinXRange = (xPx >= xRange[0]) && (xPx <= xRange[1])\n const isCrosshairWithinYRange = (this._yPx >= yRange[1]) && (this._yPx <= yRange[0])\n let shouldShow = this._xPx ? isCrosshairWithinXRange && isCrosshairWithinYRange : isCrosshairWithinXRange\n\n // If the crosshair is far from the mouse pointer (usually when `snapToData` is `true` and data resolution is low), hide it\n if (config.hideWhenFarFromPointer && ((Math.abs(xClamped - (+xPx)) >= config.hideWhenFarFromPointerDistance))) {\n shouldShow = false\n }\n\n const tooltip = config.tooltip ?? this.tooltip\n if (shouldShow && tooltip && this._isContainerInViewport()) {\n const container = tooltip.getContainer() || this.container.node()\n const isContainerBody = tooltip.isContainerBody()\n\n if (isForceShowAtDefined) {\n // Convert SVG coordinates to screen coordinates\n const containerRect = this.container.node().getBoundingClientRect()\n\n // Use the actual left margin from the container\n const screenX = (isContainerBody ? xPx + containerRect.left : xPx) + this._containerMargin.left\n const screenY = this._height / 2 + (isContainerBody ? containerRect.top : 0)\n const pos = [screenX, screenY] as [number, number]\n this._showTooltip(nearestDatum, xValue, pos, leftNearestDatumIndex)\n } else if (this._mouseEvent) {\n const pos = (isContainerBody ? [this._mouseEvent.clientX, this._mouseEvent.clientY] : pointer(this._mouseEvent, container)) as [number, number]\n this._showTooltip(nearestDatum, xValue, pos, leftNearestDatumIndex)\n }\n } else this._hideTooltip()\n\n // Trigger `onCrosshairMove` if the render was triggered by a mouse move event\n if (this._mouseEvent) {\n config.onCrosshairMove?.(shouldShow ? this.xScale.invert(this._xPx) as number : undefined, nearestDatum, nearestDatumIndex, this._mouseEvent)\n this._mouseEvent = undefined\n }\n\n smartTransition(this.g, duration)\n .style('opacity', shouldShow ? 1 : 0)\n\n // When `config.forceShowAt` becomes `undefined`, the crosshair \"jumps\" to the edge of the chart.\n // This looks off, so we stop further rendering when the `xPx` value is not finite.\n if (!isFinite(xPx)) return\n\n this.line\n .attr('y1', 0)\n .attr('y2', this._height)\n\n smartTransition(this.line, duration, easeLinear)\n .attr('x1', xClamped)\n .attr('x2', xClamped)\n\n const circleData = isFunction(config.getCircles)\n ? config.getCircles(xValue, datamodel.data, this.yScale, leftNearestDatumIndex)\n : this.getCircleData(nearestDatum, nearestDatumIndex)\n\n const circles = this.g\n .selectAll<SVGCircleElement, CrosshairCircle>('circle')\n .data(circleData, (d, i) => d.id ?? i)\n\n const circlesEnter = circles.enter()\n .append('circle')\n .attr('class', s.circle)\n .attr('r', 0)\n .attr('cx', xClamped)\n .attr('cy', d => d.y)\n .style('fill', d => d.color)\n .style('stroke', d => d.strokeColor)\n .style('stroke-width', d => d.strokeWidth)\n\n smartTransition(circlesEnter.merge(circles), duration, easeLinear)\n .attr('cx', xClamped)\n .attr('cy', d => d.y)\n .attr('r', 4)\n .style('opacity', d => d.opacity)\n .style('fill', d => d.color)\n .style('stroke', d => d.strokeColor)\n .style('stroke-width', d => d.strokeWidth)\n\n circles.exit().remove()\n }\n\n hide (sourceEvent?: MouseEvent | WheelEvent): void {\n window.cancelAnimationFrame(this._animFrameId)\n this._animFrameId = window.requestAnimationFrame(() => {\n this._xPx = undefined\n this._yPx = undefined\n this._mouseEvent = undefined\n // We call `onCrosshairMove` with all the arguments set to `undefined` because we want\n // the users to be able to hide the crosshair easily when using `forceShowAt`\n this.config.onCrosshairMove?.(undefined, undefined, undefined, sourceEvent)\n this._render()\n })\n }\n\n _onMouseMove (event: MouseEvent): void {\n const { datamodel, element } = this\n if (!this.accessors.x && datamodel.data?.length) {\n console.warn('Unovis | Crosshair: X accessor function has not been configured. Please check if it\\'s present in the configuration object')\n }\n const [x, y] = pointer(event, element)\n this._xPx = x\n this._yPx = y\n this._mouseEvent = event\n\n window.cancelAnimationFrame(this._animFrameId)\n this._animFrameId = window.requestAnimationFrame(() => {\n // We'll call `config.onCrosshairMove` in `_render` with the found `nearestDatum` and `nearestDatumIndex`,\n // which can come from the mouse interaction or from the `forceShowAt` setting\n this._render()\n })\n }\n\n _onMouseOut (event?: MouseEvent): void {\n // Only hide if the mouse actually left the SVG, not just moved to a child\n if (!event || !this.container?.node().contains((event as MouseEvent).relatedTarget as Node)) {\n this.hide(event)\n }\n }\n\n _onWheel (event: WheelEvent): void {\n this.hide(event)\n }\n\n _showTooltip (datum: Datum, xValue: number, pos: [number, number], nearestDatumIndex: number | undefined): void {\n const { config, datamodel } = this\n const tooltip = config.tooltip ?? this.tooltip\n if (!tooltip || !pos) return\n\n const [x, y] = pos\n const content = config.template(datum, xValue, datamodel.data, nearestDatumIndex)\n // Force set `followCursor` to `true` because we don't want Crosshair's tooltip to be hoverable\n tooltip.config.followCursor = true\n\n // Set tooltip placement based on Crosshair's position (left / right)\n if (!tooltip.config.horizontalPlacement || tooltip.config.horizontalPlacement === Position.Auto) {\n const xRelative = tooltip.isContainerBody() ? x - this.container.node().getBoundingClientRect().left : x\n tooltip.overrideHorizontalPlacement(xRelative > this._containerWidth / 2 ? Position.Left : Position.Right)\n }\n\n if (content) tooltip.show(content, { x, y })\n }\n\n _hideTooltip (): void {\n const { config } = this\n const tooltip = config.tooltip ?? this.tooltip\n tooltip?.hide()\n }\n\n // We don't want Crosshair to be be taken in to account in domain calculations\n getYDataExtent (): number[] {\n return [undefined, undefined]\n }\n\n private getCircleData (datum: Datum, datumIndex: number): CrosshairCircle[] {\n const { config } = this\n\n if (config.snapToData && datum) {\n const yAccessors = this.accessors.y ?? []\n const yStackedAccessors = this.accessors.yStacked ?? []\n const baselineValue = getNumber(datum, this.accessors.baseline, datumIndex) || 0\n const stackedValues: CrosshairCircle[] = getStackedValues(datum, datumIndex, ...yStackedAccessors)\n .map((value, index) => ({\n y: this.yScale(value + baselineValue),\n opacity: isNumber(getNumber(datum, yStackedAccessors[index], index)) ? 1 : 0,\n color: getColor(datum, config.color, index),\n strokeColor: config.strokeColor ? getColor(datum, config.strokeColor, index) : undefined,\n strokeWidth: config.strokeWidth ? getNumber(datum, config.strokeWidth, index) : undefined,\n }))\n\n const regularValues: CrosshairCircle[] = yAccessors\n .map((a, index) => {\n const value = getNumber(datum, a, datumIndex)\n return {\n y: this.yScale(value),\n opacity: isNumber(value) ? 1 : 0,\n color: getColor(datum, config.color, stackedValues.length + index),\n strokeColor: config.strokeColor ? getColor(datum, config.strokeColor, index) : undefined,\n strokeWidth: config.strokeWidth ? getNumber(datum, config.strokeWidth, index) : undefined,\n }\n })\n\n return stackedValues.concat(regularValues)\n }\n\n return []\n }\n}\n"],"names":["s.line","s.circle","s"],"mappings":";;;;;;;;;;;;AA0BM,MAAO,SAAiB,SAAQ,eAAuD,CAAA;AAuD3F,IAAA,WAAA,CAAa,MAAwC,EAAA;AACnD,QAAA,KAAK,EAAE,CAAA;AAtDT,QAAA,IAAA,CAAA,SAAS,GAAG,IAAI,CAAA;QACN,IAAc,CAAA,cAAA,GAAG,sBAAyD,CAAA;AAC7E,QAAA,IAAA,CAAA,MAAM,GAAoC,IAAI,CAAC,cAAc,CAAA;QAG5D,IAAI,CAAA,IAAA,GAAuB,SAAS,CAAA;QACpC,IAAI,CAAA,IAAA,GAAuB,SAAS,CAAA;QACpC,IAAW,CAAA,WAAA,GAA2B,SAAS,CAAA;QAC/C,IAAY,CAAA,YAAA,GAAW,IAAI,CAAA;;AAO3B,QAAA,I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CAAC,GAAG,SAAS;oBACxF,WAAW,EAAE,MAAM,CAAC,WAAW,GAAG,SAAS,CAAC,KAAK,EAAE,MAAM,CAAC,WAAW,EAAE,KAAK,CAAC,GAAG,SAAS;iBAC1F,CAAA;AACH,aAAC,CAAC,CAAA;AAEJ,YAAA,OAAO,aAAa,CAAC,MAAM,CAAC,aAAa,CAAC,CAAA;AAC3C,SAAA;AAED,QAAA,OAAO,EAAE,CAAA;KACV;;AAtSM,SAAS,CAAA,SAAA,GAAGC,KAAC;;;;"}
@@ -62,6 +62,14 @@ export interface GraphConfigInterface<N extends GraphInputNode, L extends GraphI
62
62
  * Only for `GraphLayoutType.Parallel` and `GraphLayoutType.ParallelHorizontal` layouts.
63
63
  * Default: `1` */
64
64
  layoutParallelSubGroupsPerRow?: number;
65
+ /** Spacing between nodes, dynamic by default.
66
+ * Only for `GraphLayoutType.Parallel` and `GraphLayoutType.ParallelHorizontal` layouts.
67
+ * Default: `undefined` */
68
+ layoutParallelNodeSpacing?: number | [number, number];
69
+ /** Spacing between sub-groups.
70
+ * Only for `GraphLayoutType.Parallel` and `GraphLayoutType.ParallelHorizontal` layouts.
71
+ * Default: `40` */
72
+ layoutParallelSubGroupSpacing?: number;
65
73
  /** Spacing between groups.
66
74
  * Only for `GraphLayoutType.Parallel` and `GraphLayoutType.ParallelHorizontal` layouts.
67
75
  * Default: `undefined` */
@@ -4,7 +4,7 @@ import { TrimMode } from '../../types/text.js';
4
4
  import { GraphLayoutType, GraphFitViewAlignment, GraphLinkStyle, GraphNodeShape, GraphNodeSelectionHighlightMode } from './types.js';
5
5
 
6
6
  // Utils
7
- const GraphDefaultConfig = Object.assign(Object.assign({}, ComponentDefaultConfig), { duration: 1000, zoomScaleExtent: [0.35, 1.25], disableZoom: false, zoomEventFilter: undefined, disableDrag: false, disableBrush: false, zoomThrottledUpdateNodeThreshold: 100, layoutType: GraphLayoutType.Force, layoutAutofit: true, layoutAutofitTolerance: 8.0, layoutNonConnectedAside: false, fitViewPadding: 50, fitViewAlign: GraphFitViewAlignment.Center, layoutGroupOrder: [], layoutParallelSubGroupsPerRow: 1, layoutParallelNodesPerColumn: 6, layoutParallelGroupSpacing: undefined, layoutParallelSortConnectionsByGroup: undefined, layoutNodeGroup: (n) => n.group, layoutParallelNodeSubGroup: (n) => n.subgroup, forceLayoutSettings: {
7
+ const GraphDefaultConfig = Object.assign(Object.assign({}, ComponentDefaultConfig), { duration: 1000, zoomScaleExtent: [0.35, 1.25], disableZoom: false, zoomEventFilter: undefined, disableDrag: false, disableBrush: false, zoomThrottledUpdateNodeThreshold: 100, layoutType: GraphLayoutType.Force, layoutAutofit: true, layoutAutofitTolerance: 8.0, layoutNonConnectedAside: false, fitViewPadding: 50, fitViewAlign: GraphFitViewAlignment.Center, layoutGroupOrder: [], layoutParallelNodeSpacing: undefined, layoutParallelSubGroupsPerRow: 1, layoutParallelNodesPerColumn: 6, layoutParallelGroupSpacing: undefined, layoutParallelSubGroupSpacing: 40, layoutParallelSortConnectionsByGroup: undefined, layoutNodeGroup: (n) => n.group, layoutParallelNodeSubGroup: (n) => n.subgroup, forceLayoutSettings: {
8
8
  linkDistance: 60,
9
9
  linkStrength: 0.45,
10
10
  charge: -500,
@@ -1 +1 @@
1
- {"version":3,"file":"config.js","sources":["../../../src/components/graph/config.ts"],"sourcesContent":["import { D3BrushEvent } from 'd3-brush'\nimport { D3DragEvent } from 'd3-drag'\nimport { D3ZoomEvent, ZoomTransform } from 'd3-zoom'\nimport { Selection } from 'd3-selection'\nimport { ElkShape } from 'elkjs'\n\n// Core\nimport type { GraphDataModel } from 'data-models/graph'\n\n// Utils\nimport { isEqual } from 'utils/data'\n\n// Config\nimport { ComponentConfigInterface, ComponentDefaultConfig } from 'core/component/config'\n\n// Types\nimport { TrimMode } from 'types/text'\nimport { Spacing } from 'types/spacing'\nimport { GraphInputLink, GraphInputNode, GraphInputData } from 'types/graph'\nimport { BooleanAccessor, ColorAccessor, NumericAccessor, StringAccessor, GenericAccessor } from 'types/accessor'\n\n// Local Types\nimport {\n GraphLayoutType,\n GraphCircleLabel,\n GraphLinkStyle,\n GraphLinkArrowStyle,\n GraphPanelConfig,\n GraphForceLayoutSettings,\n GraphElkLayoutSettings,\n GraphNodeShape,\n GraphDagreLayoutSetting,\n GraphNode,\n GraphLink,\n GraphNodeSelectionHighlightMode,\n GraphFitViewAlignment,\n} from './types'\n\nexport interface GraphConfigInterface<N extends GraphInputNode, L extends GraphInputLink> extends ComponentConfigInterface {\n // Zoom and drag\n /** Zoom level constraints. Default: [0.35, 1.25] */\n zoomScaleExtent?: [number, number];\n /** Disable zooming. Default: `false` */\n disableZoom?: boolean;\n /** Custom Zoom event filter to better control which actions should trigger zooming.\n * Learn more: https://d3js.org/d3-zoom#zoom_filter.\n * Default: `undefined` */\n zoomEventFilter?: (event: PointerEvent) => boolean;\n /** Disable node dragging. Default: `false` */\n disableDrag?: boolean;\n /** Disable brush for multiple node selection. Default: `false` */\n disableBrush?: boolean;\n /** Interval to re-render the graph when zooming. Default: `100` */\n zoomThrottledUpdateNodeThreshold?: number;\n /** Padding for the graph when fitting to container. Default: `50` */\n fitViewPadding?: Spacing | number;\n /** Default alignment when fitting the graph view. Default: `GraphFitViewAlignment.Center` */\n fitViewAlign?: GraphFitViewAlignment;\n\n // Layout general settings\n /** Type of the graph layout. Default: `GraphLayoutType.Force` */\n layoutType?: GraphLayoutType | string;\n /** Fit the graph to container on data or config updates, or on container resize. Default: `true` */\n layoutAutofit?: boolean;\n /** Tolerance constant defining whether the graph should be fitted to container\n * (on data or config update, or container resize) after a zoom / pan interaction or not.\n * `0` — Stop fitting after any pan or zoom\n * `Number.POSITIVE_INFINITY` — Always fit\n * Default: `8.0` */\n layoutAutofitTolerance?: number;\n /** Place non-connected nodes at the bottom of the graph. Default: `false` */\n layoutNonConnectedAside?: boolean;\n\n // Settings for Parallel and Concentric layouts\n /** Node group accessor function.\n * Only for `GraphLayoutType.Parallel`, `GraphLayoutType.ParallelHorizontal` and `GraphLayoutType.Concentric` layouts.\n * Default: `node => node.group` */\n layoutNodeGroup?: StringAccessor<N>;\n /** Order of the layout groups.\n * Only for `GraphLayoutType.Parallel`, `GraphLayoutType.ParallelHorizontal` and `GraphLayoutType.Concentric` layouts.\n * Default: `[]` */\n layoutGroupOrder?: string[];\n\n // Setting for Parallel layouts only\n /** Sets the number of nodes in a sub-group after which they'll continue on the next column (or row if `layoutType` is\n * `GraphLayoutType.ParallelHorizontal`).\n * Only for `GraphLayoutType.Parallel` and `GraphLayoutType.ParallelHorizontal` layouts.\n * Default: `6` */\n layoutParallelNodesPerColumn?: number;\n /** Node sub-group accessor function.\n * Only for `GraphLayoutType.Parallel` and `GraphLayoutType.ParallelHorizontal` layouts.\n * Default: `node => node.subgroup` */\n layoutParallelNodeSubGroup?: StringAccessor<N>;\n /** Number of sub-groups per row (or column if `layoutType` is `GraphLayoutType.ParallelHorizontal`) in a group.\n * Only for `GraphLayoutType.Parallel` and `GraphLayoutType.ParallelHorizontal` layouts.\n * Default: `1` */\n layoutParallelSubGroupsPerRow?: number;\n /** Spacing between groups.\n * Only for `GraphLayoutType.Parallel` and `GraphLayoutType.ParallelHorizontal` layouts.\n * Default: `undefined` */\n layoutParallelGroupSpacing?: number;\n /** Set a group by name to have priority in sorting the graph links.\n * Only for `GraphLayoutType.Parallel` and `GraphLayoutType.ParallelHorizontal` layouts.\n * Default: `undefined` */\n layoutParallelSortConnectionsByGroup?: string;\n\n // Force layout\n /** Force Layout settings, see the `d3-force` package for more details */\n forceLayoutSettings?: GraphForceLayoutSettings<N, L>;\n\n // Dagre layout\n /** Darge Layout settings, see the `dagrejs` package\n * for more details: https://github.com/dagrejs/dagre/wiki#configuring-the-layout\n */\n dagreLayoutSettings?: GraphDagreLayoutSetting;\n\n // ELK layout\n /** ELK layout options, see the `elkjs` package for more details: https://github.com/kieler/elkjs.\n * If you want to specify custom layout option for each node group, you can provide an accessor function that\n * receives group name ('root' for the top-level configuration) as the first argument and returns an object containing\n * layout options. Default: `undefined`\n */\n layoutElkSettings?: GenericAccessor<GraphElkLayoutSettings, string> | undefined;\n /** Array of accessor functions to define nested node groups for the ELK Layered layout.\n * E.g.: `[n => n.group, n => n.subGroup]`.\n * Default: `undefined` */\n layoutElkNodeGroups?: StringAccessor<N>[];\n /** A function to be called per graph node to get the ELK shape object.\n * This enables you to provide custom node dimensions (through the `width` and `height` properties)\n * and coordinates (through the `x` and `y` properties) if needed.\n * Default: `undefined`\n */\n layoutElkGetNodeShape?: (d: GraphNode<N, L>, i: number) => ElkShape;\n\n // Links\n /** Link width accessor function ot constant value. Default: `1` */\n linkWidth?: NumericAccessor<L>;\n /** Link style accessor function or constant value. Default: `GraphLinkStyle.Solid` */\n linkStyle?: GenericAccessor<GraphLinkStyle, L>;\n /** Link band width accessor function or constant value. Default: `0` */\n linkBandWidth?: NumericAccessor<L>;\n /** Link arrow accessor function or constant value. Default: `undefined` */\n linkArrow?: GenericAccessor<GraphLinkArrowStyle | string | boolean, L> | undefined;\n /** Link stroke color accessor function or constant value. Default: `undefined` */\n linkStroke?: ColorAccessor<L>;\n /** Link disabled state accessor function or constant value. Default: `false` */\n linkDisabled?: BooleanAccessor<L>;\n /** Link flow animation accessor function or constant value. Default: `false` */\n linkFlow?: BooleanAccessor<L>;\n /** Animation duration of the flow (traffic) circles in milliseconds. If `linkFlowParticleSpeed` is provided,\n * this duration will be calculated based on the link length and particle speed. Default: `20000` */\n linkFlowAnimDuration?: NumericAccessor<L>;\n /** Size of the moving particles that represent traffic flow. Default: `2` */\n linkFlowParticleSize?: NumericAccessor<L>;\n /** Speed of the moving particles in pixels per second. This property takes precedence over `linkFlowAnimDuration`. Default: `undefined` */\n linkFlowParticleSpeed?: NumericAccessor<L>;\n /** Link label accessor function or constant value. Default: `undefined` */\n linkLabel?: GenericAccessor<GraphCircleLabel | GraphCircleLabel[], L> | undefined;\n /** Shift label along the link center a little bit to avoid overlap with the link arrow. Default: `true` */\n linkLabelShiftFromCenter?: BooleanAccessor<L>;\n /** Spacing between neighboring links. Default: `8` */\n linkNeighborSpacing?: number;\n /** Curvature of the link. Recommended value range: [0:1.5].\n * `0` - straight line,\n * `1` - nice curvature,\n * `1.5` - very curve.\n * Default: `0` */\n linkCurvature?: NumericAccessor<L>;\n /** Highlight links on hover. Default: `true` */\n linkHighlightOnHover?: boolean;\n /** Offset [x,y] in pixels from the source node's center point where the link should start. Default: `undefined` */\n linkSourcePointOffset?: GenericAccessor<[number, number], GraphLink<N, L>>;\n /** Offset [x,y] in pixels from the target node's center point where the link should end. Default: `undefined` */\n linkTargetPointOffset?: GenericAccessor<[number, number], GraphLink<N, L>>;\n /** Set selected link by its unique id. Default: `undefined` */\n selectedLinkId?: number | string;\n\n // Nodes\n /** Node size accessor function or constant value. Default: `30` */\n nodeSize?: NumericAccessor<N>;\n /** Node stroke width accessor function or constant value. Default: `3` */\n nodeStrokeWidth?: NumericAccessor<N>;\n /** Node shape accessor function or constant value. Default: `GraphNodeShape.Circle` */\n nodeShape?: GenericAccessor<GraphNodeShape | string, N>;\n /** Node gauge outline accessor function or constant value in the range [0,100]. Default: `0` */\n nodeGaugeValue?: NumericAccessor<N>;\n /** Node gauge outline fill color accessor function or constant value. Default: `undefined` */\n nodeGaugeFill?: ColorAccessor<N>;\n /** Animation duration of the node gauge outline. Default: `1500` */\n nodeGaugeAnimDuration?: number;\n /** Node central icon accessor function or constant value. Default: `node => node.icon` */\n nodeIcon?: StringAccessor<N>;\n /** Node central icon size accessor function or constant value. Default: `undefined` */\n nodeIconSize?: NumericAccessor<N>;\n /** Node label accessor function or constant value. Default: `node => node.label` */\n nodeLabel?: StringAccessor<N>;\n /** Defines whether to trim the node labels or not. Default: `true` */\n nodeLabelTrim?: BooleanAccessor<N>;\n /** Node label trimming mode. Default: `TrimMode.Middle` */\n nodeLabelTrimMode?: GenericAccessor<TrimMode | string, N>;\n /** Node label maximum allowed text length above which the label will be trimmed. Default: `15` */\n nodeLabelTrimLength?: NumericAccessor<N>;\n /** Node sub-label accessor function or constant value: Default: `''` */\n nodeSubLabel?: StringAccessor<N>;\n /** Defines whether to trim the node sub-labels or not. Default: `true` */\n nodeSubLabelTrim?: BooleanAccessor<N>;\n /** Node sub-label trimming mode. Default: `TrimMode.Middle` */\n nodeSubLabelTrimMode?: GenericAccessor<TrimMode | string, N>;\n /** Node sub-label maximum allowed text length above which the label will be trimmed. Default: `15` */\n nodeSubLabelTrimLength?: NumericAccessor<N>;\n /** Node circular side labels accessor function. The function should return an array of GraphCircleLabel objects. Default: `undefined` */\n nodeSideLabels?: GenericAccessor<GraphCircleLabel[], N>;\n /** Node bottom icon accessor function. Default: `undefined` */\n nodeBottomIcon?: StringAccessor<N>;\n /** Node disabled state accessor function or constant value. Default: `false` */\n nodeDisabled?: BooleanAccessor<N>;\n /** Node fill color accessor function or constant value. Default: `node => node.fill` */\n nodeFill?: ColorAccessor<N>;\n /** Node stroke color accessor function or constant value. Default: `node => node.stroke` */\n nodeStroke?: ColorAccessor<N>;\n /** Sorting function to determine node placement. Default: `undefined` */\n nodeSort?: ((a: N, b: N) => number);\n /** Specify the initial position for entering nodes as [x, y]. Default: `undefined` */\n nodeEnterPosition?: GenericAccessor<[number, number], N> | undefined;\n /** Specify the initial scale for entering nodes in the range [0,1]. Default: `0.75` */\n nodeEnterScale?: NumericAccessor<N> | undefined;\n /** Specify the destination position for exiting nodes as [x, y]. Default: `undefined` */\n nodeExitPosition?: GenericAccessor<[number, number], N> | undefined;\n /** Specify the destination scale for exiting nodes in the range [0,1]. Default: `0.75` */\n nodeExitScale?: NumericAccessor<N> | undefined;\n /** Custom \"enter\" function for node rendering. Default: `undefined` */\n nodeEnterCustomRenderFunction?:\n (datum: GraphNode<N, L>, nodeGroupElementSelection: Selection<SVGGElement, GraphNode<N, L>, null, unknown>, config: GraphConfigInterface<N, L>, duration: number, zoomLevel: number) => void;\n /** Custom \"update\" function for node rendering. Default: `undefined` */\n nodeUpdateCustomRenderFunction?:\n (datum: GraphNode<N, L>, nodeGroupElementSelection: Selection<SVGGElement, GraphNode<N, L>, null, unknown>, config: GraphConfigInterface<N, L>, duration: number, zoomLevel: number) => void;\n /** Custom partial \"update\" function for node rendering which will be triggered after the following events:\n * - Full node update (`nodeUpdateCustomRenderFunction`);\n * - Background click;\n * - Node and Link mouseover and mouseout;\n * - Node brushing,\n * Default: `undefined` */\n nodePartialUpdateCustomRenderFunction?:\n (datum: GraphNode<N, L>, nodeGroupElementSelection: Selection<SVGGElement, GraphNode<N, L>, null, unknown>, config: GraphConfigInterface<N, L>, duration: number, zoomLevel: number) => void;\n /** Custom \"exit\" function for node rendering. Default: `undefined` */\n nodeExitCustomRenderFunction?:\n (datum: GraphNode<N, L>, nodeGroupElementSelection: Selection<SVGGElement, GraphNode<N, L>, null, unknown>, config: GraphConfigInterface<N, L>, duration: number, zoomLevel: number) => void;\n /** Custom render function that will be called while zooming / panning the graph. Default: `undefined` */\n nodeOnZoomCustomRenderFunction?:\n (datum: GraphNode<N, L>, nodeGroupElementSelection: Selection<SVGGElement, GraphNode<N, L>, null, unknown>, config: GraphConfigInterface<N, L>, zoomLevel: number) => void;\n /** Define the mode for highlighting selected nodes in the graph. Default: `GraphNodeSelectionHighlightMode.GreyoutNonConnected` */\n nodeSelectionHighlightMode?: GraphNodeSelectionHighlightMode;\n /** Set selected node by unique id. Default: `undefined` */\n selectedNodeId?: number | string;\n /** Set selected nodes by unique id. Default: `undefined` */\n selectedNodeIds?: number[] | string[];\n\n /** Panels configuration. An array of `GraphPanelConfig` objects. Default: `[]` */\n panels?: GraphPanelConfig[] | undefined;\n\n // Events\n /** Graph node drag start callback function. Default: `undefined` */\n onNodeDragStart?: (n: GraphNode<N, L>, event: D3DragEvent<SVGGElement, GraphNode<N, L>, unknown>) => void | undefined;\n /** Graph node drag callback function. Default: `undefined` */\n onNodeDrag?: (n: GraphNode<N, L>, event: D3DragEvent<SVGGElement, GraphNode<N, L>, unknown>) => void | undefined;\n /** Graph node drag end callback function. Default: `undefined` */\n onNodeDragEnd?: (n: GraphNode<N, L>, event: D3DragEvent<SVGGElement, GraphNode<N, L>, unknown>) => void | undefined;\n /** Zoom event callback. Default: `undefined` */\n onZoom?: (zoomScale: number, zoomScaleExtent: [number, number], event: D3ZoomEvent<SVGGElement, unknown> | undefined, transform: ZoomTransform) => void;\n /** Zoom start event callback. Default: `undefined` */\n onZoomStart?: (zoomScale: number, zoomScaleExtent: [number, number], event: D3ZoomEvent<SVGGElement, unknown> | undefined, transform: ZoomTransform) => void;\n /** Zoom end event callback. Default: `undefined` */\n onZoomEnd?: (zoomScale: number, zoomScaleExtent: [number, number], event: D3ZoomEvent<SVGGElement, unknown> | undefined, transform: ZoomTransform) => void;\n /** Callback function to be called when the graph layout is calculated. Default: `undefined` */\n onLayoutCalculated?: (nodes: GraphNode<N, L>[], links: GraphLink<N, L>[]) => void;\n /** Graph node selection brush callback function. Default: `undefined` */\n onNodeSelectionBrush?: (selectedNodes: GraphNode<N, L>[], event: D3BrushEvent<SVGGElement> | undefined) => void;\n /** Graph multiple node drag callback function. Default: `undefined` */\n onNodeSelectionDrag?: (selectedNodes: GraphNode<N, L>[], event: D3DragEvent<SVGGElement, GraphNode<N, L>, unknown>) => void;\n /** Callback function to be called when the graph rendering is complete. Default: `undefined` */\n onRenderComplete?: (\n g: Selection<SVGGElement, unknown, null, undefined>,\n nodes: GraphNode<N, L>[],\n links: GraphLink<N, L>[],\n config: GraphConfigInterface<N, L>,\n duration: number,\n zoomLevel: number,\n width: number,\n height: number\n ) => void;\n\n /** Determines whether the component should update when new data is provided.\n * This function takes the previous and new data as parameters and returns a boolean\n * indicating whether the update should proceed. Useful for fine-grained control over\n * update behavior when your data has a complex nested structure.\n * By default the `isEqual` function from Unovis will be used to do the comparison.\n */\n shouldDataUpdate?: (\n prevData: GraphInputData<N, L>,\n nextData: GraphInputData<N, L>,\n datamodel: GraphDataModel<N, L, GraphNode<N, L>, GraphLink<N, L>>\n ) => boolean;\n}\n\nexport const GraphDefaultConfig: GraphConfigInterface<GraphInputNode, GraphInputLink> = {\n ...ComponentDefaultConfig,\n duration: 1000,\n zoomScaleExtent: [0.35, 1.25],\n disableZoom: false,\n zoomEventFilter: undefined,\n disableDrag: false,\n disableBrush: false,\n zoomThrottledUpdateNodeThreshold: 100,\n layoutType: GraphLayoutType.Force,\n layoutAutofit: true,\n layoutAutofitTolerance: 8.0,\n layoutNonConnectedAside: false,\n fitViewPadding: 50,\n fitViewAlign: GraphFitViewAlignment.Center,\n\n layoutGroupOrder: [],\n layoutParallelSubGroupsPerRow: 1,\n layoutParallelNodesPerColumn: 6,\n layoutParallelGroupSpacing: undefined,\n layoutParallelSortConnectionsByGroup: undefined,\n layoutNodeGroup: (n: GraphInputNode): string => (n as { group: string }).group,\n layoutParallelNodeSubGroup: (n: GraphInputNode): string => (n as { subgroup: string }).subgroup,\n\n forceLayoutSettings: {\n linkDistance: 60,\n linkStrength: 0.45,\n charge: -500,\n forceXStrength: 0.15,\n forceYStrength: 0.25,\n numIterations: undefined,\n fixNodePositionAfterSimulation: false,\n },\n\n dagreLayoutSettings: {\n rankdir: 'BT',\n ranker: 'longest-path',\n },\n\n layoutElkSettings: undefined,\n layoutElkNodeGroups: undefined,\n layoutElkGetNodeShape: undefined,\n\n linkFlowAnimDuration: 20000,\n linkFlowParticleSize: 2,\n linkFlowParticleSpeed: undefined,\n linkWidth: 1,\n linkStyle: GraphLinkStyle.Solid,\n linkBandWidth: 0,\n linkArrow: undefined,\n linkStroke: undefined,\n linkFlow: false,\n linkLabel: undefined,\n linkLabelShiftFromCenter: true,\n linkNeighborSpacing: 8,\n linkDisabled: false,\n linkCurvature: 0,\n linkHighlightOnHover: true,\n linkSourcePointOffset: undefined,\n linkTargetPointOffset: undefined,\n selectedLinkId: undefined,\n\n nodeSize: 30,\n nodeStrokeWidth: 3,\n nodeShape: GraphNodeShape.Circle,\n nodeGaugeValue: 0,\n nodeIcon: (n: GraphInputNode): string => (n as { icon: string }).icon,\n nodeIconSize: undefined,\n nodeLabel: (n: GraphInputNode): string => (n as { label: string }).label,\n nodeLabelTrim: true,\n nodeLabelTrimLength: 15,\n nodeLabelTrimMode: TrimMode.Middle,\n nodeSubLabel: '',\n nodeSubLabelTrim: true,\n nodeSubLabelTrimLength: 15,\n nodeSubLabelTrimMode: TrimMode.Middle,\n nodeSideLabels: undefined,\n nodeBottomIcon: undefined,\n nodeDisabled: false,\n nodeFill: (n: GraphInputNode): string => (n as { fill: string }).fill,\n nodeGaugeFill: undefined,\n nodeStroke: (n: GraphInputNode): string => (n as { stroke: string }).stroke,\n nodeEnterPosition: undefined,\n nodeEnterScale: 0.75,\n nodeExitPosition: undefined,\n nodeExitScale: 0.75,\n nodeSort: undefined,\n nodeSelectionHighlightMode: GraphNodeSelectionHighlightMode.GreyoutNonConnected,\n nodeGaugeAnimDuration: 1500,\n\n selectedNodeId: undefined,\n selectedNodeIds: undefined,\n\n panels: undefined,\n\n onNodeDragStart: undefined,\n onNodeDrag: undefined,\n onNodeDragEnd: undefined,\n onZoom: undefined,\n onZoomStart: undefined,\n onZoomEnd: undefined,\n onLayoutCalculated: undefined,\n onNodeSelectionBrush: undefined,\n onNodeSelectionDrag: undefined,\n onRenderComplete: undefined,\n\n shouldDataUpdate: (prevData: GraphInputData<GraphInputNode, GraphInputLink>, nextData: GraphInputData<GraphInputNode, GraphInputLink>): boolean => {\n return !isEqual(prevData, nextData)\n },\n}\n"],"names":[],"mappings":";;;;;AASA;AAuSa,MAAA,kBAAkB,GAC1B,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAA,sBAAsB,KACzB,QAAQ,EAAE,IAAI,EACd,eAAe,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,EAC7B,WAAW,EAAE,KAAK,EAClB,eAAe,EAAE,SAAS,EAC1B,WAAW,EAAE,KAAK,EAClB,YAAY,EAAE,KAAK,EACnB,gCAAgC,EAAE,GAAG,EACrC,UAAU,EAAE,eAAe,CAAC,KAAK,EACjC,aAAa,EAAE,IAAI,EACnB,sBAAsB,EAAE,GAAG,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wD,EAAE,QAAwD,KAAa;AAChJ,QAAA,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;AACrC,KAAC;;;;"}
1
+ {"version":3,"file":"config.js","sources":["../../../src/components/graph/config.ts"],"sourcesContent":["import { D3BrushEvent } from 'd3-brush'\nimport { D3DragEvent } from 'd3-drag'\nimport { D3ZoomEvent, ZoomTransform } from 'd3-zoom'\nimport { Selection } from 'd3-selection'\nimport { ElkShape } from 'elkjs'\n\n// Core\nimport type { GraphDataModel } from 'data-models/graph'\n\n// Utils\nimport { isEqual } from 'utils/data'\n\n// Config\nimport { ComponentConfigInterface, ComponentDefaultConfig } from 'core/component/config'\n\n// Types\nimport { TrimMode } from 'types/text'\nimport { Spacing } from 'types/spacing'\nimport { GraphInputLink, GraphInputNode, GraphInputData } from 'types/graph'\nimport { BooleanAccessor, ColorAccessor, NumericAccessor, StringAccessor, GenericAccessor } from 'types/accessor'\n\n// Local Types\nimport {\n GraphLayoutType,\n GraphCircleLabel,\n GraphLinkStyle,\n GraphLinkArrowStyle,\n GraphPanelConfig,\n GraphForceLayoutSettings,\n GraphElkLayoutSettings,\n GraphNodeShape,\n GraphDagreLayoutSetting,\n GraphNode,\n GraphLink,\n GraphNodeSelectionHighlightMode,\n GraphFitViewAlignment,\n} from './types'\n\nexport interface GraphConfigInterface<N extends GraphInputNode, L extends GraphInputLink> extends ComponentConfigInterface {\n // Zoom and drag\n /** Zoom level constraints. Default: [0.35, 1.25] */\n zoomScaleExtent?: [number, number];\n /** Disable zooming. Default: `false` */\n disableZoom?: boolean;\n /** Custom Zoom event filter to better control which actions should trigger zooming.\n * Learn more: https://d3js.org/d3-zoom#zoom_filter.\n * Default: `undefined` */\n zoomEventFilter?: (event: PointerEvent) => boolean;\n /** Disable node dragging. Default: `false` */\n disableDrag?: boolean;\n /** Disable brush for multiple node selection. Default: `false` */\n disableBrush?: boolean;\n /** Interval to re-render the graph when zooming. Default: `100` */\n zoomThrottledUpdateNodeThreshold?: number;\n /** Padding for the graph when fitting to container. Default: `50` */\n fitViewPadding?: Spacing | number;\n /** Default alignment when fitting the graph view. Default: `GraphFitViewAlignment.Center` */\n fitViewAlign?: GraphFitViewAlignment;\n\n // Layout general settings\n /** Type of the graph layout. Default: `GraphLayoutType.Force` */\n layoutType?: GraphLayoutType | string;\n /** Fit the graph to container on data or config updates, or on container resize. Default: `true` */\n layoutAutofit?: boolean;\n /** Tolerance constant defining whether the graph should be fitted to container\n * (on data or config update, or container resize) after a zoom / pan interaction or not.\n * `0` — Stop fitting after any pan or zoom\n * `Number.POSITIVE_INFINITY` — Always fit\n * Default: `8.0` */\n layoutAutofitTolerance?: number;\n /** Place non-connected nodes at the bottom of the graph. Default: `false` */\n layoutNonConnectedAside?: boolean;\n\n // Settings for Parallel and Concentric layouts\n /** Node group accessor function.\n * Only for `GraphLayoutType.Parallel`, `GraphLayoutType.ParallelHorizontal` and `GraphLayoutType.Concentric` layouts.\n * Default: `node => node.group` */\n layoutNodeGroup?: StringAccessor<N>;\n /** Order of the layout groups.\n * Only for `GraphLayoutType.Parallel`, `GraphLayoutType.ParallelHorizontal` and `GraphLayoutType.Concentric` layouts.\n * Default: `[]` */\n layoutGroupOrder?: string[];\n\n // Setting for Parallel layouts only\n /** Sets the number of nodes in a sub-group after which they'll continue on the next column (or row if `layoutType` is\n * `GraphLayoutType.ParallelHorizontal`).\n * Only for `GraphLayoutType.Parallel` and `GraphLayoutType.ParallelHorizontal` layouts.\n * Default: `6` */\n layoutParallelNodesPerColumn?: number;\n /** Node sub-group accessor function.\n * Only for `GraphLayoutType.Parallel` and `GraphLayoutType.ParallelHorizontal` layouts.\n * Default: `node => node.subgroup` */\n layoutParallelNodeSubGroup?: StringAccessor<N>;\n /** Number of sub-groups per row (or column if `layoutType` is `GraphLayoutType.ParallelHorizontal`) in a group.\n * Only for `GraphLayoutType.Parallel` and `GraphLayoutType.ParallelHorizontal` layouts.\n * Default: `1` */\n layoutParallelSubGroupsPerRow?: number;\n /** Spacing between nodes, dynamic by default.\n * Only for `GraphLayoutType.Parallel` and `GraphLayoutType.ParallelHorizontal` layouts.\n * Default: `undefined` */\n layoutParallelNodeSpacing?: number | [number, number];\n /** Spacing between sub-groups.\n * Only for `GraphLayoutType.Parallel` and `GraphLayoutType.ParallelHorizontal` layouts.\n * Default: `40` */\n layoutParallelSubGroupSpacing?: number;\n /** Spacing between groups.\n * Only for `GraphLayoutType.Parallel` and `GraphLayoutType.ParallelHorizontal` layouts.\n * Default: `undefined` */\n layoutParallelGroupSpacing?: number;\n /** Set a group by name to have priority in sorting the graph links.\n * Only for `GraphLayoutType.Parallel` and `GraphLayoutType.ParallelHorizontal` layouts.\n * Default: `undefined` */\n layoutParallelSortConnectionsByGroup?: string;\n\n // Force layout\n /** Force Layout settings, see the `d3-force` package for more details */\n forceLayoutSettings?: GraphForceLayoutSettings<N, L>;\n\n // Dagre layout\n /** Darge Layout settings, see the `dagrejs` package\n * for more details: https://github.com/dagrejs/dagre/wiki#configuring-the-layout\n */\n dagreLayoutSettings?: GraphDagreLayoutSetting;\n\n // ELK layout\n /** ELK layout options, see the `elkjs` package for more details: https://github.com/kieler/elkjs.\n * If you want to specify custom layout option for each node group, you can provide an accessor function that\n * receives group name ('root' for the top-level configuration) as the first argument and returns an object containing\n * layout options. Default: `undefined`\n */\n layoutElkSettings?: GenericAccessor<GraphElkLayoutSettings, string> | undefined;\n /** Array of accessor functions to define nested node groups for the ELK Layered layout.\n * E.g.: `[n => n.group, n => n.subGroup]`.\n * Default: `undefined` */\n layoutElkNodeGroups?: StringAccessor<N>[];\n /** A function to be called per graph node to get the ELK shape object.\n * This enables you to provide custom node dimensions (through the `width` and `height` properties)\n * and coordinates (through the `x` and `y` properties) if needed.\n * Default: `undefined`\n */\n layoutElkGetNodeShape?: (d: GraphNode<N, L>, i: number) => ElkShape;\n\n // Links\n /** Link width accessor function ot constant value. Default: `1` */\n linkWidth?: NumericAccessor<L>;\n /** Link style accessor function or constant value. Default: `GraphLinkStyle.Solid` */\n linkStyle?: GenericAccessor<GraphLinkStyle, L>;\n /** Link band width accessor function or constant value. Default: `0` */\n linkBandWidth?: NumericAccessor<L>;\n /** Link arrow accessor function or constant value. Default: `undefined` */\n linkArrow?: GenericAccessor<GraphLinkArrowStyle | string | boolean, L> | undefined;\n /** Link stroke color accessor function or constant value. Default: `undefined` */\n linkStroke?: ColorAccessor<L>;\n /** Link disabled state accessor function or constant value. Default: `false` */\n linkDisabled?: BooleanAccessor<L>;\n /** Link flow animation accessor function or constant value. Default: `false` */\n linkFlow?: BooleanAccessor<L>;\n /** Animation duration of the flow (traffic) circles in milliseconds. If `linkFlowParticleSpeed` is provided,\n * this duration will be calculated based on the link length and particle speed. Default: `20000` */\n linkFlowAnimDuration?: NumericAccessor<L>;\n /** Size of the moving particles that represent traffic flow. Default: `2` */\n linkFlowParticleSize?: NumericAccessor<L>;\n /** Speed of the moving particles in pixels per second. This property takes precedence over `linkFlowAnimDuration`. Default: `undefined` */\n linkFlowParticleSpeed?: NumericAccessor<L>;\n /** Link label accessor function or constant value. Default: `undefined` */\n linkLabel?: GenericAccessor<GraphCircleLabel | GraphCircleLabel[], L> | undefined;\n /** Shift label along the link center a little bit to avoid overlap with the link arrow. Default: `true` */\n linkLabelShiftFromCenter?: BooleanAccessor<L>;\n /** Spacing between neighboring links. Default: `8` */\n linkNeighborSpacing?: number;\n /** Curvature of the link. Recommended value range: [0:1.5].\n * `0` - straight line,\n * `1` - nice curvature,\n * `1.5` - very curve.\n * Default: `0` */\n linkCurvature?: NumericAccessor<L>;\n /** Highlight links on hover. Default: `true` */\n linkHighlightOnHover?: boolean;\n /** Offset [x,y] in pixels from the source node's center point where the link should start. Default: `undefined` */\n linkSourcePointOffset?: GenericAccessor<[number, number], GraphLink<N, L>>;\n /** Offset [x,y] in pixels from the target node's center point where the link should end. Default: `undefined` */\n linkTargetPointOffset?: GenericAccessor<[number, number], GraphLink<N, L>>;\n /** Set selected link by its unique id. Default: `undefined` */\n selectedLinkId?: number | string;\n\n // Nodes\n /** Node size accessor function or constant value. Default: `30` */\n nodeSize?: NumericAccessor<N>;\n /** Node stroke width accessor function or constant value. Default: `3` */\n nodeStrokeWidth?: NumericAccessor<N>;\n /** Node shape accessor function or constant value. Default: `GraphNodeShape.Circle` */\n nodeShape?: GenericAccessor<GraphNodeShape | string, N>;\n /** Node gauge outline accessor function or constant value in the range [0,100]. Default: `0` */\n nodeGaugeValue?: NumericAccessor<N>;\n /** Node gauge outline fill color accessor function or constant value. Default: `undefined` */\n nodeGaugeFill?: ColorAccessor<N>;\n /** Animation duration of the node gauge outline. Default: `1500` */\n nodeGaugeAnimDuration?: number;\n /** Node central icon accessor function or constant value. Default: `node => node.icon` */\n nodeIcon?: StringAccessor<N>;\n /** Node central icon size accessor function or constant value. Default: `undefined` */\n nodeIconSize?: NumericAccessor<N>;\n /** Node label accessor function or constant value. Default: `node => node.label` */\n nodeLabel?: StringAccessor<N>;\n /** Defines whether to trim the node labels or not. Default: `true` */\n nodeLabelTrim?: BooleanAccessor<N>;\n /** Node label trimming mode. Default: `TrimMode.Middle` */\n nodeLabelTrimMode?: GenericAccessor<TrimMode | string, N>;\n /** Node label maximum allowed text length above which the label will be trimmed. Default: `15` */\n nodeLabelTrimLength?: NumericAccessor<N>;\n /** Node sub-label accessor function or constant value: Default: `''` */\n nodeSubLabel?: StringAccessor<N>;\n /** Defines whether to trim the node sub-labels or not. Default: `true` */\n nodeSubLabelTrim?: BooleanAccessor<N>;\n /** Node sub-label trimming mode. Default: `TrimMode.Middle` */\n nodeSubLabelTrimMode?: GenericAccessor<TrimMode | string, N>;\n /** Node sub-label maximum allowed text length above which the label will be trimmed. Default: `15` */\n nodeSubLabelTrimLength?: NumericAccessor<N>;\n /** Node circular side labels accessor function. The function should return an array of GraphCircleLabel objects. Default: `undefined` */\n nodeSideLabels?: GenericAccessor<GraphCircleLabel[], N>;\n /** Node bottom icon accessor function. Default: `undefined` */\n nodeBottomIcon?: StringAccessor<N>;\n /** Node disabled state accessor function or constant value. Default: `false` */\n nodeDisabled?: BooleanAccessor<N>;\n /** Node fill color accessor function or constant value. Default: `node => node.fill` */\n nodeFill?: ColorAccessor<N>;\n /** Node stroke color accessor function or constant value. Default: `node => node.stroke` */\n nodeStroke?: ColorAccessor<N>;\n /** Sorting function to determine node placement. Default: `undefined` */\n nodeSort?: ((a: N, b: N) => number);\n /** Specify the initial position for entering nodes as [x, y]. Default: `undefined` */\n nodeEnterPosition?: GenericAccessor<[number, number], N> | undefined;\n /** Specify the initial scale for entering nodes in the range [0,1]. Default: `0.75` */\n nodeEnterScale?: NumericAccessor<N> | undefined;\n /** Specify the destination position for exiting nodes as [x, y]. Default: `undefined` */\n nodeExitPosition?: GenericAccessor<[number, number], N> | undefined;\n /** Specify the destination scale for exiting nodes in the range [0,1]. Default: `0.75` */\n nodeExitScale?: NumericAccessor<N> | undefined;\n /** Custom \"enter\" function for node rendering. Default: `undefined` */\n nodeEnterCustomRenderFunction?:\n (datum: GraphNode<N, L>, nodeGroupElementSelection: Selection<SVGGElement, GraphNode<N, L>, null, unknown>, config: GraphConfigInterface<N, L>, duration: number, zoomLevel: number) => void;\n /** Custom \"update\" function for node rendering. Default: `undefined` */\n nodeUpdateCustomRenderFunction?:\n (datum: GraphNode<N, L>, nodeGroupElementSelection: Selection<SVGGElement, GraphNode<N, L>, null, unknown>, config: GraphConfigInterface<N, L>, duration: number, zoomLevel: number) => void;\n /** Custom partial \"update\" function for node rendering which will be triggered after the following events:\n * - Full node update (`nodeUpdateCustomRenderFunction`);\n * - Background click;\n * - Node and Link mouseover and mouseout;\n * - Node brushing,\n * Default: `undefined` */\n nodePartialUpdateCustomRenderFunction?:\n (datum: GraphNode<N, L>, nodeGroupElementSelection: Selection<SVGGElement, GraphNode<N, L>, null, unknown>, config: GraphConfigInterface<N, L>, duration: number, zoomLevel: number) => void;\n /** Custom \"exit\" function for node rendering. Default: `undefined` */\n nodeExitCustomRenderFunction?:\n (datum: GraphNode<N, L>, nodeGroupElementSelection: Selection<SVGGElement, GraphNode<N, L>, null, unknown>, config: GraphConfigInterface<N, L>, duration: number, zoomLevel: number) => void;\n /** Custom render function that will be called while zooming / panning the graph. Default: `undefined` */\n nodeOnZoomCustomRenderFunction?:\n (datum: GraphNode<N, L>, nodeGroupElementSelection: Selection<SVGGElement, GraphNode<N, L>, null, unknown>, config: GraphConfigInterface<N, L>, zoomLevel: number) => void;\n /** Define the mode for highlighting selected nodes in the graph. Default: `GraphNodeSelectionHighlightMode.GreyoutNonConnected` */\n nodeSelectionHighlightMode?: GraphNodeSelectionHighlightMode;\n /** Set selected node by unique id. Default: `undefined` */\n selectedNodeId?: number | string;\n /** Set selected nodes by unique id. Default: `undefined` */\n selectedNodeIds?: number[] | string[];\n\n /** Panels configuration. An array of `GraphPanelConfig` objects. Default: `[]` */\n panels?: GraphPanelConfig[] | undefined;\n\n // Events\n /** Graph node drag start callback function. Default: `undefined` */\n onNodeDragStart?: (n: GraphNode<N, L>, event: D3DragEvent<SVGGElement, GraphNode<N, L>, unknown>) => void | undefined;\n /** Graph node drag callback function. Default: `undefined` */\n onNodeDrag?: (n: GraphNode<N, L>, event: D3DragEvent<SVGGElement, GraphNode<N, L>, unknown>) => void | undefined;\n /** Graph node drag end callback function. Default: `undefined` */\n onNodeDragEnd?: (n: GraphNode<N, L>, event: D3DragEvent<SVGGElement, GraphNode<N, L>, unknown>) => void | undefined;\n /** Zoom event callback. Default: `undefined` */\n onZoom?: (zoomScale: number, zoomScaleExtent: [number, number], event: D3ZoomEvent<SVGGElement, unknown> | undefined, transform: ZoomTransform) => void;\n /** Zoom start event callback. Default: `undefined` */\n onZoomStart?: (zoomScale: number, zoomScaleExtent: [number, number], event: D3ZoomEvent<SVGGElement, unknown> | undefined, transform: ZoomTransform) => void;\n /** Zoom end event callback. Default: `undefined` */\n onZoomEnd?: (zoomScale: number, zoomScaleExtent: [number, number], event: D3ZoomEvent<SVGGElement, unknown> | undefined, transform: ZoomTransform) => void;\n /** Callback function to be called when the graph layout is calculated. Default: `undefined` */\n onLayoutCalculated?: (nodes: GraphNode<N, L>[], links: GraphLink<N, L>[]) => void;\n /** Graph node selection brush callback function. Default: `undefined` */\n onNodeSelectionBrush?: (selectedNodes: GraphNode<N, L>[], event: D3BrushEvent<SVGGElement> | undefined) => void;\n /** Graph multiple node drag callback function. Default: `undefined` */\n onNodeSelectionDrag?: (selectedNodes: GraphNode<N, L>[], event: D3DragEvent<SVGGElement, GraphNode<N, L>, unknown>) => void;\n /** Callback function to be called when the graph rendering is complete. Default: `undefined` */\n onRenderComplete?: (\n g: Selection<SVGGElement, unknown, null, undefined>,\n nodes: GraphNode<N, L>[],\n links: GraphLink<N, L>[],\n config: GraphConfigInterface<N, L>,\n duration: number,\n zoomLevel: number,\n width: number,\n height: number\n ) => void;\n\n /** Determines whether the component should update when new data is provided.\n * This function takes the previous and new data as parameters and returns a boolean\n * indicating whether the update should proceed. Useful for fine-grained control over\n * update behavior when your data has a complex nested structure.\n * By default the `isEqual` function from Unovis will be used to do the comparison.\n */\n shouldDataUpdate?: (\n prevData: GraphInputData<N, L>,\n nextData: GraphInputData<N, L>,\n datamodel: GraphDataModel<N, L, GraphNode<N, L>, GraphLink<N, L>>\n ) => boolean;\n}\n\nexport const GraphDefaultConfig: GraphConfigInterface<GraphInputNode, GraphInputLink> = {\n ...ComponentDefaultConfig,\n duration: 1000,\n zoomScaleExtent: [0.35, 1.25],\n disableZoom: false,\n zoomEventFilter: undefined,\n disableDrag: false,\n disableBrush: false,\n zoomThrottledUpdateNodeThreshold: 100,\n layoutType: GraphLayoutType.Force,\n layoutAutofit: true,\n layoutAutofitTolerance: 8.0,\n layoutNonConnectedAside: false,\n fitViewPadding: 50,\n fitViewAlign: GraphFitViewAlignment.Center,\n\n layoutGroupOrder: [],\n layoutParallelNodeSpacing: undefined,\n layoutParallelSubGroupsPerRow: 1,\n layoutParallelNodesPerColumn: 6,\n layoutParallelGroupSpacing: undefined,\n layoutParallelSubGroupSpacing: 40,\n layoutParallelSortConnectionsByGroup: undefined,\n layoutNodeGroup: (n: GraphInputNode): string => (n as { group: string }).group,\n layoutParallelNodeSubGroup: (n: GraphInputNode): string => (n as { subgroup: string }).subgroup,\n\n forceLayoutSettings: {\n linkDistance: 60,\n linkStrength: 0.45,\n charge: -500,\n forceXStrength: 0.15,\n forceYStrength: 0.25,\n numIterations: undefined,\n fixNodePositionAfterSimulation: false,\n },\n\n dagreLayoutSettings: {\n rankdir: 'BT',\n ranker: 'longest-path',\n },\n\n layoutElkSettings: undefined,\n layoutElkNodeGroups: undefined,\n layoutElkGetNodeShape: undefined,\n\n linkFlowAnimDuration: 20000,\n linkFlowParticleSize: 2,\n linkFlowParticleSpeed: undefined,\n linkWidth: 1,\n linkStyle: GraphLinkStyle.Solid,\n linkBandWidth: 0,\n linkArrow: undefined,\n linkStroke: undefined,\n linkFlow: false,\n linkLabel: undefined,\n linkLabelShiftFromCenter: true,\n linkNeighborSpacing: 8,\n linkDisabled: false,\n linkCurvature: 0,\n linkHighlightOnHover: true,\n linkSourcePointOffset: undefined,\n linkTargetPointOffset: undefined,\n selectedLinkId: undefined,\n\n nodeSize: 30,\n nodeStrokeWidth: 3,\n nodeShape: GraphNodeShape.Circle,\n nodeGaugeValue: 0,\n nodeIcon: (n: GraphInputNode): string => (n as { icon: string }).icon,\n nodeIconSize: undefined,\n nodeLabel: (n: GraphInputNode): string => (n as { label: string }).label,\n nodeLabelTrim: true,\n nodeLabelTrimLength: 15,\n nodeLabelTrimMode: TrimMode.Middle,\n nodeSubLabel: '',\n nodeSubLabelTrim: true,\n nodeSubLabelTrimLength: 15,\n nodeSubLabelTrimMode: TrimMode.Middle,\n nodeSideLabels: undefined,\n nodeBottomIcon: undefined,\n nodeDisabled: false,\n nodeFill: (n: GraphInputNode): string => (n as { fill: string }).fill,\n nodeGaugeFill: undefined,\n nodeStroke: (n: GraphInputNode): string => (n as { stroke: string }).stroke,\n nodeEnterPosition: undefined,\n nodeEnterScale: 0.75,\n nodeExitPosition: undefined,\n nodeExitScale: 0.75,\n nodeSort: undefined,\n nodeSelectionHighlightMode: GraphNodeSelectionHighlightMode.GreyoutNonConnected,\n nodeGaugeAnimDuration: 1500,\n\n selectedNodeId: undefined,\n selectedNodeIds: undefined,\n\n panels: undefined,\n\n onNodeDragStart: undefined,\n onNodeDrag: undefined,\n onNodeDragEnd: undefined,\n onZoom: undefined,\n onZoomStart: undefined,\n onZoomEnd: undefined,\n onLayoutCalculated: undefined,\n onNodeSelectionBrush: undefined,\n onNodeSelectionDrag: undefined,\n onRenderComplete: undefined,\n\n shouldDataUpdate: (prevData: GraphInputData<GraphInputNode, GraphInputLink>, nextData: GraphInputData<GraphInputNode, GraphInputLink>): boolean => {\n return !isEqual(prevData, nextData)\n },\n}\n"],"names":[],"mappings":";;;;;AASA;AA+Sa,MAAA,kBAAkB,GAC1B,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAAA,sBAAsB,CACzB,EAAA,EAAA,QAAQ,EAAE,IAAI,EACd,eAAe,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,EAC7B,WAAW,EAAE,KAAK,EAClB,eAAe,EAAE,SAAS,EAC1B,WAAW,EAAE,KAAK,EAClB,YAAY,EAAE,KAAK,EACnB,gCAAgC,EAAE,GAAG,EACrC,UAAU,EAAE,eAAe,CAAC,KAAK,EACjC,aAAa,EAAE,IAAI,EACnB,sBAAsB,EAAE,GAAG,EAC3B,uBAAuB,EAAE,KAAK,EAC9B,cAAc,EAAE,EAAE,EAClB,YAAY,EAAE,qBAAqB,CAAC,MAAM,EAE1C,gBAAgB,EAAE,EAAE,EACpB,yBAAyB,EAAE,SAAS,EACpC,6BAA6B,EAAE,CAAC,EAChC,4BAA4B,EAAE,CAAC,EAC/B,0BAA0B,EAAE,SAAS,EACrC,6BAA6B,EAAE,EAAE,EACjC,oCAAoC,EAAE,SAAS,EAC/C,eAAe,EAAE,CAAC,CAAiB,KAAc,CAAuB,CAAC,KAAK,EAC9E,0BAA0B,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,EACvB,iBAAiB,EAAE,QAAQ,CAAC,MAAM,EAClC,YAAY,EAAE,EAAE,EAChB,gBAAgB,EAAE,IAAI,EACtB,sBAAsB,EAAE,EAAE,EAC1B,oBAAoB,EAAE,QAAQ,CAAC,MAAM,EACrC,cAAc,EAAE,SAAS,EACzB,cAAc,EAAE,SAAS,EACzB,YAAY,EAAE,KAAK,EACnB,QAAQ,EAAE,CAAC,CAAiB,KAAc,CAAsB,CAAC,IAAI,EACrE,aAAa,EAAE,SAAS,EACxB,UAAU,EAAE,CAAC,CAAiB,KAAc,CAAwB,CAAC,MAAM,EAC3E,iBAAiB,EAAE,SAAS,EAC5B,cAAc,EAAE,IAAI,EACpB,gBAAgB,EAAE,SAAS,EAC3B,aAAa,EAAE,IAAI,EACnB,QAAQ,EAAE,SAAS,EACnB,0BAA0B,EAAE,+BAA+B,CAAC,mBAAmB,EAC/E,qBAAqB,EAAE,IAAI,EAE3B,cAAc,EAAE,SAAS,EACzB,eAAe,EAAE,SAAS,EAE1B,MAAM,EAAE,SAAS,EAEjB,eAAe,EAAE,SAAS,EAC1B,UAAU,EAAE,SAAS,EACrB,aAAa,EAAE,SAAS,EACxB,MAAM,EAAE,SAAS,EACjB,WAAW,EAAE,SAAS,EACtB,SAAS,EAAE,SAAS,EACpB,kBAAkB,EAAE,SAAS,EAC7B,oBAAoB,EAAE,SAAS,EAC/B,mBAAmB,EAAE,SAAS,EAC9B,gBAAgB,EAAE,SAAS,EAE3B,gBAAgB,EAAE,CAAC,QAAwD,EAAE,QAAwD,KAAa;AAChJ,QAAA,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;AACrC,KAAC;;;;"}
@@ -62,6 +62,7 @@ export declare class Graph<N extends GraphInputNode, L extends GraphInputLink> e
62
62
  private _brushBehavior;
63
63
  private _groupDragInit;
64
64
  private _linkPathLengthMap;
65
+ private _linkFlowFrameElapsed;
65
66
  events: {
66
67
  [x: string]: {
67
68
  click: () => void;
@@ -37,6 +37,7 @@ class Graph extends ComponentCore {
37
37
  this._isDragging = false;
38
38
  // A map for storing link total path lengths to optimize rendering performance
39
39
  this._linkPathLengthMap = new Map();
40
+ this._linkFlowFrameElapsed = 0;
40
41
  this.events = {
41
42
  [Graph.selectors.background]: {
42
43
  click: this._onBackgroundClick.bind(this),
@@ -521,20 +522,24 @@ class Graph extends ComponentCore {
521
522
  const hasLinksWithFlow = links.some((d, i) => getBoolean(d, config.linkFlow, i));
522
523
  if (!hasLinksWithFlow)
523
524
  return;
525
+ const deltaTime = elapsed - this._linkFlowFrameElapsed;
524
526
  const linkGroups = this._linksGroup.selectAll(`.${gLink}`);
525
527
  linkGroups.each((l, i, els) => {
526
528
  var _a;
527
- let linkFlowAnimDuration = getNumber(l, config.linkFlowAnimDuration, l._indexGlobal);
528
529
  const linkFlowParticleSpeed = getNumber(l, config.linkFlowParticleSpeed, l._indexGlobal);
529
- // If particle speed is provided, calculate duration based on link length and speed
530
- if (linkFlowParticleSpeed) {
531
- const linkPathElement = els[i].querySelector(`.${linkSupport}`);
532
- const pathLength = linkPathElement ? ((_a = this._linkPathLengthMap.get(linkPathElement.getAttribute('d'))) !== null && _a !== void 0 ? _a : linkPathElement.getTotalLength()) : 0;
533
- if (pathLength > 0)
534
- linkFlowAnimDuration = (pathLength / linkFlowParticleSpeed) * 1000; // Convert to milliseconds
535
- }
536
- l._state.flowAnimTime = (elapsed % linkFlowAnimDuration) / linkFlowAnimDuration;
530
+ // Get path length
531
+ const pathElement = els[i].querySelector(`.${linkSupport}`);
532
+ const pathLength = pathElement ? ((_a = this._linkPathLengthMap.get(pathElement.getAttribute('d'))) !== null && _a !== void 0 ? _a : pathElement.getTotalLength()) : 0;
533
+ if (pathLength <= 0)
534
+ return; // Skip if no valid path
535
+ // Calculate speed: either provided or derived from duration
536
+ const speed = linkFlowParticleSpeed || (pathLength / getNumber(l, config.linkFlowAnimDuration, l._indexGlobal) * 1000);
537
+ // Initialize and update distance
538
+ l._state.flowAnimDistancePx = (l._state.flowAnimDistancePx || 0) + (deltaTime / 1000) * speed;
539
+ // Convert to relative position
540
+ l._state.flowAnimDistanceRelative = (l._state.flowAnimDistancePx % pathLength) / pathLength;
537
541
  });
542
+ this._linkFlowFrameElapsed = elapsed;
538
543
  animateLinkFlow(linkGroups, this.config, this._scale, this._linkPathLengthMap);
539
544
  }
540
545
  _onZoom(t, event) {