@cosmos.gl/graph 2.6.0 → 2.6.2-rc.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/dist/config.d.ts +3 -0
  2. package/dist/index.d.ts +48 -6
  3. package/dist/index.js +1346 -1289
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.min.js +15 -15
  6. package/dist/index.min.js.map +1 -1
  7. package/package.json +5 -1
  8. package/.eslintrc +0 -147
  9. package/.github/SECURITY.md +0 -19
  10. package/.github/dco.yml +0 -4
  11. package/.github/workflows/github_pages.yml +0 -54
  12. package/.storybook/main.ts +0 -26
  13. package/.storybook/manager-head.html +0 -1
  14. package/.storybook/manager.ts +0 -14
  15. package/.storybook/preview.ts +0 -29
  16. package/.storybook/style.css +0 -3
  17. package/CHARTER.md +0 -69
  18. package/CODE_OF_CONDUCT.md +0 -178
  19. package/CONTRIBUTING.md +0 -22
  20. package/GOVERNANCE.md +0 -21
  21. package/cosmos-2-0-migration-notes.md +0 -98
  22. package/cosmos_awesome.md +0 -96
  23. package/dist/stories/beginners/basic-set-up/data-gen.d.ts +0 -4
  24. package/dist/stories/beginners/basic-set-up/index.d.ts +0 -5
  25. package/dist/stories/beginners/link-hovering/data-generator.d.ts +0 -19
  26. package/dist/stories/beginners/link-hovering/index.d.ts +0 -5
  27. package/dist/stories/beginners/pinned-points/data-gen.d.ts +0 -5
  28. package/dist/stories/beginners/pinned-points/index.d.ts +0 -5
  29. package/dist/stories/beginners/point-labels/data.d.ts +0 -13
  30. package/dist/stories/beginners/point-labels/index.d.ts +0 -9
  31. package/dist/stories/beginners/point-labels/labels.d.ts +0 -8
  32. package/dist/stories/beginners/quick-start.d.ts +0 -5
  33. package/dist/stories/beginners/remove-points/config.d.ts +0 -2
  34. package/dist/stories/beginners/remove-points/data-gen.d.ts +0 -4
  35. package/dist/stories/beginners/remove-points/index.d.ts +0 -5
  36. package/dist/stories/beginners.stories.d.ts +0 -11
  37. package/dist/stories/clusters/polygon-selection/index.d.ts +0 -6
  38. package/dist/stories/clusters/polygon-selection/polygon.d.ts +0 -20
  39. package/dist/stories/clusters/radial.d.ts +0 -5
  40. package/dist/stories/clusters/with-labels.d.ts +0 -6
  41. package/dist/stories/clusters/worm.d.ts +0 -5
  42. package/dist/stories/clusters.stories.d.ts +0 -9
  43. package/dist/stories/create-cluster-labels.d.ts +0 -4
  44. package/dist/stories/create-cosmos.d.ts +0 -16
  45. package/dist/stories/create-story.d.ts +0 -16
  46. package/dist/stories/experiments/full-mesh.d.ts +0 -5
  47. package/dist/stories/experiments/mesh-with-holes.d.ts +0 -5
  48. package/dist/stories/experiments.stories.d.ts +0 -7
  49. package/dist/stories/generate-mesh-data.d.ts +0 -12
  50. package/dist/stories/geospatial/moscow-metro-stations/index.d.ts +0 -15
  51. package/dist/stories/geospatial/moscow-metro-stations/moscow-metro-coords.d.ts +0 -1
  52. package/dist/stories/geospatial/moscow-metro-stations/point-colors.d.ts +0 -1
  53. package/dist/stories/geospatial.stories.d.ts +0 -6
  54. package/dist/stories/shapes/all-shapes/index.d.ts +0 -5
  55. package/dist/stories/shapes/image-example/index.d.ts +0 -5
  56. package/dist/stories/shapes.stories.d.ts +0 -7
  57. package/logo.svg +0 -3
  58. package/rollup.config.js +0 -70
  59. package/src/config.ts +0 -734
  60. package/src/declaration.d.ts +0 -12
  61. package/src/graph/utils/error-message.ts +0 -23
  62. package/src/helper.ts +0 -74
  63. package/src/index.ts +0 -1635
  64. package/src/modules/Clusters/calculate-centermass.frag +0 -9
  65. package/src/modules/Clusters/calculate-centermass.vert +0 -26
  66. package/src/modules/Clusters/force-cluster.frag +0 -39
  67. package/src/modules/Clusters/index.ts +0 -200
  68. package/src/modules/Drag/index.ts +0 -33
  69. package/src/modules/FPSMonitor/css.ts +0 -53
  70. package/src/modules/FPSMonitor/index.ts +0 -28
  71. package/src/modules/ForceCenter/calculate-centermass.frag +0 -9
  72. package/src/modules/ForceCenter/calculate-centermass.vert +0 -18
  73. package/src/modules/ForceCenter/force-center.frag +0 -27
  74. package/src/modules/ForceCenter/index.ts +0 -104
  75. package/src/modules/ForceGravity/force-gravity.frag +0 -27
  76. package/src/modules/ForceGravity/index.ts +0 -33
  77. package/src/modules/ForceLink/force-spring.ts +0 -73
  78. package/src/modules/ForceLink/index.ts +0 -149
  79. package/src/modules/ForceManyBody/calculate-level.frag +0 -9
  80. package/src/modules/ForceManyBody/calculate-level.vert +0 -25
  81. package/src/modules/ForceManyBody/force-centermass.frag +0 -52
  82. package/src/modules/ForceManyBody/force-level.frag +0 -121
  83. package/src/modules/ForceManyBody/index.ts +0 -223
  84. package/src/modules/ForceManyBody/quadtree-frag-shader.ts +0 -90
  85. package/src/modules/ForceManyBodyQuadtree/calculate-level.frag +0 -9
  86. package/src/modules/ForceManyBodyQuadtree/calculate-level.vert +0 -25
  87. package/src/modules/ForceManyBodyQuadtree/index.ts +0 -157
  88. package/src/modules/ForceManyBodyQuadtree/quadtree-frag-shader.ts +0 -93
  89. package/src/modules/ForceMouse/force-mouse.frag +0 -24
  90. package/src/modules/ForceMouse/index.ts +0 -32
  91. package/src/modules/GraphData/index.ts +0 -384
  92. package/src/modules/Lines/draw-curve-line.frag +0 -46
  93. package/src/modules/Lines/draw-curve-line.vert +0 -194
  94. package/src/modules/Lines/geometry.ts +0 -18
  95. package/src/modules/Lines/hovered-line-index.frag +0 -27
  96. package/src/modules/Lines/hovered-line-index.vert +0 -8
  97. package/src/modules/Lines/index.ts +0 -273
  98. package/src/modules/Points/atlas-utils.ts +0 -137
  99. package/src/modules/Points/drag-point.frag +0 -20
  100. package/src/modules/Points/draw-highlighted.frag +0 -16
  101. package/src/modules/Points/draw-highlighted.vert +0 -86
  102. package/src/modules/Points/draw-points.frag +0 -243
  103. package/src/modules/Points/draw-points.vert +0 -127
  104. package/src/modules/Points/fill-sampled-points.frag +0 -9
  105. package/src/modules/Points/fill-sampled-points.vert +0 -29
  106. package/src/modules/Points/find-hovered-point.frag +0 -9
  107. package/src/modules/Points/find-hovered-point.vert +0 -57
  108. package/src/modules/Points/find-points-on-area-selection.frag +0 -48
  109. package/src/modules/Points/find-points-on-polygon-selection.frag +0 -65
  110. package/src/modules/Points/index.ts +0 -968
  111. package/src/modules/Points/track-positions.frag +0 -18
  112. package/src/modules/Points/update-position.frag +0 -37
  113. package/src/modules/Shared/buffer.ts +0 -37
  114. package/src/modules/Shared/clear.frag +0 -7
  115. package/src/modules/Shared/quad.vert +0 -12
  116. package/src/modules/Store/index.ts +0 -173
  117. package/src/modules/Zoom/index.ts +0 -148
  118. package/src/modules/core-module.ts +0 -28
  119. package/src/stories/1. welcome.mdx +0 -81
  120. package/src/stories/2. configuration.mdx +0 -113
  121. package/src/stories/3. api-reference.mdx +0 -591
  122. package/src/stories/beginners/basic-set-up/data-gen.ts +0 -33
  123. package/src/stories/beginners/basic-set-up/index.ts +0 -163
  124. package/src/stories/beginners/basic-set-up/style.css +0 -35
  125. package/src/stories/beginners/link-hovering/data-generator.ts +0 -198
  126. package/src/stories/beginners/link-hovering/index.ts +0 -61
  127. package/src/stories/beginners/link-hovering/style.css +0 -73
  128. package/src/stories/beginners/pinned-points/data-gen.ts +0 -153
  129. package/src/stories/beginners/pinned-points/index.ts +0 -61
  130. package/src/stories/beginners/point-labels/data.ts +0 -73
  131. package/src/stories/beginners/point-labels/index.ts +0 -65
  132. package/src/stories/beginners/point-labels/labels.ts +0 -46
  133. package/src/stories/beginners/point-labels/style.css +0 -16
  134. package/src/stories/beginners/quick-start.ts +0 -50
  135. package/src/stories/beginners/remove-points/config.ts +0 -25
  136. package/src/stories/beginners/remove-points/data-gen.ts +0 -30
  137. package/src/stories/beginners/remove-points/index.ts +0 -92
  138. package/src/stories/beginners/remove-points/style.css +0 -31
  139. package/src/stories/beginners.stories.ts +0 -131
  140. package/src/stories/clusters/polygon-selection/index.ts +0 -51
  141. package/src/stories/clusters/polygon-selection/polygon.ts +0 -143
  142. package/src/stories/clusters/polygon-selection/style.css +0 -8
  143. package/src/stories/clusters/radial.ts +0 -24
  144. package/src/stories/clusters/with-labels.ts +0 -53
  145. package/src/stories/clusters/worm.ts +0 -40
  146. package/src/stories/clusters.stories.ts +0 -77
  147. package/src/stories/create-cluster-labels.ts +0 -50
  148. package/src/stories/create-cosmos.ts +0 -68
  149. package/src/stories/create-story.ts +0 -51
  150. package/src/stories/experiments/full-mesh.ts +0 -13
  151. package/src/stories/experiments/mesh-with-holes.ts +0 -13
  152. package/src/stories/experiments.stories.ts +0 -43
  153. package/src/stories/generate-mesh-data.ts +0 -125
  154. package/src/stories/geospatial/moscow-metro-stations/index.ts +0 -62
  155. package/src/stories/geospatial/moscow-metro-stations/moscow-metro-coords.ts +0 -1
  156. package/src/stories/geospatial/moscow-metro-stations/point-colors.ts +0 -46
  157. package/src/stories/geospatial/moscow-metro-stations/style.css +0 -30
  158. package/src/stories/geospatial.stories.ts +0 -30
  159. package/src/stories/shapes/all-shapes/index.ts +0 -69
  160. package/src/stories/shapes/image-example/icons/box.png +0 -0
  161. package/src/stories/shapes/image-example/icons/lego.png +0 -0
  162. package/src/stories/shapes/image-example/icons/s.png +0 -0
  163. package/src/stories/shapes/image-example/icons/swift.png +0 -0
  164. package/src/stories/shapes/image-example/icons/toolbox.png +0 -0
  165. package/src/stories/shapes/image-example/index.ts +0 -238
  166. package/src/stories/shapes.stories.ts +0 -37
  167. package/src/variables.ts +0 -68
  168. package/tsconfig.json +0 -41
  169. package/vite.config.ts +0 -54
