@cosmos.gl/graph 2.3.1 → 2.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc +61 -0
- package/CHARTER.md +69 -0
- package/GOVERNANCE.md +21 -0
- package/dist/config.d.ts +69 -0
- package/dist/index.d.ts +62 -21
- package/dist/index.js +5672 -5188
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +272 -86
- package/dist/index.min.js.map +1 -1
- package/dist/modules/GraphData/index.d.ts +18 -2
- package/dist/modules/Lines/index.d.ts +8 -0
- package/dist/modules/Points/atlas-utils.d.ts +24 -0
- package/dist/modules/Points/index.d.ts +21 -2
- package/dist/modules/Store/index.d.ts +20 -3
- package/dist/modules/core-module.d.ts +1 -0
- package/dist/stories/beginners/link-hovering/data-generator.d.ts +19 -0
- package/dist/stories/beginners/link-hovering/index.d.ts +5 -0
- package/dist/stories/beginners.stories.d.ts +1 -0
- package/dist/stories/create-story.d.ts +5 -1
- package/dist/stories/shapes/image-example/index.d.ts +5 -0
- package/dist/stories/shapes.stories.d.ts +1 -0
- package/dist/variables.d.ts +5 -2
- package/package.json +4 -4
- package/src/config.ts +87 -2
- package/src/declaration.d.ts +5 -0
- package/src/index.ts +270 -98
- package/src/modules/GraphData/index.ts +68 -6
- package/src/modules/Lines/draw-curve-line.frag +12 -1
- package/src/modules/Lines/draw-curve-line.vert +29 -2
- package/src/modules/Lines/hovered-line-index.frag +27 -0
- package/src/modules/Lines/hovered-line-index.vert +8 -0
- package/src/modules/Lines/index.ts +112 -2
- package/src/modules/Points/atlas-utils.ts +137 -0
- package/src/modules/Points/draw-highlighted.vert +3 -3
- package/src/modules/Points/draw-points.frag +106 -14
- package/src/modules/Points/draw-points.vert +51 -25
- package/src/modules/Points/find-points-on-area-selection.frag +6 -5
- package/src/modules/Points/index.ts +121 -13
- package/src/modules/Store/index.ts +44 -5
- package/src/modules/core-module.ts +1 -0
- package/src/stories/1. welcome.mdx +2 -1
- package/src/stories/2. configuration.mdx +10 -1
- package/src/stories/3. api-reference.mdx +61 -5
- package/src/stories/beginners/basic-set-up/index.ts +20 -10
- package/src/stories/beginners/link-hovering/data-generator.ts +198 -0
- package/src/stories/beginners/link-hovering/index.ts +61 -0
- package/src/stories/beginners/link-hovering/style.css +73 -0
- package/src/stories/beginners/quick-start.ts +2 -1
- package/src/stories/beginners/remove-points/index.ts +28 -30
- package/src/stories/beginners.stories.ts +17 -0
- package/src/stories/clusters/polygon-selection/index.ts +2 -4
- package/src/stories/create-story.ts +32 -5
- package/src/stories/shapes/image-example/icons/box.png +0 -0
- package/src/stories/shapes/image-example/icons/lego.png +0 -0
- package/src/stories/shapes/image-example/icons/s.png +0 -0
- package/src/stories/shapes/image-example/icons/swift.png +0 -0
- package/src/stories/shapes/image-example/icons/toolbox.png +0 -0
- package/src/stories/shapes/image-example/index.ts +238 -0
- package/src/stories/shapes.stories.ts +12 -0
- package/src/variables.ts +5 -2
package/.eslintrc
CHANGED
|
@@ -13,6 +13,9 @@
|
|
|
13
13
|
"unicorn"
|
|
14
14
|
],
|
|
15
15
|
"parser": "@typescript-eslint/parser",
|
|
16
|
+
"parserOptions": {
|
|
17
|
+
"project": "./tsconfig.json"
|
|
18
|
+
},
|
|
16
19
|
"rules": {
|
|
17
20
|
"object-curly-spacing": ["error", "always"],
|
|
18
21
|
"prefer-template": "error",
|
|
@@ -67,6 +70,64 @@
|
|
|
67
70
|
"@typescript-eslint/member-ordering": "error",
|
|
68
71
|
"@typescript-eslint/explicit-member-accessibility": "error",
|
|
69
72
|
"@typescript-eslint/explicit-function-return-type": "error",
|
|
73
|
+
"@typescript-eslint/naming-convention": [
|
|
74
|
+
"error",
|
|
75
|
+
{
|
|
76
|
+
"selector": "default",
|
|
77
|
+
"format": ["camelCase"],
|
|
78
|
+
"leadingUnderscore": "allow",
|
|
79
|
+
"trailingUnderscore": "allow"
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"selector": "import",
|
|
83
|
+
"format": ["camelCase", "PascalCase"]
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"selector": "classProperty",
|
|
87
|
+
"format": ["camelCase", "UPPER_CASE"],
|
|
88
|
+
"leadingUnderscore": "allow",
|
|
89
|
+
"trailingUnderscore": "allow"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"selector": "classProperty",
|
|
93
|
+
"types": ["boolean"],
|
|
94
|
+
"format": ["PascalCase"],
|
|
95
|
+
"prefix": ["is", "should", "has", "can", "did", "will", "are"],
|
|
96
|
+
"leadingUnderscore": "allow",
|
|
97
|
+
"trailingUnderscore": "allow"
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"selector": "function",
|
|
101
|
+
"format": ["camelCase", "PascalCase"],
|
|
102
|
+
"modifiers": ["exported"],
|
|
103
|
+
"leadingUnderscore": "allow",
|
|
104
|
+
"trailingUnderscore": "allow"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"selector": "variable",
|
|
108
|
+
"format": ["camelCase", "UPPER_CASE"],
|
|
109
|
+
"leadingUnderscore": "allow",
|
|
110
|
+
"trailingUnderscore": "allow"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"selector": "variable",
|
|
114
|
+
"modifiers": ["exported"],
|
|
115
|
+
"format": ["camelCase", "UPPER_CASE", "PascalCase"]
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"selector": "typeLike",
|
|
119
|
+
"format": ["PascalCase"]
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"selector": "enumMember",
|
|
123
|
+
"format": ["PascalCase"]
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
"selector": "property",
|
|
127
|
+
"leadingUnderscore": "allowSingleOrDouble",
|
|
128
|
+
"format": ["camelCase", "snake_case", "UPPER_CASE"]
|
|
129
|
+
}
|
|
130
|
+
],
|
|
70
131
|
"max-len": ["warn", { "code": 160, "comments": 160 }],
|
|
71
132
|
"unicorn/filename-case": "error",
|
|
72
133
|
"unicorn/no-for-loop": "error",
|
package/CHARTER.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# cosmos.gl Charter
|
|
2
|
+
|
|
3
|
+
## **Section 0: Guiding Principles**
|
|
4
|
+
|
|
5
|
+
**Mission:** Provide the web development community with a high-performance framework for visualizing network graphs and scatter plots.
|
|
6
|
+
|
|
7
|
+
**Vision:** Deliver fast, robust, open-source data visualization tools that empower interactive, scalable analysis in the browser.
|
|
8
|
+
|
|
9
|
+
**Values:**
|
|
10
|
+
|
|
11
|
+
- **Performance First:** Prioritize speed and efficiency in every feature and implementation.
|
|
12
|
+
- **Accessibility:** Ensure the API is intuitive and the tooling easy to adopt, lowering barriers for developers.
|
|
13
|
+
- **Community:** Foster open collaboration, welcoming contributions and feedback.
|
|
14
|
+
- **Transparency:** Maintain clear documentation, benchmarks, and decision-making processes.
|
|
15
|
+
|
|
16
|
+
## **Section 1: Scope**
|
|
17
|
+
|
|
18
|
+
cosmos.gl is a browser-native, GPU-accelerated force-directed graph layout and rendering engine designed to visualize and interact with massive, complex datasets at scale. By leveraging WebGL, it delivers fast simulations and real-time rendering of millions of nodes and edges directly in the browser. cosmos.gl bridges the gap between high-performance data visualization and interactive web-based research workflows, serving developers, researchers, and analysts. Its value lies in unlocking scalable, explainable graph exploration for AI, biotech, finance, and data science stakeholders.
|
|
19
|
+
|
|
20
|
+
### **1.1: In-scope**
|
|
21
|
+
|
|
22
|
+
- GPU-accelerated graph algorithms
|
|
23
|
+
- WebGL- and WebGPU-based rendering of large-scale network graph and machine learning embeddings
|
|
24
|
+
- Browser-native integration with frontend tooling and workflows
|
|
25
|
+
|
|
26
|
+
### **1.2: Out-of-Scope**
|
|
27
|
+
|
|
28
|
+
- Server-side computation, backend data processing and pipelines
|
|
29
|
+
- Native desktop or mobile applications (outside browser environment)
|
|
30
|
+
- Direct integration with domain-specific tools
|
|
31
|
+
|
|
32
|
+
## **Section 2: Relationship with OpenJS Foundation CPC**
|
|
33
|
+
|
|
34
|
+
Technical leadership of the cosmos.gl project is delegated to the cosmos.gl Technical Steering Committee (TSC) by the OpenJS Cross Project Council (CPC). Amendments to this charter require approval from both the CPC, through its [decision-making process](https://github.com/openjs-foundation/cross-project-council/blob/master/CPC-CHARTER.md#section-9-decision-making), and the TSC.
|
|
35
|
+
|
|
36
|
+
## **Section 3: Technical Steering Committee (TSC)**
|
|
37
|
+
|
|
38
|
+
TSC members may attend meetings, participate in discussions, and vote on all matters before the TSC.
|
|
39
|
+
|
|
40
|
+
TSC memberships are not time-limited. There is no maximum size of the TSC.
|
|
41
|
+
|
|
42
|
+
There is no specific set of requirements or qualifications for TSC membership beyond these rules. A TSC member can be removed from the TSC by voluntary resignation or by a standard TSC motion.
|
|
43
|
+
|
|
44
|
+
The TSC shall meet regularly using tools that enable participation by the community. The meeting shall be directed by the TSC chairperson. Responsibility for directing individual meetings may be delegated by the TSC chairperson to any other TSC member. Minutes or an appropriate recording shall be taken and made available to the community through accessible public postings.
|
|
45
|
+
|
|
46
|
+
TSC members are expected to regularly participate in TSC activities.
|
|
47
|
+
|
|
48
|
+
The TSC chairperson is elected by a simple majority vote of all TSC members. The chairperson serves until they resign or are replaced by a TSC vote. Any TSC member may call for a vote at any time, provided the proposal is made in writing and shared with the full TSC. Votes may be held in meetings or asynchronously using any communication tool commonly used by the TSC.
|
|
49
|
+
|
|
50
|
+
## **Section 4: Roles & Responsibilities**
|
|
51
|
+
The roles and responsibilities of cosmos.gl's TSC are described in [GOVERNANCE.md](./GOVERNANCE.md).
|
|
52
|
+
|
|
53
|
+
### **Section 4.1 Project Operations & Management**
|
|
54
|
+
The Project Operations & Management processes are defined in [GOVERNANCE.md](./GOVERNANCE.md).
|
|
55
|
+
|
|
56
|
+
### **Section 4.2: Decision-making, Voting, and/or Elections**
|
|
57
|
+
|
|
58
|
+
Project decisions shall operate under a model of Lazy Consensus by default. The TSC shall define appropriate guidelines for implementing Lazy Consensus (e.g., notification periods, review windows) within the development process.
|
|
59
|
+
|
|
60
|
+
When consensus cannot be reached, the TSC shall decide via public voting.
|
|
61
|
+
|
|
62
|
+
Each vote presents the available options in a format that supports clear expression of member preferences—this may include polls, emoji reactions, checklists, or comparable methods. TSC members may vote for one or more options or abstain. Unless otherwise specified, the winning option is the one that receives the greatest support among participating members.
|
|
63
|
+
|
|
64
|
+
For decisions involving three or more options, the TSC may optionally conduct pairwise comparisons between all candidates. In such cases, the winner is the candidate who secures a simple majority against every other candidate in head-to-head matchups (Condorcet winner). All votes are public, and voting activity may be adjusted until the close of the voting period.
|
|
65
|
+
|
|
66
|
+
## **Section 5: Definitions**
|
|
67
|
+
### **Agenda Item**
|
|
68
|
+
|
|
69
|
+
An agenda item is a specific topic, proposal, or issue scheduled for discussion or decision during a TSC meeting. Examples include proposed technical changes, governance matters, or any subject requiring TSC review or input. Agenda items are published in advance to allow TSC members and the community to prepare for discussion or decision-making.
|
package/GOVERNANCE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# cosmos.gl Governance Guidelines
|
|
2
|
+
|
|
3
|
+
The [TSC Charter](./CHARTER.md) governs the operations of the TSC. All changes to the Charter need approval by the OpenJS Foundation Cross-Project Council (CPC).
|
|
4
|
+
|
|
5
|
+
The TSC oversees all technical development in the cosmos.gl project, as long as it follows policies set by CPC, including:
|
|
6
|
+
- Setting release dates.
|
|
7
|
+
- Release quality standards.
|
|
8
|
+
- Technical direction.
|
|
9
|
+
- Project governance and process.
|
|
10
|
+
- GitHub repository hosting.
|
|
11
|
+
- Conduct guidelines.
|
|
12
|
+
- Maintaining the list of additional collaborators.
|
|
13
|
+
- Development process and any coding standards.
|
|
14
|
+
- Mediating technical conflicts between collaborators or foundation projects.
|
|
15
|
+
|
|
16
|
+
The TSC will define cosmos.gl project’s release vehicles.
|
|
17
|
+
|
|
18
|
+
### **Project Operations & Management**
|
|
19
|
+
The TSC will establish and maintain a development process for the cosmos.gl project. The development process will establish guidelines for how the developers and community will operate. It will, for example, establish appropriate timelines for TSC review (e.g. agenda items must be published at least a certain number of hours in advance of a TSC meeting).
|
|
20
|
+
|
|
21
|
+
The TSC and entire technical community will follow any processes as may be specified by the OpenJS Foundation Board relating to the intake and license compliance review of contributions, including the OpenJS Foundation IP Policy.
|
package/dist/config.d.ts
CHANGED
|
@@ -74,6 +74,11 @@ export interface GraphConfigInterface {
|
|
|
74
74
|
* Default value: `auto`
|
|
75
75
|
*/
|
|
76
76
|
hoveredPointCursor?: string;
|
|
77
|
+
/**
|
|
78
|
+
* Cursor style to use when hovering over a link
|
|
79
|
+
* Default value: `auto`
|
|
80
|
+
*/
|
|
81
|
+
hoveredLinkCursor?: string;
|
|
77
82
|
/**
|
|
78
83
|
* Turns ring rendering around a point on hover on / off
|
|
79
84
|
* Default value: `false`
|
|
@@ -127,6 +132,19 @@ export interface GraphConfigInterface {
|
|
|
127
132
|
* Default value: `1`
|
|
128
133
|
*/
|
|
129
134
|
linkWidth?: number;
|
|
135
|
+
/**
|
|
136
|
+
* The color to use for links when they are hovered.
|
|
137
|
+
* This can be either a hex color string (e.g., '#ff3333') or an array of RGBA values
|
|
138
|
+
* in the format `[red, green, blue, alpha]` where each value is a number between 0 and 255.
|
|
139
|
+
* Default value: `undefined`
|
|
140
|
+
*/
|
|
141
|
+
hoveredLinkColor?: string | [number, number, number, number];
|
|
142
|
+
/**
|
|
143
|
+
* Number of pixels to add to the link width when hovered.
|
|
144
|
+
* The hovered width is calculated as: originalWidth + hoveredLinkWidthIncrease
|
|
145
|
+
* Default value: `5`
|
|
146
|
+
*/
|
|
147
|
+
hoveredLinkWidthIncrease?: number;
|
|
130
148
|
/**
|
|
131
149
|
* Scale factor for the link width.
|
|
132
150
|
* Default value: `1`
|
|
@@ -289,9 +307,15 @@ export interface GraphConfigInterface {
|
|
|
289
307
|
onSimulationPause?: () => void;
|
|
290
308
|
/**
|
|
291
309
|
* Callback function that will be called when the simulation is restarted.
|
|
310
|
+
* @deprecated Use `onSimulationUnpause` instead. This callback will be removed in a future version.
|
|
292
311
|
* Default value: `undefined`
|
|
293
312
|
*/
|
|
294
313
|
onSimulationRestart?: () => void;
|
|
314
|
+
/**
|
|
315
|
+
* Callback function that will be called when the simulation is unpaused.
|
|
316
|
+
* Default value: `undefined`
|
|
317
|
+
*/
|
|
318
|
+
onSimulationUnpause?: () => void;
|
|
295
319
|
/**
|
|
296
320
|
* Callback function that will be called on every canvas click.
|
|
297
321
|
* If clicked on a point, its index will be passed as the first argument,
|
|
@@ -300,6 +324,28 @@ export interface GraphConfigInterface {
|
|
|
300
324
|
* Default value: `undefined`
|
|
301
325
|
*/
|
|
302
326
|
onClick?: (index: number | undefined, pointPosition: [number, number] | undefined, event: MouseEvent) => void;
|
|
327
|
+
/**
|
|
328
|
+
* Callback function that will be called when a point is clicked.
|
|
329
|
+
* The point index will be passed as the first argument,
|
|
330
|
+
* position as the second argument and the corresponding mouse event as the third argument:
|
|
331
|
+
* `(index: number, pointPosition: [number, number], event: MouseEvent) => void`.
|
|
332
|
+
* Default value: `undefined`
|
|
333
|
+
*/
|
|
334
|
+
onPointClick?: (index: number, pointPosition: [number, number], event: MouseEvent) => void;
|
|
335
|
+
/**
|
|
336
|
+
* Callback function that will be called when a link is clicked.
|
|
337
|
+
* The link index will be passed as the first argument and the corresponding mouse event as the second argument:
|
|
338
|
+
* `(linkIndex: number, event: MouseEvent) => void`.
|
|
339
|
+
* Default value: `undefined`
|
|
340
|
+
*/
|
|
341
|
+
onLinkClick?: (linkIndex: number, event: MouseEvent) => void;
|
|
342
|
+
/**
|
|
343
|
+
* Callback function that will be called when the background (empty space) is clicked.
|
|
344
|
+
* The mouse event will be passed as the first argument:
|
|
345
|
+
* `(event: MouseEvent) => void`.
|
|
346
|
+
* Default value: `undefined`
|
|
347
|
+
*/
|
|
348
|
+
onBackgroundClick?: (event: MouseEvent) => void;
|
|
303
349
|
/**
|
|
304
350
|
* Callback function that will be called when mouse movement happens.
|
|
305
351
|
* If the mouse moves over a point, its index will be passed as the first argument,
|
|
@@ -326,6 +372,20 @@ export interface GraphConfigInterface {
|
|
|
326
372
|
* Default value: `undefined`
|
|
327
373
|
*/
|
|
328
374
|
onPointMouseOut?: (event: MouseEvent | D3ZoomEvent<HTMLCanvasElement, undefined> | D3DragEvent<HTMLCanvasElement, undefined, Hovered> | undefined) => void;
|
|
375
|
+
/**
|
|
376
|
+
* Callback function that will be called when the mouse moves over a link.
|
|
377
|
+
* The link index will be passed as the first argument:
|
|
378
|
+
* `(linkIndex: number) => void`.
|
|
379
|
+
* Default value: `undefined`
|
|
380
|
+
*/
|
|
381
|
+
onLinkMouseOver?: (linkIndex: number) => void;
|
|
382
|
+
/**
|
|
383
|
+
* Callback function that will be called when the mouse moves out of a link.
|
|
384
|
+
* The event will be passed as the first argument:
|
|
385
|
+
* `(event: MouseEvent | D3ZoomEvent<HTMLCanvasElement, undefined> | D3DragEvent<HTMLCanvasElement, undefined, Hovered> | undefined) => void`.
|
|
386
|
+
* Default value: `undefined`
|
|
387
|
+
*/
|
|
388
|
+
onLinkMouseOut?: (event: MouseEvent | D3ZoomEvent<HTMLCanvasElement, undefined> | D3DragEvent<HTMLCanvasElement, undefined, Hovered> | undefined) => void;
|
|
329
389
|
/**
|
|
330
390
|
* Callback function that will be called when zooming or panning starts.
|
|
331
391
|
* First argument is a D3 Zoom Event and second indicates whether
|
|
@@ -491,6 +551,7 @@ export declare class GraphConfig implements GraphConfigInterface {
|
|
|
491
551
|
pointOpacity: number;
|
|
492
552
|
pointSizeScale: number;
|
|
493
553
|
hoveredPointCursor: string;
|
|
554
|
+
hoveredLinkCursor: string;
|
|
494
555
|
renderHoveredPointRing: boolean;
|
|
495
556
|
hoveredPointRingColor: string;
|
|
496
557
|
focusedPointRingColor: string;
|
|
@@ -500,6 +561,8 @@ export declare class GraphConfig implements GraphConfigInterface {
|
|
|
500
561
|
linkGreyoutOpacity: number;
|
|
501
562
|
linkWidth: number;
|
|
502
563
|
linkWidthScale: number;
|
|
564
|
+
hoveredLinkColor: undefined;
|
|
565
|
+
hoveredLinkWidthIncrease: number;
|
|
503
566
|
renderLinks: boolean;
|
|
504
567
|
curvedLinks: boolean;
|
|
505
568
|
curvedLinkSegments: number;
|
|
@@ -529,10 +592,16 @@ export declare class GraphConfig implements GraphConfigInterface {
|
|
|
529
592
|
onSimulationEnd: GraphConfigInterface['onSimulationEnd'];
|
|
530
593
|
onSimulationPause: GraphConfigInterface['onSimulationPause'];
|
|
531
594
|
onSimulationRestart: GraphConfigInterface['onSimulationRestart'];
|
|
595
|
+
onSimulationUnpause: GraphConfigInterface['onSimulationUnpause'];
|
|
532
596
|
onClick: GraphConfigInterface['onClick'];
|
|
597
|
+
onPointClick: GraphConfigInterface['onPointClick'];
|
|
598
|
+
onLinkClick: GraphConfigInterface['onLinkClick'];
|
|
599
|
+
onBackgroundClick: GraphConfigInterface['onBackgroundClick'];
|
|
533
600
|
onMouseMove: GraphConfigInterface['onMouseMove'];
|
|
534
601
|
onPointMouseOver: GraphConfigInterface['onPointMouseOver'];
|
|
535
602
|
onPointMouseOut: GraphConfigInterface['onPointMouseOut'];
|
|
603
|
+
onLinkMouseOver: GraphConfigInterface['onLinkMouseOver'];
|
|
604
|
+
onLinkMouseOut: GraphConfigInterface['onLinkMouseOut'];
|
|
536
605
|
onZoomStart: GraphConfigInterface['onZoomStart'];
|
|
537
606
|
onZoom: GraphConfigInterface['onZoom'];
|
|
538
607
|
onZoomEnd: GraphConfigInterface['onZoomEnd'];
|
package/dist/index.d.ts
CHANGED
|
@@ -24,12 +24,12 @@ export declare class Graph {
|
|
|
24
24
|
private fpsMonitor;
|
|
25
25
|
private currentEvent;
|
|
26
26
|
/**
|
|
27
|
-
* The value of `
|
|
28
|
-
* When the counter reaches
|
|
27
|
+
* The value of `_findHoveredItemExecutionCount` is incremented by 1 on each animation frame.
|
|
28
|
+
* When the counter reaches MAX_HOVER_DETECTION_DELAY (default 4), it is reset to 0 and the `findHoveredPoint` or `findHoveredLine` method is executed.
|
|
29
29
|
*/
|
|
30
|
-
private
|
|
30
|
+
private _findHoveredItemExecutionCount;
|
|
31
31
|
/**
|
|
32
|
-
* If the mouse is not on the Canvas, the `findHoveredPoint` method will not be executed.
|
|
32
|
+
* If the mouse is not on the Canvas, the `findHoveredPoint` or `findHoveredLine` method will not be executed.
|
|
33
33
|
*/
|
|
34
34
|
private _isMouseOnCanvas;
|
|
35
35
|
/**
|
|
@@ -37,18 +37,20 @@ export declare class Graph {
|
|
|
37
37
|
* */
|
|
38
38
|
private _isFirstRenderAfterInit;
|
|
39
39
|
private _fitViewOnInitTimeoutID;
|
|
40
|
-
private
|
|
41
|
-
private
|
|
42
|
-
private
|
|
43
|
-
private
|
|
44
|
-
private
|
|
45
|
-
private
|
|
46
|
-
private
|
|
47
|
-
private
|
|
48
|
-
private
|
|
49
|
-
private
|
|
50
|
-
private
|
|
51
|
-
private
|
|
40
|
+
private isPointPositionsUpdateNeeded;
|
|
41
|
+
private isPointColorUpdateNeeded;
|
|
42
|
+
private isPointSizeUpdateNeeded;
|
|
43
|
+
private isPointShapeUpdateNeeded;
|
|
44
|
+
private isPointImageIndicesUpdateNeeded;
|
|
45
|
+
private isLinksUpdateNeeded;
|
|
46
|
+
private isLinkColorUpdateNeeded;
|
|
47
|
+
private isLinkWidthUpdateNeeded;
|
|
48
|
+
private isLinkArrowUpdateNeeded;
|
|
49
|
+
private isPointClusterUpdateNeeded;
|
|
50
|
+
private isForceManyBodyUpdateNeeded;
|
|
51
|
+
private isForceLinkUpdateNeeded;
|
|
52
|
+
private isForceCenterUpdateNeeded;
|
|
53
|
+
private isPointImageSizesUpdateNeeded;
|
|
52
54
|
private _isDestroyed;
|
|
53
55
|
constructor(div: HTMLDivElement, config?: GraphConfigInterface);
|
|
54
56
|
/**
|
|
@@ -108,10 +110,37 @@ export declare class Graph {
|
|
|
108
110
|
*
|
|
109
111
|
* @param {Float32Array} pointShapes - A Float32Array representing the shapes of points in the format [shape1, shape2, ..., shapen],
|
|
110
112
|
* where `n` is the index of the point and each shape value corresponds to a PointShape enum:
|
|
111
|
-
* 0 = Circle, 1 = Square, 2 = Triangle, 3 = Diamond, 4 = Pentagon, 5 = Hexagon, 6 = Star, 7 = Cross.
|
|
113
|
+
* 0 = Circle, 1 = Square, 2 = Triangle, 3 = Diamond, 4 = Pentagon, 5 = Hexagon, 6 = Star, 7 = Cross, 8 = None.
|
|
112
114
|
* Example: `new Float32Array([0, 1, 2])` sets the first point to Circle, the second point to Square, and the third point to Triangle.
|
|
115
|
+
* Images are rendered above shapes.
|
|
113
116
|
*/
|
|
114
117
|
setPointShapes(pointShapes: Float32Array): void;
|
|
118
|
+
/**
|
|
119
|
+
* Sets the images for the graph points using ImageData objects.
|
|
120
|
+
* Images are rendered above shapes.
|
|
121
|
+
* To use images, provide image indices via setPointImageIndices().
|
|
122
|
+
*
|
|
123
|
+
* @param {ImageData[]} imageDataArray - Array of ImageData objects to use as point images.
|
|
124
|
+
* Example: `setImageData([imageData1, imageData2, imageData3])`
|
|
125
|
+
*/
|
|
126
|
+
setImageData(imageDataArray: ImageData[]): void;
|
|
127
|
+
/**
|
|
128
|
+
* Sets which image each point should use from the images array.
|
|
129
|
+
* Images are rendered above shapes.
|
|
130
|
+
*
|
|
131
|
+
* @param {Float32Array} imageIndices - A Float32Array representing which image each point uses in the format [index1, index2, ..., indexn],
|
|
132
|
+
* where `n` is the index of the point and each value is an index into the images array provided to `setImageData`.
|
|
133
|
+
* Example: `new Float32Array([0, 1, 0])` sets the first point to use image 0, second point to use image 1, third point to use image 0.
|
|
134
|
+
*/
|
|
135
|
+
setPointImageIndices(imageIndices: Float32Array): void;
|
|
136
|
+
/**
|
|
137
|
+
* Sets the sizes for the point images.
|
|
138
|
+
*
|
|
139
|
+
* @param {Float32Array} imageSizes - A Float32Array representing the sizes of point images in the format [size1, size2, ..., sizen],
|
|
140
|
+
* where `n` is the index of the point.
|
|
141
|
+
* Example: `new Float32Array([10, 20, 30])` sets the first image to size 10, the second image to size 20, and the third image to size 30.
|
|
142
|
+
*/
|
|
143
|
+
setPointImageSizes(imageSizes: Float32Array): void;
|
|
115
144
|
/**
|
|
116
145
|
* Gets the current sizes of the graph points.
|
|
117
146
|
*
|
|
@@ -367,9 +396,11 @@ export declare class Graph {
|
|
|
367
396
|
trackPointPositionsByIndices(indices: number[]): void;
|
|
368
397
|
/**
|
|
369
398
|
* Get current X and Y coordinates of the tracked points.
|
|
370
|
-
*
|
|
399
|
+
* Do not mutate the returned map - it may affect future calls.
|
|
400
|
+
* @returns A ReadonlyMap where keys are point indices and values are their corresponding X and Y coordinates in the [number, number] format.
|
|
401
|
+
* @see trackPointPositionsByIndices To set which points should be tracked
|
|
371
402
|
*/
|
|
372
|
-
getTrackedPointPositionsMap():
|
|
403
|
+
getTrackedPointPositionsMap(): ReadonlyMap<number, [number, number]>;
|
|
373
404
|
/**
|
|
374
405
|
* Get current X and Y coordinates of the tracked points as an array.
|
|
375
406
|
* @returns Array of point positions in the format [x1, y1, x2, y2, ..., xn, yn] for tracked points only.
|
|
@@ -412,11 +443,19 @@ export declare class Graph {
|
|
|
412
443
|
*/
|
|
413
444
|
start(alpha?: number): void;
|
|
414
445
|
/**
|
|
415
|
-
* Pause the simulation.
|
|
446
|
+
* Pause the simulation. When paused, the simulation stops running
|
|
447
|
+
* and can be resumed using the unpause method.
|
|
416
448
|
*/
|
|
417
449
|
pause(): void;
|
|
418
450
|
/**
|
|
419
|
-
*
|
|
451
|
+
* Unpause the simulation. This method resumes a paused
|
|
452
|
+
* simulation and continues its execution.
|
|
453
|
+
*/
|
|
454
|
+
unpause(): void;
|
|
455
|
+
/**
|
|
456
|
+
* Restart/Resume the simulation. This method unpauses a paused
|
|
457
|
+
* simulation and resumes its execution.
|
|
458
|
+
* @deprecated Use `unpause()` instead. This method will be removed in a future version.
|
|
420
459
|
*/
|
|
421
460
|
restart(): void;
|
|
422
461
|
/**
|
|
@@ -455,7 +494,9 @@ export declare class Graph {
|
|
|
455
494
|
private resizeCanvas;
|
|
456
495
|
private setZoomTransformByPointPositions;
|
|
457
496
|
private updateZoomDragBehaviors;
|
|
497
|
+
private findHoveredItem;
|
|
458
498
|
private findHoveredPoint;
|
|
499
|
+
private findHoveredLine;
|
|
459
500
|
private updateCanvasCursor;
|
|
460
501
|
private addAttribution;
|
|
461
502
|
}
|