@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
@@ -1,591 +0,0 @@
1
- import { Meta } from "@storybook/blocks";
2
-
3
- <Meta title="API Reference" />
4
-
5
- ### <a name="set_config" href="#set_config">#</a> graph.<b>setConfig</b>(<i>config</i>)
6
-
7
- This method sets the [cosmos.gl configuration](../?path=/docs/configuration--docs). The changes are applied in real-time.
8
-
9
- * **`config`** (Object): The configuration object adhering to cosmos.gl configuration properties.
10
-
11
- ### <a name="set_point_positions" href="#set_point_positions">#</a> graph.<b>setPointPositions</b>(<i>pointPositions</i>, [<i>dontRescale</i>])
12
-
13
- This method sets the positions of points in a cosmos.gl graph using the provided coordinates array.
14
-
15
- * **`pointPositions`** (Float32Array): A Float32Array representing the x and y coordinates of points in the format `[x1, y1, x2, y2, ..., xN, yN]`. Each pair represents the coordinates of a single point.
16
- * **`dontRescale`** (Boolean, optional): For this call only, controls whether to rescale the points.
17
- - `true`: Don't rescale the points.
18
- - `false` or `undefined` (default): Use the behavior defined by `config.rescalePositions`.
19
-
20
- **Example:**
21
- ```javascript
22
- graph.setPointPositions(new Float32Array([1, 2, 3, 4, 5, 6]));
23
- graph.render();
24
- ```
25
-
26
- ### <a name="set_point_colors" href="#set_point_colors">#</a> graph.<b>setPointColors</b>(<i>pointColors</i>)
27
-
28
- This method sets the colors for points in a cosmos.gl graph.
29
-
30
- * **`pointColors`** (Float32Array): A Float32Array representing the colors of points in the format `[r1, g1, b1, a1, r2, g2, b2, a2, ..., rN, gN, bN, aN]`, where each color is represented in RGBA format:
31
- - **`r`**: Red value (0.0-1.0)
32
- - **`g`**: Green value (0.0-1.0)
33
- - **`b`**: Blue value (0.0-1.0)
34
- - **`a`**: Alpha value (0.0-1.0, where 0 is fully transparent and 1 is fully opaque)
35
-
36
- Each group of four values (`r`, `g`, `b`, `a`) represents the color of a single point in the graph. The order of the colors in the array corresponds to the order of the points in the graph's data.
37
-
38
- **Example:**
39
-
40
- ```javascript
41
- graph.setPointColors(new Float32Array([
42
- 1, 0, 0, 1, // Red color for the first point
43
- 0, 1, 0, 1, // Green color for the second point
44
- 0, 0, 1, 1 // Blue color for the third point
45
- ]));
46
- graph.render();
47
- ```
48
-
49
- ### <a name="get_point_colors" href="#get_point_colors">#</a> graph.<b>getPointColors</b>()
50
-
51
- This method retrieves the current colors of the graph points that were previously set using `setPointColors`.
52
-
53
- **Returns:** A Float32Array representing the colors of points in the format `[r1, g1, b1, a1, r2, g2, b2, a2, ..., rN, gN, bN, aN]`, where each color is in RGBA format. Each set of four values (`r`, `g`, `b`, `a`) represents the color of a single point. Returns an empty Float32Array if no point colors are set.
54
-
55
- The returned array contains the processed point colors used for rendering, including any default values that were applied during processing.
56
-
57
- ### <a name="set_point_sizes" href="#set_point_sizes">#</a> graph.<b>setPointSizes</b>(<i>pointSizes</i>)
58
-
59
- This method sets the sizes for the graph points.
60
-
61
- * **`pointSizes`** (Float32Array): A Float32Array representing the sizes of points in the format `[size1, size2, ..., sizeN]`, where each `size` value corresponds to the size of the point at the same index in the graph's data.
62
-
63
- Each size value in the array specifies the size of a point using the same order as the points in the graph data.
64
-
65
- **Example:**
66
- ```javascript
67
- graph.setPointSizes(new Float32Array([10, 20, 30]));
68
- graph.render();
69
- ```
70
-
71
- This example sets the size of the first point to 10, the second point to 20, and the third point to 30.
72
-
73
- ### <a name="get_point_sizes" href="#get_point_sizes">#</a> graph.<b>getPointSizes</b>()
74
-
75
- This method retrieves the current sizes of the graph points that were previously set using `setPointSizes`.
76
-
77
- **Returns:** A Float32Array representing the sizes of points in the format `[size1, size2, ..., sizeN]`, where each `size` value corresponds to the size of the point at the same index in the graph's data. Returns an empty Float32Array if no point sizes are set.
78
-
79
- The returned array contains the processed point sizes used for rendering, including any default values that were applied during processing.
80
-
81
- ### <a name="set_point_shapes" href="#set_point_shapes">#</a> graph.<b>setPointShapes</b>(<i>pointShapes</i>)
82
-
83
- This method sets the shapes for the graph points.
84
-
85
- * **`pointShapes`** (Float32Array): A Float32Array representing the shapes of points in the format `[shape1, shape2, ..., shapeN]`, where each `shape` value corresponds to the shape of the point at the same index in the graph's data. Each shape value should be one of the available shape constants:
86
-
87
- | Shape Value | Shape Name |
88
- |-------------|------------|
89
- | 0 | Circle |
90
- | 1 | Square |
91
- | 2 | Triangle |
92
- | 3 | Diamond |
93
- | 4 | Pentagon |
94
- | 5 | Hexagon |
95
- | 6 | Star |
96
- | 7 | Cross |
97
- | 8 | None |
98
-
99
- Each shape value in the array specifies the shape of a point using the same order as the points in the graph data. Invalid shape values (outside the range 0-8) will default to Circle (0).
100
-
101
- Images are rendered above shapes.
102
-
103
- **Example:**
104
- ```javascript
105
- import { Graph, PointShape } from '@cosmos.gl/graph'
106
-
107
- // Create a mixed set of shapes using the PointShape enum
108
- graph.setPointShapes(new Float32Array([
109
- PointShape.Circle, // Circle for first point
110
- PointShape.Star, // Star for second point
111
- PointShape.Triangle, // Triangle for third point
112
- PointShape.Hexagon // Hexagon for fourth point
113
- ]));
114
- graph.render();
115
- ```
116
-
117
- ### <a name="set_image_data" href="#set_image_data">#</a> graph.<b>setImageData</b>(<i>imageDataArray</i>)
118
-
119
- This method sets the images for the graph points using [ImageData](https://developer.mozilla.org/en-US/docs/Web/API/ImageData) objects. Images are rendered above shapes. To use images, provide image indices via `setPointImageIndices()`.
120
-
121
- Images are rendered above shapes.
122
-
123
- * **`imageDataArray`** (ImageData[]): Array of ImageData objects to use as point images.
124
-
125
- **Example:**
126
- ```javascript
127
- // Create ImageData objects from canvas or other sources
128
- const imageData1 = canvas1.getContext('2d').getImageData(0, 0, 32, 32);
129
- const imageData2 = canvas2.getContext('2d').getImageData(0, 0, 32, 32);
130
-
131
- // Set the images for the graph
132
- graph.setImageData([imageData1, imageData2]);
133
-
134
- // Set which image each point should use (0 = imageData1, 1 = imageData2)
135
- graph.setPointImageIndices(new Float32Array([0, 1, 0, 1]));
136
-
137
- // To show shapes with images
138
- graph.setPointShapes(new Float32Array([0, 1, 2, 3])); // Circle, Square, Triangle, Diamond
139
-
140
- graph.render();
141
- ```
142
-
143
- This example sets up two images and assigns them to four points: the first and third points use imageData1, while the second and fourth points use imageData2. The shapes are also set to show both shapes and images together.
144
-
145
- ### <a name="set_point_image_indices" href="#set_point_image_indices">#</a> graph.<b>setPointImageIndices</b>(<i>imageIndices</i>)
146
-
147
- This method sets which image each point should use from the images array provided to `setImageData()`. Images are rendered above shapes.
148
-
149
- * **`imageIndices`** (Float32Array): A Float32Array representing which image each point uses in the format `[index1, index2, ..., indexN]`, where each value is an index into the images array provided to `setImageData()`.
150
- * **Valid indices**: Use 0 for the first image, 1 for the second image, etc. Invalid or negative indices will default to -1 (no image).
151
- * **Default behavior**: When no image indices are provided, all points default to -1 (no image).
152
-
153
- ### <a name="set_point_image_sizes" href="#set_point_image_sizes">#</a> graph.<b>setPointImageSizes</b>(<i>imageSizes</i>)
154
-
155
- This method sets the sizes for the point images in the graph.
156
-
157
- * **`imageSizes`** (Float32Array): A Float32Array representing the sizes of point images in the format `[size1, size2, ..., sizeN]`, where each `size` value corresponds to the size of the image for the point at the same index in the graph's data.
158
-
159
- Each size value in the array specifies the size of a point image using the same order as the points in the graph data. The sizes are applied to images that have been set using `setImageData()` and referenced via `setPointImageIndices()`.
160
-
161
- ### <a name="set_links" href="#set_links">#</a> graph.<b>setLinks</b>(<i>links</i>)
162
-
163
- This method sets the links (connections) between points in a cosmos.gl graph.
164
-
165
- * **`links`** (Float32Array): A Float32Array representing the connections between points in the format `[source1, target1, source2, target2, ..., sourceN, targetN]`, where `source` and `target` are the indices of the points being linked. Each pair of elements in the array represents a single link.
166
-
167
- Each pair of elements in the array represents a single link between two points specified by their indices.
168
-
169
- **Example:**
170
- ```javascript
171
- graph.setLinks(new Float32Array([
172
- 0, 1, // Link between point 0 and point 1
173
- 1, 2, // Link between point 1 and point 2
174
- 2, 3 // Link between point 2 and point 3
175
- ]));
176
- graph.render();
177
- ```
178
-
179
- The resulting graph will have a total of 3 links: one between points 0 and 1, another between points 1 and 2, and a third between points 2 and 3.
180
-
181
- ### <a name="set_link_colors" href="#set_link_colors">#</a> graph.<b>setLinkColors</b>(<i>linkColors</i>)
182
-
183
- This method sets the colors for the graph links.
184
-
185
- * **`linkColors`** (Float32Array): A Float32Array representing the colors of links in the format `[r1, g1, b1, a1, r2, g2, b2, a2, ..., rN, gN, bN, aN]`, where each color is in RGBA format. Each set of four values (`r`, `g`, `b`, `a`) represents the color of a single link. Here's a breakdown:
186
-
187
- * **`r`**: Red value (0.0-1.0)
188
- * **`g`**: Green value (0.0-1.0)
189
- * **`b`**: Blue value (0.0-1.0)
190
- * **`a`**: Alpha (opacity) value (0.0-1.0), where 0 is fully transparent and 1 is fully opaque.
191
-
192
- The array should contain a multiple of 4 elements, where each set of four elements represents the RGBA color for a single link. The order of the colors in the array corresponds to the order of the links in the graph.
193
-
194
- **Example:**
195
- ```javascript
196
- graph.setLinkColors(new Float32Array([
197
- 1, 0, 0, 1, // Red for the first link
198
- 0, 1, 0, 1, // Green for the second link
199
- 0, 0, 1, 1 // Blue for the third link
200
- ]));
201
- graph.render();
202
- ```
203
-
204
- In this example, the `linkColors` array contains three sets of four elements, each representing the RGBA color for a single link. The first set `[1, 0, 0, 1]` sets the first link to red, the second set `[0, 1, 0, 1]` sets the second link to green, and the third set `[0, 0, 1, 1]` sets the third link to blue.
205
-
206
- ### <a name="get_link_colors" href="#get_link_colors">#</a> graph.<b>getLinkColors</b>()
207
-
208
- This method retrieves the current colors of the graph links that were previously set using `setLinkColors`.
209
-
210
- **Returns:** A Float32Array representing the colors of links in the format `[r1, g1, b1, a1, r2, g2, b2, a2, ..., rN, gN, bN, aN]`, where each color is in RGBA format. Each set of four values (`r`, `g`, `b`, `a`) represents the color of a single link. Returns an empty Float32Array if no link colors are set.
211
-
212
- The returned array contains the processed link colors used for rendering, including any default values that were applied during processing.
213
-
214
- ### <a name="set_link_widths" href="#set_link_widths">#</a> graph.<b>setLinkWidths</b>(<i>linkWidths</i>)
215
-
216
- This method sets the widths for the graph links.
217
-
218
- * **`linkWidths`** (Float32Array): A Float32Array representing the widths of links in the format `[width1, width2, ..., widthN]`, where each `width` value corresponds to the width of the link at the same index in the graph's data. The lengths of the widths array should match the number of links in the graph. Each width is usually a numerical value representing the thickness of the link.
219
-
220
- **Example:**
221
- ```javascript
222
- graph.setLinkWidths(new Float32Array([1, 2, 3]));
223
- graph.render();
224
- ```
225
-
226
- In this example, the `linkWidths` array contains three numerical values. The first value `1` sets the width of the first link, the second value `2` sets the width of the second link, and the third value `3` sets the width of the third link.
227
-
228
- ### <a name="get_link_widths" href="#get_link_widths">#</a> graph.<b>getLinkWidths</b>()
229
-
230
- This method retrieves the current widths of the graph links that were previously set using `setLinkWidths`.
231
-
232
- **Returns:** A Float32Array representing the widths of links in the format `[width1, width2, ..., widthN]`, where each `width` value corresponds to the width of the link at the same index in the graph's data. Returns an empty Float32Array if no link widths are set.
233
-
234
- The returned array contains the processed link widths used for rendering, including any default values that were applied during processing.
235
-
236
- ### <a name="set_link_arrows" href="#set_link_arrows">#</a> graph.<b>setLinkArrows</b>(<i>linkArrows</i>)
237
-
238
- This method sets the arrows for the graph links.
239
-
240
- * **`linkArrows`** (Array): An array of booleans indicating whether each link should have an arrow.
241
-
242
- The array should have the same length as the number of links in the graph.
243
-
244
- **Example:**
245
- ```javascript
246
- graph.setLinkArrows([true, false, true]);
247
- graph.render();
248
- ```
249
-
250
- In this example, the `linkArrows` array contains three boolean values. The first value `true` sets an arrow on the first link, the second value `false` leaves the second link without an arrow, and the third value `true` sets an arrow on the third link.
251
-
252
- ### <a name="set_link_strength" href="#set_link_strength">#</a> graph.<b>setLinkStrength</b>(<i>linkStrength</i>)
253
-
254
- This method sets the strength of the graph links.
255
-
256
- * **`linkStrength`** (Float32Array): A Float32Array representing the strength of each link in the format `[strength1, strength2, ..., strengthN]`, where each `strength` is a numerical value. The strength values typically range from 0.0 to 1.0, with higher values indicating stronger links. The length of the `linkStrength` array should match the number of links in the graph.
257
-
258
- **Example:**
259
- ```javascript
260
- graph.setLinkStrength(new Float32Array([0.1, 0.2, 0.3]));
261
- graph.render();
262
- ```
263
-
264
- In this example, the `linkStrength` array contains three numerical values. The first value `0.1` sets the strength of the first link, the second value `0.2` sets the strength of the second link, and the third value `0.3` sets the strength of the third link.
265
-
266
- ### <a name="set_point_clusters" href="#set_point_clusters">#</a> graph.<b>setPointClusters</b>(<i>pointClusters</i>)
267
-
268
- This method sets the point clusters for the graph.
269
-
270
- * **`pointClusters`** (Array of `(number | undefined)`): An array where each index corresponds to a point, and the value is the cluster index. `undefined` indicates that a point does not belong to any cluster and will not be affected by cluster forces.
271
- * **Example:**
272
- ```javascript
273
- graph.setPointClusters([0, 1, 0, 2, undefined, 1]);
274
- ```
275
- This example maps points to clusters: point 0 and 2 to cluster 0, point 1 to cluster 1, point 3 to cluster 2, and point 4 is unclustered.
276
- * **Note:** Clusters without specified positions via `setClusterPositions` will be positioned at their centermass by default.
277
-
278
- ### <a name="set_cluster_positions" href="#set_cluster_positions">#</a> graph.<b>setClusterPositions</b>(<i>clusterPositions</i>)
279
-
280
- This method sets the positions of the point clusters for the graph.
281
-
282
- * **`clusterPositions`** (Array of `(number | undefined)`): An array where every two elements represent the x and y coordinates for a cluster position. `undefined` means the cluster's position is not defined and will use centermass positioning instead.
283
- * **Example:**
284
- ```javascript
285
- graph.setClusterPositions([10, 20, 30, 40, undefined, undefined]);
286
- ```
287
- This example places the first cluster at (10, 20) and the second at (30, 40); the third cluster will be positioned at its centermass automatically.
288
-
289
- ### <a name="set_point_cluster_strength" href="#set_point_cluster_strength">#</a> graph.<b>setPointClusterStrength</b>(<i>clusterStrength</i>)
290
-
291
- This method sets the force strength coefficients for clustering points in the graph.
292
-
293
- * **`clusterStrength`** (Float32Array): A Float32Array of force strength coefficients for each point in the format `[coeff1, coeff2, ..., coeffn]`, where `n` is the index of the point.
294
- * **Example:**
295
- ```javascript
296
- graph.setPointClusterStrength(new Float32Array([1, 0.4, 0.3]));
297
- ```
298
- This example sets the force coefficient for point 0 to 1, point 1 to 0.4, and point 2 to 0.3.
299
-
300
- ### <a name="render" href="#render">#</a> graph.<b>render</b>([<i>simulationAlpha</i>])
301
-
302
- The `render` method renders the graph and, optionally, controls the initial energy of the simulation.
303
-
304
- * **`simulationAlpha`** (number, optional): The higher the value, the more initial energy the simulation will get. Zero value stops the simulation.
305
-
306
- ### <a name="zoom_to_point_by_index" href="#zoom_to_point_by_index">#</a> graph.<b>zoomToPointByIndex</b>(<i>index</i>, [<i>duration</i>], [<i>scale</i>], [<i>canZoomOut</i>])
307
-
308
- This method centers the view on the specified point (by its <i>index</i>) and zooms in with a given animation <i>duration</i> and <i>scale</i> value.
309
-
310
- * **`index`** (Number): The index of the point to zoom into.
311
- * **`duration`** (Number, optional): The animation duration in milliseconds. Default is 700.
312
- * **`scale`** (Number, optional): The zoom scale. Default is 3.
313
- * **`canZoomOut`** (Boolean, optional): If set to `false`, prevents zooming out. Default is `true`.
314
-
315
- ### <a name="set_zoom_level" href="#set_zoom_level">#</a> graph.<b>setZoomLevel</b>(<i>value</i>, [<i>duration</i>])
316
-
317
- This method sets the zoom level of the graph view.
318
-
319
- * **`value`** (Number): The desired zoom level. Higher values result in a closer zoom, while lower values zoom out.
320
- * **`duration`** (Number, optional): The duration of the zoom animation in milliseconds. If not provided, the default value is `0`, meaning the zoom level will change instantly without any animation.
321
-
322
- ### <a name="get_zoom_level" href="#get_zoom_level">#</a> graph.<b>getZoomLevel</b>()
323
-
324
- This method retrieves the current zoom level of the graph view.
325
-
326
- ### <a name="fit_view" href="#fit_view">#</a> graph.<b>fitView</b>([<i>duration</i>], [<i>padding</i>])
327
-
328
- This method centers and zooms the view to fit all points within the scene.
329
-
330
- * **`duration`** (Number, optional): The duration of the zoom animation in milliseconds. If not provided, the default value is `250` milliseconds. This allows the view to smoothly transition to fit all points. A value of `0` can be used for an instant fit without any animation.
331
- * **`padding`** (Number, optional): The padding around the viewport in percentage. This value should be between 0 and 1. Default is 0.1 (10% padding).
332
-
333
- The `fitView` method is particularly useful when you want to ensure that all points in the graph are visible within the currently displayed viewport. By fitting the view to include all points, users can get a complete overview of the entire graph.
334
-
335
- ### <a name="fit_view_by_point_indices" href="#fit_view_by_point_indices">#</a> graph.<b>fitViewByPointIndices</b>(<i>indices</i>, [<i>duration</i>], [<i>padding</i>])
336
-
337
- The `fitViewByPointIndices` method centers and zooms the view to fit the points specified by their <i>indices</i> in the scene, with an optional animation <i>duration</i> and <i>padding</i>.
338
-
339
- * **`indices`** (Array): An array of point indices to fit in the view.
340
- * **`duration`** (Number, optional): The duration of the animation in milliseconds. Default is 250 ms.
341
- * **`padding`** (Number, optional): The padding around the viewport in percentage. This value should be between 0 and 1. Default is 0.1 (10% padding).
342
-
343
- ### <a name="fit_view_by_point_positions" href="#fit_view_by_point_positions">#</a> graph.<b>fitViewByPointPositions</b>(<i>positions</i>, [<i>duration</i>], [<i>padding</i>])
344
-
345
- The `fitViewByPointPositions` method centers and zooms the view to fit the points specified by their <i>positions</i> in the scene, with an optional animation <i>duration</i> and <i>padding</i>.
346
-
347
- * **`positions`** (Array): An array of point positions to fit in the view.
348
- * **`duration`** (Number, optional): The duration of the animation in milliseconds. Default is 250 ms.
349
- * **`padding`** (Number, optional): The padding around the viewport in percentage. This value should be between 0 and 1. Default is 0.1 (10% padding).
350
-
351
- ### <a name="get_points_in_rect" href="#get_points_in_rect">#</a> graph.<b>getPointsInRect</b>(<i>selection</i>)
352
-
353
- Get points as a Float32Array within a rectangular area defined by two corner points `[[left, top], [right, bottom]]`. The `left` and `right` values represent the horizontal position in pixels, relative to the left edge of the canvas, with `0` being the leftmost position and the width of the canvas being the rightmost position.
354
-
355
- The `top` and `bottom` values represent the vertical position in pixels, relative to the top edge of the canvas, with `0` being the topmost position and the height of the canvas being the bottommost position.
356
-
357
- * **`selection`** (Array): An array containing two coordinate arrays representing the corners of the selection rectangle in the format `[[left, top], [right, bottom]]`.
358
-
359
- **Returns:** A Float32Array containing the indices of points inside the rectangular area.
360
-
361
- ### <a name="get_points_in_range" href="#get_points_in_range">#</a> graph.<b>getPointsInRange</b>(<i>selection</i>) <b style={{ color: 'orange' }}>[DEPRECATED]</b>
362
-
363
- **⚠️ Deprecated:** Use `getPointsInRect` instead. This method will be removed in a future version.
364
-
365
- Get points as a Float32Array within a rectangular area defined by two corner points `[[left, top], [right, bottom]]`. This method has the same functionality as `getPointsInRect`.
366
-
367
- ### <a name="select_points_in_rect" href="#select_points_in_rect">#</a> graph.<b>selectPointsInRect</b>(<i>selection</i>)
368
-
369
- Select points within a rectangular area defined by two corner points `[[left, top], [right, bottom]]`. The `left` and `right` values represent the horizontal position in pixels, relative to the left edge of the canvas, with `0` being the leftmost position and the width of the canvas being the rightmost position.
370
-
371
- The `top` and `bottom` values represent the vertical position in pixels, relative to the top edge of the canvas, with `0` being the topmost position and the height of the canvas being the bottommost position.
372
-
373
- * **`selection`** (Array | null): An array containing two coordinate arrays representing the corners of the selection rectangle in the format `[[left, top], [right, bottom]]`, or `null` to clear the current selection.
374
-
375
- ### <a name="select_points_in_range" href="#select_points_in_range">#</a> graph.<b>selectPointsInRange</b>(<i>selection</i>) <b style={{ color: 'orange' }}>[DEPRECATED]</b>
376
-
377
- **⚠️ Deprecated:** Use `selectPointsInRect` instead. This method will be removed in a future version.
378
-
379
- Select points within a rectangular area defined by two corner points `[[left, top], [right, bottom]]`. This method has the same functionality as `selectPointsInRect`.
380
-
381
- ### <a name="get_points_in_polygon" href="#get_points_in_polygon">#</a> graph.<b>getPointsInPolygon</b>(<i>polygonPath</i>)
382
-
383
- Get points as a Float32Array within a polygon area defined by an array of coordinate points.
384
-
385
- * **`polygonPath`** (Array): An array of coordinate points in the format `[[x1, y1], [x2, y2], ..., [xN, yN]]` that defines the polygon. The coordinates should be in pixels relative to the canvas, where:
386
- - **`x`**: Horizontal position from 0 to the width of the canvas
387
- - **`y`**: Vertical position from 0 to the height of the canvas
388
- - The polygon requires at least 3 points to form a valid selection area
389
-
390
- **Returns:** A Float32Array containing the indices of points inside the polygon area.
391
-
392
- ### <a name="select_points_in_polygon" href="#select_points_in_polygon">#</a> graph.<b>selectPointsInPolygon</b>(<i>polygonPath</i>)
393
-
394
- Select points within a polygon area defined by an array of coordinate points. This method combines the functionality of `getPointsInPolygon` with point selection, making the identified points visually selected in the graph.
395
-
396
- * **`polygonPath`** (Array | null): An array of coordinate points in the format `[[x1, y1], [x2, y2], ..., [xN, yN]]` that defines the polygon, or `null` to clear the current selection. The coordinates should be in pixels relative to the canvas, where:
397
- - **`x`**: Horizontal position from 0 to the width of the canvas
398
- - **`y`**: Vertical position from 0 to the height of the canvas
399
- - The polygon requires at least 3 points to form a valid selection area
400
-
401
- ### <a name="select_point_by_index" href="#select_point_by_index">#</a> graph.<b>selectPointByIndex</b>(<i>index</i>, [<i>selectAdjacentPoints</i>])
402
-
403
- This method selects a point in the graph based on its index.
404
-
405
- * **`index`** (Number): The index of the point to be selected.
406
- * **`selectAdjacentPoints`** (Boolean, optional): If set to `true`, adjacent points to the specified index will also be selected. The default value is `false`.
407
-
408
- ### <a name="select_points_by_indices" href="#select_points_by_indices">#</a> graph.<b>selectPointsByIndices</b>(<i>indices</i>)
409
-
410
- This method selects multiple points in the graph based on their indices.
411
-
412
- * **`indices`** (Array): An array of numbers representing the indices of the points to be selected.
413
-
414
- ### <a name="unselect_points" href="#unselect_points">#</a> graph.<b>unselectPoints</b>()
415
-
416
- This method unselects all currently selected points in the graph.
417
-
418
- ### <a name="get_selected_indices" href="#get_selected_indices">#</a> graph.<b>getSelectedIndices</b>()
419
-
420
- This method returns an array of indices corresponding to the currently selected points in the graph.
421
-
422
- ### <a name="get_adjacent_indices" href="#get_adjacent_indices">#</a> graph.<b>getAdjacentIndices</b>(<i>index</i>)
423
-
424
- This method returns an array of indices that are adjacent to a specific point in the graph, identified by its <i>index</i>.
425
-
426
- * **`index`** (Number): The index of the point whose adjacent points are to be retrieved.
427
-
428
- ### <a name="space_to_screen_position" href="#space_to_screen_position">#</a> graph.<b>spaceToScreenPosition</b>(<i>coordinates</i>)
429
-
430
- This method method is used to convert X and Y point coordinates from the space coordinate system (which is typically used for graph data) to the screen coordinate system (which is used for rendering the graph on the display).
431
-
432
- * **`coordinates`** (Array): An array of two numbers in the format `[x, y]`, representing the X and Y coordinates in the space coordinate system.
433
-
434
- ### <a name="screen_to_space_position" href="#screen_to_space_position">#</a> graph.<b>screenToSpacePosition</b>(<i>coordinates</i>)
435
-
436
- This` method converts X and Y point coordinates from the screen coordinate system (which is used for rendering the graph on the display) to the space coordinate system (which is typically used for graph data).
437
-
438
- * **`coordinates`** (Array): An array of two numbers in the format `[x, y]`, representing the X and Y coordinates in the screen coordinate system.
439
-
440
- ### <a name="space_to_screen_radius" href="#space_to_screen_radius">#</a> graph.<b>spaceToScreenRadius</b>(<i>radius</i>)
441
-
442
- This method is used to convert a <i>radius</i> value from the space coordinate system (which is typically used for graph data) to the screen coordinate system (which is used for rendering the graph on the display).
443
-
444
- * **`radius`** (Number): The radius value in the space coordinate system that needs to be converted to the screen coordinate system.
445
-
446
- ### <a name="get_point_radius_by_index" href="#get_point_radius_by_index">#</a> graph.<b>getPointRadiusByIndex</b>(<i>index</i>)
447
-
448
- This method retrieves the radius of a point in the graph identified by its <i>index</i>.
449
-
450
- * **`index`** (Number): The index of the point for which the radius is to be retrieved.
451
-
452
- ### <a name="track_point_positions_by_indices" href="#track_point_positions_by_indices">#</a> graph.<b>trackPointPositionsByIndices</b>(<i>indices</i>)
453
-
454
- This method allows you to monitor the coordinates of specific points over time. This is particularly useful for observing dynamic changes in the positions of points during the simulation. The positions of the tracked points are updated on each tick of the cosmos.gl simulation.
455
-
456
- * **`indices`** (Array): An array of numbers representing the indices of points to be tracked.
457
-
458
- To retrieve the current positions of the tracked points, use the [**getTrackedPointPositionsMap**](#get_tracked_point_positions_map) method, which returns a `Map` object containing the point coordinates.
459
-
460
- ### <a name="get_tracked_point_positions_map" href="#get_tracked_point_positions_map">#</a> graph.<b>getTrackedPointPositionsMap</b>()
461
-
462
- This method retrieves the current positions of points that are being tracked. This method is particularly useful for monitoring the changing coordinates of specific points over time during the simulation. Using this method in conjunction with the [**trackPointPositionsByIndices**](#track_point_positions_by_indices) method allows for dynamic tracking and retrieval of point positions.
463
-
464
- **Returns:**
465
-
466
- * A `Map` object where the keys are the indices of the tracked points and the values are their corresponding X and Y coordinates in the form of a `[number, number]` array.
467
-
468
- ### <a name="get_tracked_point_positions_array" href="#get_tracked_point_positions_array">#</a> graph.<b>getTrackedPointPositionsArray</b>()
469
-
470
- This method retrieves the current positions of points that are being tracked as an array for optimized performance. This method provides the same functionality as `getTrackedPointPositionsMap` but returns data as a flat array instead of a Map object, which can be more efficient for applications that need to process large numbers of tracked points.
471
-
472
- The positions are returned in the same order as the indices provided to [**trackPointPositionsByIndices**](#track_point_positions_by_indices).
473
-
474
- **Returns:**
475
-
476
- * An array of numbers representing the X and Y coordinates of tracked points in the format `[x1, y1, x2, y2, ..., xn, yn]`, where each pair corresponds to a tracked point in the order they were specified for tracking. Returns an empty array if no points are being tracked.
477
-
478
- ### <a name="get_sampled_point_positions_map" href="#get_sampled_point_positions_map">#</a> graph.<b>getSampledPointPositionsMap</b>()
479
-
480
- This method provides a sampling of point positions from the currently visible points on the screen. It returns a `Map` containing a sample of point indices and their corresponding X and Y coordinates for the points that are currently visible on the screen.
481
-
482
- The number of sampled points is determined by the `pointSamplingDistance` [configuration property](../?path=/docs/configuration--docs). This property controls the density of the sampled points:
483
- * A higher value for `pointSamplingDistance` results in fewer sampled points.
484
- * A lower value results in more sampled points.
485
-
486
- The sample aims to distribute points evenly across the visible area.
487
-
488
- ### <a name="get_sampled_points" href="#get_sampled_points">#</a> graph.<b>getSampledPoints</b>()
489
-
490
- This method provides an optimized way to retrieve both point indices and positions for sampled points that are currently visible on the screen. Unlike `getSampledPointPositionsMap`, this method returns the data as arrays rather than a Map.
491
-
492
- The number of sampled points is determined by the `pointSamplingDistance` [configuration property](../?path=/docs/configuration--docs). This property controls the density of the sampled points:
493
- * A higher value for `pointSamplingDistance` results in fewer sampled points.
494
- * A lower value results in more sampled points.
495
-
496
- The sample aims to distribute points evenly across the visible area.
497
-
498
- **Returns:**
499
-
500
- * An object containing:
501
- - **`indices`**: Array of point indices for the sampled points
502
- - **`positions`**: Flat array of coordinates in the format `[x1, y1, x2, y2, ..., xn, yn]`, where the coordinates correspond to the points at the same index positions in the `indices` array.
503
-
504
- ### <a name="start" href="#start">#</a> graph.<b>start</b>([<i>alpha</i>])
505
-
506
- Starts the simulation with an optional <i>alpha</i> parameter, which controls the initial energy of the simulation.
507
-
508
- * **`alpha`** (Number, optional): A number between `0` and `1` representing the initial energy of the simulation. The default value is `1` if not provided. A higher `alpha` value results in more initial energy for the simulation.
509
-
510
- ### <a name="pause" href="#pause">#</a> graph.<b>pause</b>()
511
-
512
- Pauses the current simulation in the graph.
513
-
514
- ### <a name="unpause" href="#unpause">#</a> graph.<b>unpause</b>()
515
-
516
- Unpauses (resumes) the current simulation in the graph.
517
-
518
- ### <a name="restart" href="#restart">#</a> graph.<b>restart</b>() <b style={{ color: 'orange' }}>[DEPRECATED]</b>
519
-
520
- **⚠️ Deprecated:** Use `unpause()` instead. This method will be removed in a future version.
521
-
522
- Restarts the current simulation in the graph.
523
-
524
- ### <a name="step" href="#step">#</a> graph.<b>step</b>()
525
-
526
- Renders a single frame of the simulation and pauses the simulation if it was active.
527
-
528
- ### <a name="destroy" href="#destroy">#</a> graph.<b>destroy</b>()
529
-
530
- Destroys the current cosmos.gl instance.
531
-
532
- ### <a name="create" href="#create">#</a> graph.<b>create</b>()
533
-
534
- Creates a new cosmos.gl instance.
535
-
536
- ### <a name="flatten" href="#flatten">#</a> graph.<b>flatten</b>(<i>pointPositions</i>)
537
-
538
- This method converts an array of tuple positions into a single, flat array containing all coordinates sequentially.
539
-
540
- * **`pointPositions`** (Array of Arrays): An array of tuples, where each tuple contains two numbers representing the x and y coordinates of a point in the graph. For example, `[[x1, y1], [x2, y2], ..., [xn, yn]]`.
541
-
542
- ### <a name="pair" href="#pair">#</a> graph.<b>pair</b>(<i>pointPositions</i>)
543
-
544
- This method converts a flat array of point positions into an array of tuple pairs, where each tuple represents the x and y coordinates of a point in the graph.
545
-
546
- * **`pointPositions`** (Array): A flat array of numbers representing the x and y coordinates of points sequentially. For example, `[x1, y1, x2, y2, ..., xn, yn]`.
547
-
548
- ### <a name="get_point_positions" href="#get_point_positions">#</a> graph.<b>getPointPositions</b>()
549
-
550
- This method retrieves the current X and Y coordinates of all points in the graph as an array of numbers. The returned array is in the same order as the point positions were added to the graph.
551
-
552
- ### <a name="get_cluster_positions" href="#get_cluster_positions">#</a> graph.<b>getClusterPositions</b>()
553
-
554
- This method returns an array of cluster positions, where each pair of elements represents the x and y coordinates of a cluster.
555
-
556
- ### <a name="progress" href="#progress">#</a> graph.<b>progress</b>
557
-
558
- Returns the current progress of the graph simulation as a float value between 0 (start) and 1 (end). This method can be called at any time during the simulation to get the current progress percentage.
559
-
560
- ### <a name="is_simulation_running" href="#is_simulation_running">#</a> graph.<b>isSimulationRunning</b>
561
-
562
- A boolean property of the graph object that indicates whether the graph simulation is currently running (`true`) or not (`false`). This property can be accessed at any time to check the simulation's status.
563
-
564
- ### <a name="max_point_size" href="#max_point_size">#</a> graph.<b>maxPointSize</b>
565
-
566
- A number property of the graph object that represents the maximum point size the user's hardware can render using the `gl.POINTS` primitive in WebGL. This value varies between different GPUs and is a limitation of the WebGL rendering context.
567
-
568
- ### <a name="zoom" href="#zoom">#</a> graph.<b>zoom</b>(<i>value</i>, [<i>duration</i>])
569
-
570
- This method sets the zoom level of the graph view (alias for setZoomLevel).
571
-
572
- * **`value`** (Number): The desired zoom level. Higher values result in a closer zoom, while lower values zoom out.
573
- * **`duration`** (Number, optional): The duration of the zoom animation in milliseconds. If not provided, the default value is `0`, meaning the zoom level will change instantly without any animation.
574
-
575
- ### <a name="get_scale_x" href="#get_scale_x">#</a> graph.<b>getScaleX</b>()
576
-
577
- Retrieves the X-axis rescaling function used for position transformations when rescaling is enabled.
578
-
579
- **Returns:**
580
- - A function mapping data values to X-coordinates, or `undefined` if rescaling is disabled.
581
-
582
- ### <a name="get_scale_y" href="#get_scale_y">#</a> graph.<b>getScaleY</b>()
583
-
584
- Retrieves the Y-axis rescaling function used for position transformations when rescaling is enabled.
585
-
586
- **Returns:**
587
- - A function mapping data values to Y-coordinates, or `undefined` if rescaling is disabled.
588
-
589
- ---
590
- Copyright [OpenJS Foundation](https://openjsf.org) and cosmos.gl contributors. All rights reserved. The [OpenJS Foundation](https://openjsf.org) has registered trademarks and uses trademarks. For a list of trademarks of the [OpenJS Foundation](https://openjsf.org), please see our [Trademark Policy](https://trademark-policy.openjsf.org/) and [Trademark List](https://trademark-list.openjsf.org/). Trademarks and logos not indicated on the [list of OpenJS Foundation trademarks](https://trademark-list.openjsf.org) are trademarks™ or registered® trademarks of their respective holders. Use of them does not imply any affiliation with or endorsement by them.
591
- [The OpenJS Foundation](https://openjsf.org/) | [Terms of Use](https://terms-of-use.openjsf.org/) | [Privacy Policy](https://privacy-policy.openjsf.org/) | [Bylaws](https://bylaws.openjsf.org/) | [Code of Conduct](https://code-of-conduct.openjsf.org) | [Trademark Policy](https://trademark-policy.openjsf.org/) | [Trademark List](https://trademark-list.openjsf.org/) | [Cookie Policy](https://www.linuxfoundation.org/cookies/)
@@ -1,33 +0,0 @@
1
-
2
- function getRandom (min: number, max: number): number {
3
- return Math.random() * (max - min) + min
4
- }
5
-
6
- export function generateData (n = 100, m = 100): { pointPositions: Float32Array; links: Float32Array } {
7
- const pointPositions = new Float32Array(n * m * 2)
8
- const linksArray: number[] = []
9
- for (let pointIndex = 0; pointIndex < n * m; pointIndex += 1) {
10
- const x = 4096 * getRandom(0.495, 0.505)
11
- const y = 4096 * getRandom(0.495, 0.505)
12
- pointPositions[pointIndex * 2] = x
13
- pointPositions[pointIndex * 2 + 1] = y
14
- const nextPointIndex = pointIndex + 1
15
- const bottomPointIndex = pointIndex + n
16
- const pointLine = Math.floor(pointIndex / n)
17
- const nextPointLine = Math.floor(nextPointIndex / n)
18
- const bottomPointLine = Math.floor(bottomPointIndex / n)
19
- if (pointLine === nextPointLine) {
20
- linksArray.push(pointIndex)
21
- linksArray.push(nextPointIndex)
22
- }
23
-
24
- if (bottomPointLine < m) {
25
- linksArray.push(pointIndex)
26
- linksArray.push(bottomPointIndex)
27
- }
28
- }
29
-
30
- const links = new Float32Array(linksArray)
31
-
32
- return { pointPositions, links }
33
- }