package/src/config.ts DELETED
@@ -1,734 +0,0 @@
1
- /* eslint-disable @typescript-eslint/naming-convention */
2
- import { D3ZoomEvent } from 'd3-zoom'
3
- import { D3DragEvent } from 'd3-drag'
4
- import {
5
- defaultPointColor,
6
- defaultGreyoutPointOpacity,
7
- defaultGreyoutPointColor,
8
- defaultPointOpacity,
9
- defaultPointSize,
10
- defaultLinkColor,
11
- defaultGreyoutLinkOpacity,
12
- defaultLinkOpacity,
13
- defaultLinkWidth,
14
- defaultBackgroundColor,
15
- defaultConfigValues,
16
- } from '@/graph/variables'
17
- import { isPlainObject } from '@/graph/helper'
18
- import { type Hovered } from '@/graph/modules/Store'
19
-
20
- export interface GraphConfigInterface {
21
- /**
22
- * If set to `false`, the simulation will not run.
23
- * This property will be applied only on component initialization and it
24
- * can't be changed using the `setConfig` method.
25
- * Default value: `true`
26
- */
27
- enableSimulation?: boolean;
28
- /**
29
- * Canvas background color.
30
- * Can be either a hex color string (e.g., '#b3b3b3') or an array of RGBA values.
31
- * Default value: '#222222'
32
- */
33
- backgroundColor?: string | [number, number, number, number];
34
- /**
35
- * Simulation space size (max 8192).
36
- * Default value: `8192`
37
- */
38
- spaceSize?: number;
39
-
40
- /**
41
- * The default color to use for points when no point colors are provided,
42
- * or if the color value in the array is `undefined` or `null`.
43
- * This can be either a hex color string (e.g., '#b3b3b3') or an array of RGBA values
44
- * in the format `[red, green, blue, alpha]` where each value is a number between 0 and 255.
45
- * Default value: '#b3b3b3'
46
- */
47
- pointDefaultColor?: string | [number, number, number, number];
48
-
49
- /** @deprecated Use `pointDefaultColor` instead */
50
- pointColor?: string | [number, number, number, number];
51
-
52
- /**
53
- * The color to use for points when they are greyed out (when selection is active).
54
- * This can be either a hex color string (e.g., '#b3b3b3') or an array of RGBA values
55
- * in the format `[red, green, blue, alpha]` where each value is a number between 0 and 255.
56
- *
57
- * If not provided, the color will be the same as the point's original color,
58
- * but darkened or lightened depending on the background color.
59
- *
60
- * If `pointGreyoutOpacity` is also defined, it will override the alpha/opacity component
61
- * of this color.
62
- *
63
- * Default value: `undefined`
64
- */
65
- pointGreyoutColor?: string | [number, number, number, number];
66
-
67
- /**
68
- * Opacity value for points when they are greyed out (when selection is active).
69
- * Values range from 0 (completely transparent) to 1 (fully opaque).
70
- *
71
- * If defined, this value will override the alpha/opacity component of `pointGreyoutColor`.
72
- *
73
- * Default value: `undefined`
74
- */
75
- pointGreyoutOpacity?: number;
76
-
77
- /**
78
- * The default size value to use for points when no point sizes are provided or
79
- * if the size value in the array is `undefined` or `null`.
80
- * Default value: `4`
81
- */
82
- pointSize?: number;
83
-
84
- /**
85
- * Universal opacity value applied to all points.
86
- * This value multiplies with individual point alpha values (if set via setPointColors).
87
- * Useful for dynamically controlling opacity of all points without updating individual RGBA arrays.
88
- * Default value: `1.0`
89
- */
90
- pointOpacity?: number;
91
-
92
- /**
93
- * Scale factor for the point size.
94
- * Default value: `1`
95
- */
96
- pointSizeScale?: number;
97
-
98
- /**
99
- * Cursor style to use when hovering over a point
100
- * Default value: `auto`
101
- */
102
- hoveredPointCursor?: string;
103
-
104
- /**
105
- * Cursor style to use when hovering over a link
106
- * Default value: `auto`
107
- */
108
- hoveredLinkCursor?: string;
109
-
110
- /**
111
- * Turns ring rendering around a point on hover on / off
112
- * Default value: `false`
113
- */
114
- renderHoveredPointRing?: boolean;
115
-
116
- /**
117
- * Hovered point ring color hex value.
118
- * Can be either a hex color string (e.g., '#b3b3b3') or an array of RGBA values.
119
- * Default value: `white`
120
- */
121
- hoveredPointRingColor?: string | [number, number, number, number];
122
-
123
- /**
124
- * Focused point ring color hex value.
125
- * Can be either a hex color string (e.g., '#b3b3b3') or an array of RGBA values.
126
- * Default value: `white`
127
- */
128
- focusedPointRingColor?: string | [number, number, number, number];
129
-
130
- /**
131
- * Set focus on a point by index. A ring will be highlighted around the focused point.
132
- * When set to `undefined`, no point is focused.
133
- * Default value: `undefined`
134
- */
135
- focusedPointIndex?: number;
136
-
137
- /**
138
- * Turns link rendering on / off.
139
- * Default value: `true`
140
- */
141
- renderLinks?: boolean;
142
-
143
- /**
144
- * The default color to use for links when no link colors are provided,
145
- * or if the color value in the array is `undefined` or `null`.
146
- * This can be either a hex color string (e.g., '#666666') or an array of RGBA values
147
- * in the format `[red, green, blue, alpha]` where each value is a number between 0 and 255.
148
- * Default value: '#666666'
149
- */
150
- linkColor?: string | [number, number, number, number];
151
-
152
- /**
153
- * Universal opacity value applied to all links.
154
- * This value multiplies with individual link alpha values (if set via setLinkColors).
155
- * Useful for dynamically controlling opacity of all links without updating individual RGBA arrays.
156
- * Default value: `1.0`
157
- */
158
- linkOpacity?: number;
159
-
160
- /**
161
- * Greyed out link opacity value when the selection is active.
162
- * Default value: `0.1`
163
- */
164
- linkGreyoutOpacity?: number;
165
- /**
166
- * The default width value to use for links when no link widths are provided or if the width value in the array is `undefined` or `null`.
167
- * Default value: `1`
168
- */
169
- linkWidth?: number;
170
- /**
171
- * The color to use for links when they are hovered.
172
- * This can be either a hex color string (e.g., '#ff3333') or an array of RGBA values
173
- * in the format `[red, green, blue, alpha]` where each value is a number between 0 and 255.
174
- * Default value: `undefined`
175
- */
176
- hoveredLinkColor?: string | [number, number, number, number];
177
- /**
178
- * Number of pixels to add to the link width when hovered.
179
- * The hovered width is calculated as: originalWidth + hoveredLinkWidthIncrease
180
- * Default value: `5`
181
- */
182
- hoveredLinkWidthIncrease?: number;
183
- /**
184
- * Scale factor for the link width.
185
- * Default value: `1`
186
- */
187
- linkWidthScale?: number;
188
- /**
189
- * Increase or decrease the size of the links when zooming in or out.
190
- * Default value: `false`
191
- */
192
- scaleLinksOnZoom?: boolean;
193
- /**
194
- * If set to true, links are rendered as curved lines.
195
- * Otherwise as straight lines.
196
- * Default value: `false`
197
- */
198
- curvedLinks?: boolean;
199
- /**
200
- * Number of segments in a curved line.
201
- * Default value: `19`.
202
- */
203
- curvedLinkSegments?: number;
204
- /**
205
- * Weight affects the shape of the curve.
206
- * Default value: `0.8`.
207
- */
208
- curvedLinkWeight?: number;
209
- /**
210
- * Defines the position of the control point of the curve on the normal from the centre of the line.
211
- * If set to 1 then the control point is at a distance equal to the length of the line.
212
- * Default value: `0.5`
213
- */
214
- curvedLinkControlPointDistance?: number;
215
- /**
216
- * The default link arrow value that controls whether or not to display link arrows.
217
- * Default value: `false`
218
- */
219
- linkArrows?: boolean;
220
- /**
221
- * Scale factor for the link arrows size.
222
- * Default value: `1`
223
- */
224
- linkArrowsSizeScale?: number;
225
- /**
226
- * The range defines the minimum and maximum link visibility distance in pixels.
227
- * The link will be fully opaque when its length is less than the first number in the array,
228
- * and will have `linkVisibilityMinTransparency` transparency when its length is greater than
229
- * the second number in the array.
230
- * This distance is defined in screen space coordinates and will change as you zoom in and out
231
- * (e.g. links become longer when you zoom in, and shorter when you zoom out).
232
- * Default value: `[50, 150]`
233
- */
234
- linkVisibilityDistanceRange?: number[];
235
- /**
236
- * The transparency value that the link will have when its length reaches
237
- * the maximum link distance value from `linkVisibilityDistanceRange`.
238
- * Default value: `0.25`
239
- */
240
- linkVisibilityMinTransparency?: number;
241
- /**
242
- * Use the classic quadtree algorithm for the Many-Body force.
243
- * This property will be applied only on component initialization and it
244
- * can't be changed using the `setConfig` method.
245
- * Default value: `false`
246
- */
247
- useClassicQuadtree?: boolean;
248
-
249
- /**
250
- * Decay coefficient. Use smaller values if you want the simulation to "cool down" slower.
251
- * Default value: `5000`
252
- */
253
- simulationDecay?: number;
254
- /**
255
- * Gravity force coefficient.
256
- * Default value: `0.25`
257
- */
258
- simulationGravity?: number;
259
- /**
260
- * Centering to center mass force coefficient.
261
- * Default value: `0`
262
- */
263
- simulationCenter?: number;
264
- /**
265
- * Repulsion force coefficient.
266
- * Default value: `1.0`
267
- */
268
- simulationRepulsion?: number;
269
- /**
270
- * Decreases / increases the detalization of the Many-Body force calculations.
271
- * When `useClassicQuadtree` is set to `true`, this property corresponds to the Barnes–Hut approximation criterion.
272
- * Default value: `1.15`
273
- */
274
- simulationRepulsionTheta?: number;
275
- /**
276
- * Barnes–Hut approximation depth.
277
- * Can only be used when `useClassicQuadtree` is set `true`.
278
- * Default value: `12`
279
- */
280
- simulationRepulsionQuadtreeLevels?: number;
281
- /**
282
- * Link spring force coefficient.
283
- * Default value: `1`
284
- */
285
- simulationLinkSpring?: number;
286
- /**
287
- * Minimum link distance.
288
- * Default value: `10`
289
- */
290
- simulationLinkDistance?: number;
291
- /**
292
- * Range of random link distance values.
293
- * Default value: `[1, 1.2]`
294
- */
295
- simulationLinkDistRandomVariationRange?: number[];
296
- /**
297
- * Repulsion coefficient from mouse position.
298
- * The repulsion force is activated by pressing the right mouse button.
299
- * Default value: `2`
300
- */
301
- simulationRepulsionFromMouse?: number;
302
- /**
303
- * Enable or disable the repulsion force from mouse when right-clicking.
304
- * When set to `true`, holding the right mouse button will activate the mouse repulsion force.
305
- * When set to `false`, right-clicking will not trigger any repulsion force.
306
- * Default value: `false`
307
- */
308
- enableRightClickRepulsion?: boolean;
309
- /**
310
- * Friction coefficient.
311
- * Values range from 0 (high friction, stops quickly) to 1 (no friction, keeps moving).
312
- * Default value: `0.85`
313
- */
314
- simulationFriction?: number;
315
- /**
316
- * Cluster coefficient.
317
- * Default value: `0.1`
318
- */
319
- simulationCluster?: number;
320
-
321
- /**
322
- * Callback function that will be called when the simulation starts.
323
- * Default value: `undefined`
324
- */
325
- onSimulationStart?: () => void;
326
- /**
327
- * Callback function that will be called on every simulation tick.
328
- * The value of the first argument `alpha` will decrease over time as the simulation "cools down".
329
- * If there's a point under the mouse pointer, its index will be passed as the second argument
330
- * and position as the third argument:
331
- * `(alpha: number, hoveredIndex: number | undefined, pointPosition: [number, number] | undefined) => void`.
332
- * Default value: `undefined`
333
- */
334
- onSimulationTick?: (
335
- alpha: number, hoveredIndex?: number, pointPosition?: [number, number]
336
- ) => void;
337
- /**
338
- * Callback function that will be called when the simulation stops.
339
- * Default value: `undefined`
340
- */
341
- onSimulationEnd?: () => void;
342
- /**
343
- * Callback function that will be called when the simulation gets paused.
344
- * Default value: `undefined`
345
- */
346
- onSimulationPause?: () => void;
347
- /**
348
- * Callback function that will be called when the simulation is restarted.
349
- * @deprecated Use `onSimulationUnpause` instead. This callback will be removed in a future version.
350
- * Default value: `undefined`
351
- */
352
- onSimulationRestart?: () => void;
353
- /**
354
- * Callback function that will be called when the simulation is unpaused.
355
- * Default value: `undefined`
356
- */
357
- onSimulationUnpause?: () => void;
358
-
359
- /**
360
- * Callback function that will be called on every canvas click.
361
- * If clicked on a point, its index will be passed as the first argument,
362
- * position as the second argument and the corresponding mouse event as the third argument:
363
- * `(index: number | undefined, pointPosition: [number, number] | undefined, event: MouseEvent) => void`.
364
- * Default value: `undefined`
365
- */
366
- onClick?: (
367
- index: number | undefined, pointPosition: [number, number] | undefined, event: MouseEvent
368
- ) => void;
369
-
370
- /**
371
- * Callback function that will be called when a point is clicked.
372
- * The point index will be passed as the first argument,
373
- * position as the second argument and the corresponding mouse event as the third argument:
374
- * `(index: number, pointPosition: [number, number], event: MouseEvent) => void`.
375
- * Default value: `undefined`
376
- */
377
- onPointClick?: (
378
- index: number,
379
- pointPosition: [number, number],
380
- event: MouseEvent
381
- ) => void;
382
-
383
- /**
384
- * Callback function that will be called when a link is clicked.
385
- * The link index will be passed as the first argument and the corresponding mouse event as the second argument:
386
- * `(linkIndex: number, event: MouseEvent) => void`.
387
- * Default value: `undefined`
388
- */
389
- onLinkClick?: (
390
- linkIndex: number,
391
- event: MouseEvent
392
- ) => void;
393
-
394
- /**
395
- * Callback function that will be called when the background (empty space) is clicked.
396
- * The mouse event will be passed as the first argument:
397
- * `(event: MouseEvent) => void`.
398
- * Default value: `undefined`
399
- */
400
- onBackgroundClick?: (
401
- event: MouseEvent
402
- ) => void;
403
-
404
- /**
405
- * Callback function that will be called when mouse movement happens.
406
- * If the mouse moves over a point, its index will be passed as the first argument,
407
- * position as the second argument and the corresponding mouse event as the third argument:
408
- * `(index: number | undefined, pointPosition: [number, number] | undefined, event: MouseEvent) => void`.
409
- * Default value: `undefined`
410
- */
411
- onMouseMove?: (
412
- index: number | undefined, pointPosition: [number, number] | undefined, event: MouseEvent
413
- ) => void;
414
-
415
- /**
416
- * Callback function that will be called when a point appears under the mouse
417
- * as a result of a mouse event, zooming and panning, or movement of points.
418
- * The point index will be passed as the first argument, position as the second argument
419
- * and the corresponding mouse event or D3's zoom event as the third argument:
420
- * `(index: number, pointPosition: [number, number], event: MouseEvent | D3DragEvent<HTMLCanvasElement, undefined, Hovered>
421
- * | D3ZoomEvent<HTMLCanvasElement, undefined> | undefined) => void`.
422
- * Default value: `undefined`
423
- */
424
- onPointMouseOver?: (
425
- index: number,
426
- pointPosition: [number, number],
427
- event: MouseEvent | D3DragEvent<HTMLCanvasElement, undefined, Hovered> | D3ZoomEvent<HTMLCanvasElement, undefined> | undefined
428
- ) => void;
429
-
430
- /**
431
- * Callback function that will be called when a point is no longer underneath
432
- * the mouse pointer because of a mouse event, zoom/pan event, or movement of points.
433
- * The corresponding mouse event or D3's zoom event will be passed as the first argument:
434
- * `(event: MouseEvent | D3ZoomEvent<HTMLCanvasElement, undefined> | D3DragEvent<HTMLCanvasElement, undefined, Hovered> | undefined) => void`.
435
- * Default value: `undefined`
436
- */
437
- onPointMouseOut?: (event: MouseEvent | D3ZoomEvent<HTMLCanvasElement, undefined> | D3DragEvent<HTMLCanvasElement, undefined, Hovered> | undefined) => void;
438
-
439
- /**
440
- * Callback function that will be called when the mouse moves over a link.
441
- * The link index will be passed as the first argument:
442
- * `(linkIndex: number) => void`.
443
- * Default value: `undefined`
444
- */
445
- onLinkMouseOver?: (linkIndex: number) => void;
446
-
447
- /**
448
- * Callback function that will be called when the mouse moves out of a link.
449
- * The event will be passed as the first argument:
450
- * `(event: MouseEvent | D3ZoomEvent<HTMLCanvasElement, undefined> | D3DragEvent<HTMLCanvasElement, undefined, Hovered> | undefined) => void`.
451
- * Default value: `undefined`
452
- */
453
- onLinkMouseOut?: (event: MouseEvent | D3ZoomEvent<HTMLCanvasElement, undefined> | D3DragEvent<HTMLCanvasElement, undefined, Hovered> | undefined) => void;
454
-
455
- /**
456
- * Callback function that will be called when zooming or panning starts.
457
- * First argument is a D3 Zoom Event and second indicates whether
458
- * the event has been initiated by a user interaction (e.g. a mouse event):
459
- * `(event: D3ZoomEvent, userDriven: boolean) => void`.
460
- * Default value: `undefined`
461
- */
462
- onZoomStart?: (e: D3ZoomEvent<HTMLCanvasElement, undefined>, userDriven: boolean) => void;
463
-
464
- /**
465
- * Callback function that will be called continuously during zooming or panning.
466
- * First argument is a D3 Zoom Event and second indicates whether
467
- * the event has been initiated by a user interaction (e.g. a mouse event):
468
- * `(event: D3ZoomEvent, userDriven: boolean) => void`.
469
- * Default value: `undefined`
470
- */
471
- onZoom?: (e: D3ZoomEvent<HTMLCanvasElement, undefined>, userDriven: boolean) => void;
472
-
473
- /**
474
- * Callback function that will be called when zooming or panning ends.
475
- * First argument is a D3 Zoom Event and second indicates whether
476
- * the event has been initiated by a user interaction (e.g. a mouse event):
477
- * `(event: D3ZoomEvent, userDriven: boolean) => void`.
478
- * Default value: `undefined`
479
- */
480
- onZoomEnd?: (e: D3ZoomEvent<HTMLCanvasElement, undefined>, userDriven: boolean) => void;
481
-
482
- /**
483
- * Callback function that will be called when dragging starts.
484
- * First argument is a D3 Drag Event:
485
- * `(event: D3DragEvent) => void`.
486
- * Default value: `undefined`
487
- */
488
- onDragStart?: (e: D3DragEvent<HTMLCanvasElement, undefined, Hovered>) => void;
489
-
490
- /**
491
- * Callback function that will be called continuously during dragging.
492
- * First argument is a D3 Drag Event:
493
- * `(event: D3DragEvent) => void`.
494
- * Default value: `undefined`
495
- */
496
- onDrag?: (e: D3DragEvent<HTMLCanvasElement, undefined, Hovered>) => void;
497
-
498
- /**
499
- * Callback function that will be called when dragging ends.
500
- * First argument is a D3 Drag Event:
501
- * `(event: D3DragEvent) => void`.
502
- * Default value: `undefined`
503
- */
504
- onDragEnd?: (e: D3DragEvent<HTMLCanvasElement, undefined, Hovered>) => void;
505
-
506
- /**
507
- * Show WebGL performance monitor.
508
- * Default value: `false`
509
- */
510
- showFPSMonitor?: boolean;
511
- /**
512
- * Canvas pixel ratio.
513
- * Default value: `2`
514
- */
515
- pixelRatio?: number;
516
- /**
517
- * Increase or decrease the size of the points when zooming in or out.
518
- * Default value: `false`
519
- */
520
- scalePointsOnZoom?: boolean;
521
- /**
522
- * Initial zoom level. Can be set once during graph initialization.
523
- * If set, `fitViewOnInit` value will be ignored.
524
- * Default value: `undefined`
525
- */
526
- initialZoomLevel?: number;
527
- /**
528
- * Enables or disables zooming in and out.
529
- * Default: `true`
530
- */
531
- enableZoom?: boolean;
532
- /**
533
- * Controls whether the simulation remains active during zoom operations.
534
- * When set to `true`, the simulation continues running while zooming.
535
- * When set to `false`, the simulation pauses during zoom operations.
536
- * Default value: `false`
537
- */
538
- enableSimulationDuringZoom?: boolean;
539
- /**
540
- * Enables or disables dragging of points in the graph.
541
- * Default value: `false`
542
- */
543
- enableDrag?: boolean;
544
- /**
545
- * Whether to center and zoom the view to fit all points in the scene on initialization or not.
546
- * Ignored if `initialZoomLevel` is set.
547
- * Default: `true`
548
- */
549
- fitViewOnInit?: boolean;
550
- /**
551
- * Delay in milliseconds before fitting the view when `fitViewOnInit` is enabled.
552
- * Useful if you want the layout to stabilize a bit before fitting.
553
- * Default: `250`
554
- */
555
- fitViewDelay?: number;
556
- /**
557
- * Padding to apply when fitting the view to show all points.
558
- * This value is added to the calculated bounding box to provide some extra space around the points.
559
- * This is used when the `fitViewOnInit` option is enabled.
560
- * Default: `0.1`
561
- */
562
- fitViewPadding?: number;
563
- /**
564
- * Duration in milliseconds for fitting the view to show all points when fitViewOnInit is enabled.
565
- * Default: `250`
566
- */
567
- fitViewDuration?: number;
568
- /**
569
- * When `fitViewOnInit` is set to `true`, fits the view to show the points within a rectangle
570
- * defined by its two corner coordinates `[[left, bottom], [right, top]]` in the scene space.
571
- * Default: `undefined`
572
- */
573
- fitViewByPointsInRect?: [[number, number], [number, number]] | [number, number][];
574
- /**
575
- * When `fitViewOnInit` is set to `true`, fits the view to show only the specified points by their indices.
576
- * Takes precedence over `fitViewByPointsInRect` when both are provided.
577
- * Default: `undefined`
578
- */
579
- fitViewByPointIndices?: number[];
580
- /**
581
- * Providing a `randomSeed` value allows you to control
582
- * the randomness of the layout across different simulation runs.
583
- * It is useful when you want the graph to always look the same on same datasets.
584
- * This property will be applied only on component initialization and it
585
- * can't be changed using the `setConfig` method.
586
- * Default value: undefined
587
- */
588
- randomSeed?: number | string;
589
- /**
590
- * Point sampling distance in pixels between neighboring points when calling the `getSampledPointPositionsMap` method.
591
- * This parameter determines how many points will be included in the sample.
592
- * Default value: `150`
593
- */
594
- pointSamplingDistance?: number;
595
- /**
596
- * Controls automatic position adjustment of points in the visible space.
597
- *
598
- * When `undefined` (default):
599
- * - If simulation is disabled (`enableSimulation: false`), points will be automatically
600
- * repositioned to fit within the visible space
601
- * - If simulation is enabled, points will not be rescaled
602
- *
603
- * When explicitly set:
604
- * - `true`: Forces points positions to be rescaled
605
- * - `false`: Forces points positions to not be rescaled
606
- */
607
- rescalePositions?: boolean | undefined;
608
- /**
609
- * Controls the text shown in the bottom right corner.
610
- * - When a non-empty string is provided: Displays the string as HTML
611
- * - When empty string or not provided: No text is displayed
612
- */
613
- attribution?: string;
614
- }
615
-
616
- export class GraphConfig implements GraphConfigInterface {
617
- public enableSimulation = defaultConfigValues.enableSimulation
618
- public backgroundColor = defaultBackgroundColor
619
- public spaceSize = defaultConfigValues.spaceSize
620
- public pointColor = defaultPointColor
621
- // TODO: When pointColor is removed, change this to:
622
- // public pointDefaultColor = defaultPointColor
623
- // Currently undefined to allow fallback to deprecated pointColor via nullish coalescing
624
- // in GraphData.updatePointColor() (see: this._config.pointDefaultColor ?? this._config.pointColor)
625
- public pointDefaultColor = undefined
626
- public pointGreyoutOpacity = defaultGreyoutPointOpacity
627
- public pointGreyoutColor = defaultGreyoutPointColor
628
- public pointSize = defaultPointSize
629
- public pointOpacity = defaultPointOpacity
630
- public pointSizeScale = defaultConfigValues.pointSizeScale
631
- public hoveredPointCursor = defaultConfigValues.hoveredPointCursor
632
- public hoveredLinkCursor = defaultConfigValues.hoveredLinkCursor
633
- public renderHoveredPointRing = defaultConfigValues.renderHoveredPointRing
634
- public hoveredPointRingColor = defaultConfigValues.hoveredPointRingColor
635
- public focusedPointRingColor = defaultConfigValues.focusedPointRingColor
636
- public focusedPointIndex = defaultConfigValues.focusedPointIndex
637
- public linkColor = defaultLinkColor
638
- public linkOpacity = defaultLinkOpacity
639
- public linkGreyoutOpacity = defaultGreyoutLinkOpacity
640
- public linkWidth = defaultLinkWidth
641
- public linkWidthScale = defaultConfigValues.linkWidthScale
642
- public hoveredLinkColor = defaultConfigValues.hoveredLinkColor
643
- public hoveredLinkWidthIncrease = defaultConfigValues.hoveredLinkWidthIncrease
644
- public renderLinks = defaultConfigValues.renderLinks
645
- public curvedLinks = defaultConfigValues.curvedLinks
646
- public curvedLinkSegments = defaultConfigValues.curvedLinkSegments
647
- public curvedLinkWeight = defaultConfigValues.curvedLinkWeight
648
- public curvedLinkControlPointDistance = defaultConfigValues.curvedLinkControlPointDistance
649
- public linkArrows = defaultConfigValues.linkArrows
650
- public linkArrowsSizeScale = defaultConfigValues.linkArrowsSizeScale
651
- public scaleLinksOnZoom = defaultConfigValues.scaleLinksOnZoom
652
- public linkVisibilityDistanceRange = defaultConfigValues.linkVisibilityDistanceRange
653
- public linkVisibilityMinTransparency = defaultConfigValues.linkVisibilityMinTransparency
654
- public useClassicQuadtree = defaultConfigValues.useClassicQuadtree
655
-
656
- public simulationDecay = defaultConfigValues.simulation.decay
657
- public simulationGravity = defaultConfigValues.simulation.gravity
658
- public simulationCenter = defaultConfigValues.simulation.center
659
- public simulationRepulsion = defaultConfigValues.simulation.repulsion
660
- public simulationRepulsionTheta = defaultConfigValues.simulation.repulsionTheta
661
- public simulationRepulsionQuadtreeLevels = defaultConfigValues.simulation.repulsionQuadtreeLevels
662
- public simulationLinkSpring = defaultConfigValues.simulation.linkSpring
663
- public simulationLinkDistance = defaultConfigValues.simulation.linkDistance
664
- public simulationLinkDistRandomVariationRange = defaultConfigValues.simulation.linkDistRandomVariationRange
665
- public simulationRepulsionFromMouse = defaultConfigValues.simulation.repulsionFromMouse
666
- public enableRightClickRepulsion = defaultConfigValues.enableRightClickRepulsion
667
- public simulationFriction = defaultConfigValues.simulation.friction
668
- public simulationCluster = defaultConfigValues.simulation.cluster
669
-
670
- public onSimulationStart: GraphConfigInterface['onSimulationStart'] = undefined
671
- public onSimulationTick: GraphConfigInterface['onSimulationTick'] = undefined
672
- public onSimulationEnd: GraphConfigInterface['onSimulationEnd'] = undefined
673
- public onSimulationPause: GraphConfigInterface['onSimulationPause'] = undefined
674
- public onSimulationRestart: GraphConfigInterface['onSimulationRestart'] = undefined
675
- public onSimulationUnpause: GraphConfigInterface['onSimulationUnpause'] = undefined
676
-
677
- public onClick: GraphConfigInterface['onClick'] = undefined
678
- public onPointClick: GraphConfigInterface['onPointClick'] = undefined
679
- public onLinkClick: GraphConfigInterface['onLinkClick'] = undefined
680
- public onBackgroundClick: GraphConfigInterface['onBackgroundClick'] = undefined
681
- public onMouseMove: GraphConfigInterface['onMouseMove'] = undefined
682
- public onPointMouseOver: GraphConfigInterface['onPointMouseOver'] = undefined
683
- public onPointMouseOut: GraphConfigInterface['onPointMouseOut'] = undefined
684
- public onLinkMouseOver: GraphConfigInterface['onLinkMouseOver'] = undefined
685
- public onLinkMouseOut: GraphConfigInterface['onLinkMouseOut'] = undefined
686
- public onZoomStart: GraphConfigInterface['onZoomStart'] = undefined
687
- public onZoom: GraphConfigInterface['onZoom'] = undefined
688
- public onZoomEnd: GraphConfigInterface['onZoomEnd'] = undefined
689
- public onDragStart: GraphConfigInterface['onDragStart'] = undefined
690
- public onDrag: GraphConfigInterface['onDrag'] = undefined
691
- public onDragEnd: GraphConfigInterface['onDragEnd'] = undefined
692
-
693
- public showFPSMonitor = defaultConfigValues.showFPSMonitor
694
-
695
- public pixelRatio = defaultConfigValues.pixelRatio
696
-
697
- public scalePointsOnZoom = defaultConfigValues.scalePointsOnZoom
698
- public initialZoomLevel = undefined
699
- public enableZoom = defaultConfigValues.enableZoom
700
- public enableSimulationDuringZoom = defaultConfigValues.enableSimulationDuringZoom
701
- public enableDrag = defaultConfigValues.enableDrag
702
- public fitViewOnInit = defaultConfigValues.fitViewOnInit
703
- public fitViewDelay = defaultConfigValues.fitViewDelay
704
- public fitViewPadding = defaultConfigValues.fitViewPadding
705
- public fitViewDuration = defaultConfigValues.fitViewDuration
706
- public fitViewByPointsInRect = undefined
707
- public fitViewByPointIndices = undefined
708
-
709
- public randomSeed = undefined
710
- public pointSamplingDistance = defaultConfigValues.pointSamplingDistance
711
- public attribution = defaultConfigValues.attribution
712
- public rescalePositions = defaultConfigValues.rescalePositions
713
-
714
- public init (config: GraphConfigInterface): void {
715
- (Object.keys(config) as (keyof GraphConfigInterface)[])
716
- .forEach(configParameter => {
717
- this.deepMergeConfig(this.getConfig(), config, configParameter)
718
- })
719
- }
720
-
721
- public deepMergeConfig <T> (current: T, next: T, key: keyof T): void {
722
- if (isPlainObject(current[key]) && isPlainObject(next[key])) {
723
- // eslint-disable-next-line @typescript-eslint/ban-types
724
- (Object.keys(next[key] as Object) as (keyof T[keyof T])[])
725
- .forEach(configParameter => {
726
- this.deepMergeConfig(current[key], next[key], configParameter)
727
- })
728
- } else current[key] = next[key]
729
- }
730
-
731
- private getConfig (): GraphConfigInterface {
732
- return this
733
- }
734
- }