@krainovsd/graph 0.13.0-beta3 → 0.14.0-beta.1
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/lib/cjs/index.cjs +729 -426
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/esm/constants/force-controls.js +4 -2
- package/lib/esm/constants/force-controls.js.map +1 -1
- package/lib/esm/constants/highlight-controls.js +9 -16
- package/lib/esm/constants/highlight-controls.js.map +1 -1
- package/lib/esm/constants/link-controls.js +17 -30
- package/lib/esm/constants/link-controls.js.map +1 -1
- package/lib/esm/constants/node-controls.js +4 -2
- package/lib/esm/constants/node-controls.js.map +1 -1
- package/lib/esm/index.js +8 -7
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/module/GraphCanvas/GraphCanvas.js +222 -34
- package/lib/esm/module/GraphCanvas/GraphCanvas.js.map +1 -1
- package/lib/esm/module/GraphCanvas/constants/force-settings.js +11 -1
- package/lib/esm/module/GraphCanvas/constants/force-settings.js.map +1 -1
- package/lib/esm/module/GraphCanvas/constants/graph-settings.js +17 -5
- package/lib/esm/module/GraphCanvas/constants/graph-settings.js.map +1 -1
- package/lib/esm/module/GraphCanvas/constants/highlight-settings.js +5 -3
- package/lib/esm/module/GraphCanvas/constants/highlight-settings.js.map +1 -1
- package/lib/esm/module/GraphCanvas/constants/index.js +5 -2
- package/lib/esm/module/GraphCanvas/constants/index.js.map +1 -1
- package/lib/esm/module/GraphCanvas/constants/link-settings.js +19 -10
- package/lib/esm/module/GraphCanvas/constants/link-settings.js.map +1 -1
- package/lib/esm/module/GraphCanvas/constants/node-settings.js +13 -3
- package/lib/esm/module/GraphCanvas/constants/node-settings.js.map +1 -1
- package/lib/esm/module/GraphCanvas/lib/settings/force-settings-getter.js +4 -2
- package/lib/esm/module/GraphCanvas/lib/settings/force-settings-getter.js.map +1 -1
- package/lib/esm/module/GraphCanvas/lib/settings/graph-settings-getter.js +4 -0
- package/lib/esm/module/GraphCanvas/lib/settings/graph-settings-getter.js.map +1 -1
- package/lib/esm/module/GraphCanvas/lib/settings/highlight-settings-getter.js +4 -2
- package/lib/esm/module/GraphCanvas/lib/settings/highlight-settings-getter.js.map +1 -1
- package/lib/esm/module/GraphCanvas/lib/settings/link-settings-getter.js +8 -5
- package/lib/esm/module/GraphCanvas/lib/settings/link-settings-getter.js.map +1 -1
- package/lib/esm/module/GraphCanvas/lib/settings/node-settings-getter.js +14 -2
- package/lib/esm/module/GraphCanvas/lib/settings/node-settings-getter.js.map +1 -1
- package/lib/esm/module/GraphCanvas/lib/utils/calculate-curve-link-position-by-node.js +5 -2
- package/lib/esm/module/GraphCanvas/lib/utils/calculate-curve-link-position-by-node.js.map +1 -1
- package/lib/esm/module/GraphCanvas/lib/utils/calculate-link-position-by-node.js +5 -2
- package/lib/esm/module/GraphCanvas/lib/utils/calculate-link-position-by-node.js.map +1 -1
- package/lib/esm/module/GraphCanvas/lib/utils/compute-graph-bounds.js +26 -0
- package/lib/esm/module/GraphCanvas/lib/utils/compute-graph-bounds.js.map +1 -0
- package/lib/esm/module/GraphCanvas/lib/utils/get-particle-position.js +40 -30
- package/lib/esm/module/GraphCanvas/lib/utils/get-particle-position.js.map +1 -1
- package/lib/esm/module/GraphCanvas/lib/utils/is-empty-object.js +11 -0
- package/lib/esm/module/GraphCanvas/lib/utils/is-empty-object.js.map +1 -0
- package/lib/esm/module/GraphCanvas/lib/utils/is-node-visible.js +5 -2
- package/lib/esm/module/GraphCanvas/lib/utils/is-node-visible.js.map +1 -1
- package/lib/esm/module/GraphCanvas/slices/draw-links.js +47 -62
- package/lib/esm/module/GraphCanvas/slices/draw-links.js.map +1 -1
- package/lib/esm/module/GraphCanvas/slices/draw-nodes.js +9 -4
- package/lib/esm/module/GraphCanvas/slices/draw-nodes.js.map +1 -1
- package/lib/esm/module/GraphCanvas/slices/init-dnd.js +21 -4
- package/lib/esm/module/GraphCanvas/slices/init-dnd.js.map +1 -1
- package/lib/esm/module/GraphCanvas/slices/init-draw.js +1 -52
- package/lib/esm/module/GraphCanvas/slices/init-draw.js.map +1 -1
- package/lib/esm/module/GraphCanvas/slices/init-pointer.js +6 -34
- package/lib/esm/module/GraphCanvas/slices/init-pointer.js.map +1 -1
- package/lib/esm/module/GraphCanvas/slices/init-simulation.js +12 -2
- package/lib/esm/module/GraphCanvas/slices/init-simulation.js.map +1 -1
- package/lib/esm/module/GraphCanvas/slices/init-zoom.js +85 -16
- package/lib/esm/module/GraphCanvas/slices/init-zoom.js.map +1 -1
- package/lib/esm/module/GraphCanvas/slices/update-link-cache.js +33 -3
- package/lib/esm/module/GraphCanvas/slices/update-link-cache.js.map +1 -1
- package/lib/esm/module/GraphCanvas/slices/update-node-cache.js +61 -16
- package/lib/esm/module/GraphCanvas/slices/update-node-cache.js.map +1 -1
- package/lib/index.d.ts +68 -29
- package/package.json +3 -2
|
@@ -1,16 +1,42 @@
|
|
|
1
|
-
import
|
|
1
|
+
import '../constants/force-settings.js';
|
|
2
|
+
import '../constants/graph-settings.js';
|
|
3
|
+
import '../constants/highlight-settings.js';
|
|
4
|
+
import '../constants/link-settings.js';
|
|
5
|
+
import '../constants/node-settings.js';
|
|
2
6
|
import { nodeOptionsGetter, nodeRadiusGetter, nodeSizeGetter } from '../lib/settings/node-settings-getter.js';
|
|
7
|
+
import '@krainovsd/js-helpers';
|
|
3
8
|
import 'd3-array';
|
|
4
9
|
import { nodeIterationExtractor } from '../lib/utils/node-iteration-extractor.js';
|
|
5
10
|
import { getTextLines } from './draw-text.js';
|
|
6
11
|
|
|
7
|
-
function updateNodeCache(
|
|
8
|
-
this.nodeOptionsCache = {};
|
|
12
|
+
function updateNodeCache() {
|
|
9
13
|
if (!this.context)
|
|
10
14
|
return;
|
|
15
|
+
const currentZoom = this.areaTransform.k;
|
|
16
|
+
const options = this.nodeOptionsCache.length === 0;
|
|
17
|
+
const label = this.cachedNodeLabel.length === 0;
|
|
18
|
+
let text = this.cachedNodeText.length === 0;
|
|
19
|
+
if (this.nodeSettings.smartCache &&
|
|
20
|
+
this._lastNodeZoomK !== undefined &&
|
|
21
|
+
!options &&
|
|
22
|
+
!text &&
|
|
23
|
+
!label) {
|
|
24
|
+
const thresholds = this.nodeSettings.textScaleSteps;
|
|
25
|
+
if (thresholds && thresholds.length > 0) {
|
|
26
|
+
const min = Math.min(this._lastNodeZoomK, currentZoom);
|
|
27
|
+
const max = Math.max(this._lastNodeZoomK, currentZoom);
|
|
28
|
+
const crossed = thresholds.some((t) => t >= min && t <= max);
|
|
29
|
+
this._lastNodeZoomK = currentZoom;
|
|
30
|
+
if (!crossed)
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
this.cachedNodeText.length = 0;
|
|
34
|
+
text = true;
|
|
35
|
+
}
|
|
36
|
+
this._lastNodeZoomK = currentZoom;
|
|
11
37
|
for (let i = 0; i < this.nodes.length; i++) {
|
|
12
38
|
const node = this.nodes[i];
|
|
13
|
-
if (
|
|
39
|
+
if (options) {
|
|
14
40
|
const nodeOptions = nodeIterationExtractor(node, i, this.nodes, this, this.nodeSettings.options ?? {}, nodeOptionsGetter);
|
|
15
41
|
const radius = nodeOptions.shape === "circle"
|
|
16
42
|
? nodeRadiusGetter({
|
|
@@ -61,11 +87,19 @@ function updateNodeCache(types) {
|
|
|
61
87
|
nodeOptions.height = node.visible === false ? 0 : height;
|
|
62
88
|
nodeOptions.radius = node.visible === false ? 0 : radius;
|
|
63
89
|
nodeOptions.labelSize = labelSize;
|
|
64
|
-
this.nodeOptionsCache[
|
|
90
|
+
this.nodeOptionsCache[i] = nodeOptions;
|
|
65
91
|
}
|
|
66
|
-
|
|
92
|
+
let nodeOptions = this.nodeOptionsCache[i];
|
|
93
|
+
if (!nodeOptions)
|
|
94
|
+
continue;
|
|
67
95
|
/** label */
|
|
68
|
-
if (
|
|
96
|
+
if (label) {
|
|
97
|
+
if (!options) {
|
|
98
|
+
nodeOptions = nodeIterationExtractor(node, i, this.nodes, this, this.nodeSettings.options ?? {}, nodeOptionsGetter);
|
|
99
|
+
const cache = this.nodeOptionsCache[i];
|
|
100
|
+
if (cache)
|
|
101
|
+
cache.label = nodeOptions.label;
|
|
102
|
+
}
|
|
69
103
|
/** label in not text shape */
|
|
70
104
|
if (nodeOptions.shape !== "text" && nodeOptions.label) {
|
|
71
105
|
this.context.font = `${nodeOptions.labelStyle} normal ${nodeOptions.labelWeight} ${nodeOptions.labelSize}px ${nodeOptions.labelFont}`;
|
|
@@ -73,7 +107,7 @@ function updateNodeCache(types) {
|
|
|
73
107
|
this.context.textAlign = nodeOptions.labelAlign;
|
|
74
108
|
if (nodeOptions.labelWidth == undefined ||
|
|
75
109
|
this.context.measureText(nodeOptions.label).width <= nodeOptions.labelWidth) {
|
|
76
|
-
this.cachedNodeLabel[
|
|
110
|
+
this.cachedNodeLabel[i] = [nodeOptions.label];
|
|
77
111
|
}
|
|
78
112
|
const { lines } = getTextLines({
|
|
79
113
|
context: this.context,
|
|
@@ -86,7 +120,7 @@ function updateNodeCache(types) {
|
|
|
86
120
|
textStyle: nodeOptions.labelStyle,
|
|
87
121
|
textWeight: nodeOptions.labelWeight,
|
|
88
122
|
});
|
|
89
|
-
this.cachedNodeLabel[
|
|
123
|
+
this.cachedNodeLabel[i] = lines;
|
|
90
124
|
/** label in text shape */
|
|
91
125
|
}
|
|
92
126
|
else if (nodeOptions.shape === "text" && nodeOptions.label) {
|
|
@@ -110,18 +144,29 @@ function updateNodeCache(types) {
|
|
|
110
144
|
(lines.length - 1) * nodeOptions.labelGap +
|
|
111
145
|
nodeOptions.labelYPadding;
|
|
112
146
|
nodeOptions.width = maxSize + nodeOptions.labelXPadding;
|
|
113
|
-
this.cachedNodeLabel[
|
|
147
|
+
this.cachedNodeLabel[i] = lines;
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
this.cachedNodeLabel[i] = [];
|
|
114
151
|
}
|
|
115
152
|
}
|
|
116
153
|
/** text */
|
|
117
|
-
if (
|
|
154
|
+
if (text) {
|
|
155
|
+
if (!options) {
|
|
156
|
+
nodeOptions = nodeIterationExtractor(node, i, this.nodes, this, this.nodeSettings.options ?? {}, nodeOptionsGetter);
|
|
157
|
+
const cache = this.nodeOptionsCache[i];
|
|
158
|
+
if (cache) {
|
|
159
|
+
cache.text = nodeOptions.text;
|
|
160
|
+
cache.textVisible = nodeOptions.textVisible;
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
if (!nodeOptions.text) {
|
|
164
|
+
this.cachedNodeText[i] = [];
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
118
167
|
this.context.font = `${nodeOptions.textStyle} normal ${nodeOptions.textWeight} ${nodeOptions.textSize}px ${nodeOptions.textFont}`;
|
|
119
168
|
this.context.fillStyle = nodeOptions.textColor;
|
|
120
169
|
this.context.textAlign = nodeOptions.textAlign;
|
|
121
|
-
if (nodeOptions.textWidth == undefined ||
|
|
122
|
-
this.context.measureText(nodeOptions.text).width <= nodeOptions.textWidth) {
|
|
123
|
-
this.cachedNodeText[node.id] = [nodeOptions.text];
|
|
124
|
-
}
|
|
125
170
|
const { lines } = getTextLines({
|
|
126
171
|
context: this.context,
|
|
127
172
|
maxWidth: nodeOptions.textWidth,
|
|
@@ -133,7 +178,7 @@ function updateNodeCache(types) {
|
|
|
133
178
|
textStyle: nodeOptions.textStyle,
|
|
134
179
|
textWeight: nodeOptions.textWeight,
|
|
135
180
|
});
|
|
136
|
-
this.cachedNodeText[
|
|
181
|
+
this.cachedNodeText[i] = lines;
|
|
137
182
|
}
|
|
138
183
|
}
|
|
139
184
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"update-node-cache.js","sources":["../../../../../src/module/GraphCanvas/slices/update-node-cache.ts"],"sourcesContent":["import { isObject } from \"@krainovsd/js-helpers\";\nimport type { GraphCanvas } from \"../GraphCanvas\";\nimport {\n nodeIterationExtractor,\n nodeOptionsGetter,\n nodeRadiusGetter,\n nodeSizeGetter,\n} from \"../lib\";\nimport { getTextLines } from \"./draw-text\";\n\ntype NodeCache = {\n options: boolean;\n text: boolean;\n label: boolean;\n};\n\nexport function updateNodeCache<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>(this: GraphCanvas<NodeData, LinkData>, types: boolean | NodeCache) {\n this.nodeOptionsCache = {};\n if (!this.context) return;\n\n for (let i = 0; i < this.nodes.length; i++) {\n const node = this.nodes[i];\n if (types === true || (isObject(types) && types.options)) {\n const nodeOptions = nodeIterationExtractor(\n node,\n i,\n this.nodes,\n this,\n this.nodeSettings.options ?? {},\n nodeOptionsGetter,\n );\n const radius =\n nodeOptions.shape === \"circle\"\n ? nodeRadiusGetter({\n radiusFlexible: this.nodeSettings.nodeRadiusFlexible,\n radiusInitial: nodeOptions.radius,\n radiusIncrementByStep: this.nodeSettings.nodeRadiusIncrementByStep,\n radiusLinkCountForStep: this.nodeSettings.nodeRadiusLinkCountForStep,\n radiusMaxLinearSteps: this.nodeSettings.nodeRadiusMaxLinearSteps,\n radiusLogFactor: this.nodeSettings.nodeRadiusLogFactor,\n radiusLinkCountDividerForLog: this.nodeSettings.nodeRadiusLinkCountDividerForLog,\n linkCount: node.linkCount,\n })\n : nodeOptions.radius;\n\n let width = nodeOptions.width;\n let height = nodeOptions.height;\n let labelSize = nodeOptions.labelSize;\n if (nodeOptions.shape === \"square\") {\n const size = nodeSizeGetter({\n heightInitial: nodeOptions.height,\n widthInitial: nodeOptions.width,\n linkCount: node.linkCount,\n sizeFlexible: this.nodeSettings.nodeSizeFlexible,\n sizeIncrementByStep: this.nodeSettings.nodeSizeIncrementByStep,\n sizeLinkCountForStep: this.nodeSettings.nodeSizeLinkCountForStep,\n sizeMaxLinearSteps: this.nodeSettings.nodeSizeMaxLinearSteps,\n sizeLogFactor: this.nodeSettings.nodeSizeLogFactor,\n sizeLinkCountDividerForLog: this.nodeSettings.nodeSizeLinkCountDividerForLog,\n });\n width = size.width;\n height = size.height;\n }\n if (nodeOptions.shape === \"text\") {\n width = nodeOptions.width;\n const size = nodeSizeGetter({\n heightInitial: nodeOptions.height,\n widthInitial: width,\n linkCount: node.linkCount,\n sizeFlexible: this.nodeSettings.nodeSizeFlexible,\n sizeIncrementByStep: this.nodeSettings.nodeSizeIncrementByStep,\n sizeLinkCountForStep: this.nodeSettings.nodeSizeLinkCountForStep,\n sizeMaxLinearSteps: this.nodeSettings.nodeSizeMaxLinearSteps,\n sizeLogFactor: this.nodeSettings.nodeSizeLogFactor,\n sizeLinkCountDividerForLog: this.nodeSettings.nodeSizeLinkCountDividerForLog,\n });\n\n labelSize *= size.additionalSizeCoefficient;\n }\n\n nodeOptions.width = node.visible === false ? 0 : width;\n nodeOptions.height = node.visible === false ? 0 : height;\n nodeOptions.radius = node.visible === false ? 0 : radius;\n nodeOptions.labelSize = labelSize;\n this.nodeOptionsCache[node.id] = nodeOptions;\n }\n\n const nodeOptions = this.nodeOptionsCache[node.id];\n /** label */\n if (types === true || (isObject(types) && types.label)) {\n /** label in not text shape */\n if (nodeOptions.shape !== \"text\" && nodeOptions.label) {\n this.context.font = `${nodeOptions.labelStyle} normal ${nodeOptions.labelWeight} ${nodeOptions.labelSize}px ${nodeOptions.labelFont}`;\n this.context.fillStyle = nodeOptions.labelColor;\n this.context.textAlign = nodeOptions.labelAlign;\n\n if (\n nodeOptions.labelWidth == undefined ||\n this.context.measureText(nodeOptions.label).width <= nodeOptions.labelWidth\n ) {\n this.cachedNodeLabel[node.id] = [nodeOptions.label];\n }\n\n const { lines } = getTextLines({\n context: this.context,\n maxWidth: nodeOptions.labelWidth,\n text: nodeOptions.label,\n textAlign: nodeOptions.labelAlign,\n textColor: nodeOptions.labelColor,\n textFont: nodeOptions.labelFont,\n textSize: nodeOptions.labelSize,\n textStyle: nodeOptions.labelStyle,\n textWeight: nodeOptions.labelWeight,\n });\n this.cachedNodeLabel[node.id] = lines;\n /** label in text shape */\n } else if (nodeOptions.shape === \"text\" && nodeOptions.label) {\n const textInfo = getTextLines({\n context: this.context,\n text: nodeOptions.label,\n textAlign: nodeOptions.labelAlign,\n textColor: nodeOptions.labelColor,\n textFont: nodeOptions.labelFont,\n textSize: nodeOptions.labelSize,\n maxWidth: nodeOptions.labelWidth,\n textStyle: nodeOptions.labelStyle,\n textWeight: nodeOptions.textWeight,\n });\n const textNodeParameters = [textInfo.currentMaxSize, nodeOptions.labelSize];\n const lines = textInfo.lines;\n const textSizeCoefficient = nodeOptions.labelSize / textNodeParameters[1];\n const maxSize = textNodeParameters[0] * textSizeCoefficient;\n\n nodeOptions.height =\n lines.length * nodeOptions.labelSize +\n (lines.length - 1) * nodeOptions.labelGap +\n nodeOptions.labelYPadding;\n\n nodeOptions.width = maxSize + nodeOptions.labelXPadding;\n this.cachedNodeLabel[node.id] = lines;\n }\n }\n\n /** text */\n if (nodeOptions.text && (types === true || (isObject(types) && types.text))) {\n this.context.font = `${nodeOptions.textStyle} normal ${nodeOptions.textWeight} ${nodeOptions.textSize}px ${nodeOptions.textFont}`;\n this.context.fillStyle = nodeOptions.textColor;\n this.context.textAlign = nodeOptions.textAlign;\n\n if (\n nodeOptions.textWidth == undefined ||\n this.context.measureText(nodeOptions.text).width <= nodeOptions.textWidth\n ) {\n this.cachedNodeText[node.id] = [nodeOptions.text];\n }\n\n const { lines } = getTextLines({\n context: this.context,\n maxWidth: nodeOptions.textWidth,\n text: nodeOptions.text,\n textAlign: nodeOptions.textAlign,\n textColor: nodeOptions.textColor,\n textFont: nodeOptions.textFont,\n textSize: nodeOptions.textSize,\n textStyle: nodeOptions.textStyle,\n textWeight: nodeOptions.textWeight,\n });\n this.cachedNodeText[node.id] = lines;\n }\n }\n}\n"],"names":[],"mappings":";;;;;;AAgBM,SAAU,eAAe,CAGU,KAA0B,EAAA;AACjE,IAAA,IAAI,CAAC,gBAAgB,GAAG,EAAE;IAC1B,IAAI,CAAC,IAAI,CAAC,OAAO;QAAE;AAEnB,IAAA,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QAC1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AAW,CAAC,SAAS;gBAChC,UAAU,EAAE,WAAW,CAAC,UAAU;AACnC,aAAA,CAAC;YACF,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,KAAK;;;AAG1C;;;;"}
|
|
1
|
+
{"version":3,"file":"update-node-cache.js","sources":["../../../../../src/module/GraphCanvas/slices/update-node-cache.ts"],"sourcesContent":["import type { GraphCanvas } from \"../GraphCanvas\";\nimport {\n nodeIterationExtractor,\n nodeOptionsGetter,\n nodeRadiusGetter,\n nodeSizeGetter,\n} from \"../lib\";\nimport { getTextLines } from \"./draw-text\";\n\nexport function updateNodeCache<\n NodeData extends Record<string, unknown>,\n LinkData extends Record<string, unknown>,\n>(this: GraphCanvas<NodeData, LinkData>) {\n if (!this.context) return;\n\n const currentZoom = this.areaTransform.k;\n const options = this.nodeOptionsCache.length === 0;\n const label = this.cachedNodeLabel.length === 0;\n let text = this.cachedNodeText.length === 0;\n\n if (\n this.nodeSettings.smartCache &&\n this._lastNodeZoomK !== undefined &&\n !options &&\n !text &&\n !label\n ) {\n const thresholds = this.nodeSettings.textScaleSteps;\n if (thresholds && thresholds.length > 0) {\n const min = Math.min(this._lastNodeZoomK, currentZoom);\n const max = Math.max(this._lastNodeZoomK, currentZoom);\n const crossed = thresholds.some((t) => t >= min && t <= max);\n this._lastNodeZoomK = currentZoom;\n if (!crossed) return;\n }\n this.cachedNodeText.length = 0;\n text = true;\n }\n this._lastNodeZoomK = currentZoom;\n\n for (let i = 0; i < this.nodes.length; i++) {\n const node = this.nodes[i];\n if (options) {\n const nodeOptions = nodeIterationExtractor(\n node,\n i,\n this.nodes,\n this,\n this.nodeSettings.options ?? {},\n nodeOptionsGetter,\n );\n const radius =\n nodeOptions.shape === \"circle\"\n ? nodeRadiusGetter({\n radiusFlexible: this.nodeSettings.nodeRadiusFlexible,\n radiusInitial: nodeOptions.radius,\n radiusIncrementByStep: this.nodeSettings.nodeRadiusIncrementByStep,\n radiusLinkCountForStep: this.nodeSettings.nodeRadiusLinkCountForStep,\n radiusMaxLinearSteps: this.nodeSettings.nodeRadiusMaxLinearSteps,\n radiusLogFactor: this.nodeSettings.nodeRadiusLogFactor,\n radiusLinkCountDividerForLog: this.nodeSettings.nodeRadiusLinkCountDividerForLog,\n linkCount: node.linkCount,\n })\n : nodeOptions.radius;\n\n let width = nodeOptions.width;\n let height = nodeOptions.height;\n let labelSize = nodeOptions.labelSize;\n if (nodeOptions.shape === \"square\") {\n const size = nodeSizeGetter({\n heightInitial: nodeOptions.height,\n widthInitial: nodeOptions.width,\n linkCount: node.linkCount,\n sizeFlexible: this.nodeSettings.nodeSizeFlexible,\n sizeIncrementByStep: this.nodeSettings.nodeSizeIncrementByStep,\n sizeLinkCountForStep: this.nodeSettings.nodeSizeLinkCountForStep,\n sizeMaxLinearSteps: this.nodeSettings.nodeSizeMaxLinearSteps,\n sizeLogFactor: this.nodeSettings.nodeSizeLogFactor,\n sizeLinkCountDividerForLog: this.nodeSettings.nodeSizeLinkCountDividerForLog,\n });\n width = size.width;\n height = size.height;\n }\n if (nodeOptions.shape === \"text\") {\n width = nodeOptions.width;\n const size = nodeSizeGetter({\n heightInitial: nodeOptions.height,\n widthInitial: width,\n linkCount: node.linkCount,\n sizeFlexible: this.nodeSettings.nodeSizeFlexible,\n sizeIncrementByStep: this.nodeSettings.nodeSizeIncrementByStep,\n sizeLinkCountForStep: this.nodeSettings.nodeSizeLinkCountForStep,\n sizeMaxLinearSteps: this.nodeSettings.nodeSizeMaxLinearSteps,\n sizeLogFactor: this.nodeSettings.nodeSizeLogFactor,\n sizeLinkCountDividerForLog: this.nodeSettings.nodeSizeLinkCountDividerForLog,\n });\n\n labelSize *= size.additionalSizeCoefficient;\n }\n\n nodeOptions.width = node.visible === false ? 0 : width;\n nodeOptions.height = node.visible === false ? 0 : height;\n nodeOptions.radius = node.visible === false ? 0 : radius;\n nodeOptions.labelSize = labelSize;\n this.nodeOptionsCache[i] = nodeOptions;\n }\n\n let nodeOptions = this.nodeOptionsCache[i];\n if (!nodeOptions) continue;\n /** label */\n if (label) {\n if (!options) {\n nodeOptions = nodeIterationExtractor(\n node,\n i,\n this.nodes,\n this,\n this.nodeSettings.options ?? {},\n nodeOptionsGetter,\n );\n const cache = this.nodeOptionsCache[i];\n if (cache) cache.label = nodeOptions.label;\n }\n /** label in not text shape */\n if (nodeOptions.shape !== \"text\" && nodeOptions.label) {\n this.context.font = `${nodeOptions.labelStyle} normal ${nodeOptions.labelWeight} ${nodeOptions.labelSize}px ${nodeOptions.labelFont}`;\n this.context.fillStyle = nodeOptions.labelColor;\n this.context.textAlign = nodeOptions.labelAlign;\n\n if (\n nodeOptions.labelWidth == undefined ||\n this.context.measureText(nodeOptions.label).width <= nodeOptions.labelWidth\n ) {\n this.cachedNodeLabel[i] = [nodeOptions.label];\n }\n\n const { lines } = getTextLines({\n context: this.context,\n maxWidth: nodeOptions.labelWidth,\n text: nodeOptions.label,\n textAlign: nodeOptions.labelAlign,\n textColor: nodeOptions.labelColor,\n textFont: nodeOptions.labelFont,\n textSize: nodeOptions.labelSize,\n textStyle: nodeOptions.labelStyle,\n textWeight: nodeOptions.labelWeight,\n });\n this.cachedNodeLabel[i] = lines;\n /** label in text shape */\n } else if (nodeOptions.shape === \"text\" && nodeOptions.label) {\n const textInfo = getTextLines({\n context: this.context,\n text: nodeOptions.label,\n textAlign: nodeOptions.labelAlign,\n textColor: nodeOptions.labelColor,\n textFont: nodeOptions.labelFont,\n textSize: nodeOptions.labelSize,\n maxWidth: nodeOptions.labelWidth,\n textStyle: nodeOptions.labelStyle,\n textWeight: nodeOptions.textWeight,\n });\n const textNodeParameters = [textInfo.currentMaxSize, nodeOptions.labelSize];\n const lines = textInfo.lines;\n const textSizeCoefficient = nodeOptions.labelSize / textNodeParameters[1];\n const maxSize = textNodeParameters[0] * textSizeCoefficient;\n\n nodeOptions.height =\n lines.length * nodeOptions.labelSize +\n (lines.length - 1) * nodeOptions.labelGap +\n nodeOptions.labelYPadding;\n\n nodeOptions.width = maxSize + nodeOptions.labelXPadding;\n this.cachedNodeLabel[i] = lines;\n } else {\n this.cachedNodeLabel[i] = [];\n }\n }\n\n /** text */\n if (text) {\n if (!options) {\n nodeOptions = nodeIterationExtractor(\n node,\n i,\n this.nodes,\n this,\n this.nodeSettings.options ?? {},\n nodeOptionsGetter,\n );\n const cache = this.nodeOptionsCache[i];\n if (cache) {\n cache.text = nodeOptions.text;\n cache.textVisible = nodeOptions.textVisible;\n }\n }\n if (!nodeOptions.text) {\n this.cachedNodeText[i] = [];\n return;\n }\n this.context.font = `${nodeOptions.textStyle} normal ${nodeOptions.textWeight} ${nodeOptions.textSize}px ${nodeOptions.textFont}`;\n this.context.fillStyle = nodeOptions.textColor;\n this.context.textAlign = nodeOptions.textAlign;\n const { lines } = getTextLines({\n context: this.context,\n maxWidth: nodeOptions.textWidth,\n text: nodeOptions.text,\n textAlign: nodeOptions.textAlign,\n textColor: nodeOptions.textColor,\n textFont: nodeOptions.textFont,\n textSize: nodeOptions.textSize,\n textStyle: nodeOptions.textStyle,\n textWeight: nodeOptions.textWeight,\n });\n this.cachedNodeText[i] = lines;\n }\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;SASgB,eAAe,GAAA;IAI7B,IAAI,CAAC,IAAI,CAAC,OAAO;QAAE;AAEnB,IAAA,MAAM,WAAW,GAAG,IAAI,CAAC,aAAa,CAAC,CAAC;IACxC,MAAM,OAAO,GAAG,IAAI,CAAC,gBAAgB,CAAC,MAAM,KAAK,CAAC;IAClD,MAAM,KAAK,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,KAAK,CAAC;IAC/C,IAAI,IAAI,GAAG,IAAI,CAAC,cAAc,CAAC,MAAM,KAAK,CAAC;AAE3C,IAAA,IACE,IAAI,CAAC,YAAY,CAAC,UAAU;QAC5B,IAAI,CAAC,cAAc,KAAK,SAAS;AACjC,QAAA,CAAC,OAAO;AACR,QAAA,CAAC,IAAI;QACL,CAAC,KAAK,EACN;AACA,QAAA,MAAM,UA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C;;;;"}
|
package/lib/index.d.ts
CHANGED
|
@@ -49,14 +49,12 @@ interface LinkInterface<NodeData extends Record<string, unknown>, LinkData exten
|
|
|
49
49
|
_ay?: number;
|
|
50
50
|
}
|
|
51
51
|
type LinkParticle = {
|
|
52
|
-
step: number;
|
|
53
52
|
index: number;
|
|
54
|
-
prev: LinkParticle | undefined;
|
|
55
|
-
next: LinkParticle | undefined;
|
|
56
53
|
x?: number;
|
|
57
54
|
y?: number;
|
|
58
|
-
|
|
59
|
-
|
|
55
|
+
_distanceTraveled?: number;
|
|
56
|
+
_lastDistance?: number;
|
|
57
|
+
_lastTime?: number;
|
|
60
58
|
};
|
|
61
59
|
|
|
62
60
|
type NodeIterationPropsInterface<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>, Return = number> = (this: GraphCanvas<NodeData, LinkData>, node: NodeInterface<NodeData>, i: number, nodes: NodeInterface<NodeData>[]) => Return;
|
|
@@ -64,6 +62,12 @@ type LinkIterationPropsInterface<NodeData extends Record<string, unknown>, LinkD
|
|
|
64
62
|
type NodeIterationPropsNoThisInterface<NodeData extends Record<string, unknown>, Return = number> = (node: NodeInterface<NodeData>, i: number, nodes: NodeInterface<NodeData>[]) => Return;
|
|
65
63
|
type LinkIterationPropsNoThisInterface<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>, Return = number> = (link: LinkInterface<NodeData, LinkData>, i: number, links: LinkInterface<NodeData, LinkData>[]) => Return;
|
|
66
64
|
|
|
65
|
+
type PrecomputeForceSettingsInterface = {
|
|
66
|
+
precompute?: boolean;
|
|
67
|
+
precomputeMaxTimeMs?: number;
|
|
68
|
+
precomputeMaxTicks?: number;
|
|
69
|
+
precomputeDisableForcesAfter?: boolean;
|
|
70
|
+
};
|
|
67
71
|
type ForceSettingsInterface<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>> = {
|
|
68
72
|
forces?: boolean;
|
|
69
73
|
xForce?: boolean;
|
|
@@ -94,15 +98,21 @@ type ForceSettingsInterface<NodeData extends Record<string, unknown>, LinkData e
|
|
|
94
98
|
xStrength?: NodeIterationPropsNoThisInterface<NodeData> | number;
|
|
95
99
|
yPosition?: NodeIterationPropsNoThisInterface<NodeData> | number;
|
|
96
100
|
yStrength?: NodeIterationPropsNoThisInterface<NodeData> | number;
|
|
97
|
-
};
|
|
101
|
+
} & PrecomputeForceSettingsInterface;
|
|
98
102
|
|
|
99
103
|
declare const FORCE_SETTINGS: Required<ForceSettingsInterface<Record<string, unknown>, Record<string, unknown>>>;
|
|
104
|
+
declare const PERFORMANCE_FORCE_SETTINGS: Required<ForceSettingsInterface<Record<string, unknown>, Record<string, unknown>>>;
|
|
100
105
|
|
|
101
106
|
type GraphSettingsInterface<NodeData extends Record<string, unknown>> = {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
107
|
+
zoomAnimation?: boolean;
|
|
108
|
+
zoomAnimationDuration?: number;
|
|
109
|
+
zoomToNodeScale?: number;
|
|
110
|
+
zoomToFitMargin?: number;
|
|
111
|
+
zoomExtent?: [number, number] | null;
|
|
112
|
+
zoomExtentMargin?: number;
|
|
113
|
+
translateExtent?: [[number?, number?], [number?, number?]] | null;
|
|
114
|
+
translateExtentCoefficient?: number | [number, number] | null;
|
|
115
|
+
translateExtentOverlap?: number;
|
|
106
116
|
zoomInitial?: {
|
|
107
117
|
k?: number;
|
|
108
118
|
x?: number;
|
|
@@ -114,11 +124,11 @@ type GraphSettingsInterface<NodeData extends Record<string, unknown>> = {
|
|
|
114
124
|
};
|
|
115
125
|
|
|
116
126
|
declare const GRAPH_SETTINGS: Required<GraphSettingsInterface<Record<string, unknown>>>;
|
|
127
|
+
declare const PERFORMANCE_GRAPH_SETTINGS: Required<GraphSettingsInterface<Record<string, unknown>>>;
|
|
117
128
|
|
|
118
129
|
type HighlightSettingsInterface = HighlighCommonSettingsInterface & HighlightByNodeForNodeSettingsInterface & HighlightByNodeForLabelSettingsInterface & HighlightByNodeForTextSettingsInterface & HighlightByNodeForLinkSettingsInterface & HighlightByNodeForArrowSettingsInterface & HighlightByLinkForNodeSettingsInterface & HighlightByLinkForTextSettingsInterface & HighlightByLinkForLabelSettingsInterface & HighlightByLinkForLinkSettingsInterface & HighlightByLinkForArrowSettingsInterface;
|
|
119
130
|
type HighlighCommonSettingsInterface = {
|
|
120
|
-
|
|
121
|
-
highlightUpFrames?: number;
|
|
131
|
+
highlightDuration?: number;
|
|
122
132
|
highlightByHoverNode?: boolean;
|
|
123
133
|
highlightByHoverLink?: boolean;
|
|
124
134
|
linkHoverExtraZone?: number;
|
|
@@ -192,15 +202,17 @@ type HighlightByLinkForArrowSettingsInterface = {
|
|
|
192
202
|
};
|
|
193
203
|
|
|
194
204
|
declare const HIGHLIGHT_SETTINGS: Required<HighlightSettingsInterface>;
|
|
205
|
+
declare const PERFORMANCE_HIGHLIGHT_SETTINGS: Required<HighlightSettingsInterface>;
|
|
195
206
|
|
|
196
207
|
type LinkSettingsInterface<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>> = {
|
|
208
|
+
smartCache?: boolean;
|
|
197
209
|
prettyDraw?: boolean;
|
|
198
210
|
curve?: boolean;
|
|
199
211
|
arrow?: boolean;
|
|
200
212
|
arrowByHighlight?: boolean;
|
|
201
213
|
particles?: boolean;
|
|
202
|
-
|
|
203
|
-
|
|
214
|
+
particleCountByDistance?: number;
|
|
215
|
+
particleSpeedByDistance?: number;
|
|
204
216
|
linkScaleSwitch?: number;
|
|
205
217
|
linkWidthBeforeScaleSwitch?: number;
|
|
206
218
|
linkWidthAfterScaleSwitch?: number;
|
|
@@ -228,16 +240,18 @@ type LinkOptionsParticleInterface = {
|
|
|
228
240
|
particleAlpha?: number;
|
|
229
241
|
particleColor?: string;
|
|
230
242
|
particleRadius?: number;
|
|
231
|
-
particleCount?: number;
|
|
232
|
-
particleSteps?: number;
|
|
233
243
|
particleBorderWidth?: number;
|
|
234
244
|
particleBorderColor?: string;
|
|
235
245
|
};
|
|
236
246
|
|
|
237
247
|
declare const LINK_SETTINGS: Omit<Required<LinkSettingsInterface<Record<string, unknown>, Record<string, unknown>>>, "options">;
|
|
238
248
|
declare const LINK_OPTIONS: Omit<Required<LinkOptionsInterface<Record<string, unknown>, Record<string, unknown>>>, "color" | "width" | "drawLink" | "drawExtraLink" | "arrowColor">;
|
|
249
|
+
declare const PERFORMANCE_LINK_SETTINGS: Omit<Required<LinkSettingsInterface<Record<string, unknown>, Record<string, unknown>>>, "options">;
|
|
250
|
+
declare const PERFORMANCE_LINK_OPTIONS: Omit<Required<LinkOptionsInterface<Record<string, unknown>, Record<string, unknown>>>, "color" | "width" | "drawLink" | "drawExtraLink" | "arrowColor">;
|
|
239
251
|
|
|
240
252
|
type NodeSettingsInterface<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>> = {
|
|
253
|
+
smartCache?: boolean;
|
|
254
|
+
textScaleSteps?: number[];
|
|
241
255
|
nodeRadiusFlexible?: boolean;
|
|
242
256
|
nodeRadiusLinkCountForStep?: number;
|
|
243
257
|
nodeRadiusIncrementByStep?: number;
|
|
@@ -309,6 +323,8 @@ type NodeOptionsLabelInterface = {
|
|
|
309
323
|
|
|
310
324
|
declare const NODE_SETTINGS: Omit<Required<NodeSettingsInterface<Record<string, unknown>, Record<string, unknown>>>, "options" | "idGetter">;
|
|
311
325
|
declare const NODE_OPTIONS: Omit<Required<NodeOptionsInterface<Record<string, unknown>, Record<string, unknown>>>, "color" | "text" | "textVisible" | "textSize" | "textShiftY" | "nodeDraw" | "nodeExtraDraw" | "textDraw" | "textExtraDraw">;
|
|
326
|
+
declare const PERFORMANCE_NODE_SETTINGS: Omit<Required<NodeSettingsInterface<Record<string, unknown>, Record<string, unknown>>>, "options" | "idGetter">;
|
|
327
|
+
declare const PERFOMANCE_NODE_OPTIONS: Omit<Required<NodeOptionsInterface<Record<string, unknown>, Record<string, unknown>>>, "color" | "text" | "textVisible" | "textSize" | "textShiftY" | "nodeDraw" | "nodeExtraDraw" | "textDraw" | "textExtraDraw">;
|
|
312
328
|
|
|
313
329
|
declare const GRAPH_CACHE_TYPE: {
|
|
314
330
|
readonly NodeOptions: "nodeOptions";
|
|
@@ -353,7 +369,7 @@ declare class GraphCanvas<NodeData extends Record<string, unknown>, LinkData ext
|
|
|
353
369
|
/** initial data */
|
|
354
370
|
protected nodes: NodeInterface<NodeData>[];
|
|
355
371
|
protected links: LinkInterface<NodeData, LinkData>[];
|
|
356
|
-
protected particles:
|
|
372
|
+
protected particles: (LinkParticle[] | undefined)[];
|
|
357
373
|
protected width: number;
|
|
358
374
|
protected height: number;
|
|
359
375
|
protected root: HTMLElement;
|
|
@@ -370,30 +386,40 @@ declare class GraphCanvas<NodeData extends Record<string, unknown>, LinkData ext
|
|
|
370
386
|
protected context: CanvasRenderingContext2D | null | undefined;
|
|
371
387
|
protected simulation: GraphCanvasSimulation<NodeData, LinkData> | undefined;
|
|
372
388
|
protected areaTransform: ZoomTransform;
|
|
389
|
+
protected _translateExtent: [[number, number], [number, number]] | undefined;
|
|
373
390
|
protected areaRect: DOMRect | undefined;
|
|
374
391
|
protected draw: (this: GraphCanvas<NodeData, LinkData>, recursive?: boolean) => void;
|
|
375
392
|
protected eventAbortController: AbortController;
|
|
376
|
-
protected cachedNodeText:
|
|
377
|
-
protected cachedNodeLabel:
|
|
378
|
-
protected linkOptionsCache:
|
|
379
|
-
protected nodeOptionsCache:
|
|
393
|
+
protected cachedNodeText: (string[] | undefined)[];
|
|
394
|
+
protected cachedNodeLabel: (string[] | undefined)[];
|
|
395
|
+
protected linkOptionsCache: (Required<LinkOptionsInterface<NodeData, LinkData>> | undefined)[];
|
|
396
|
+
protected nodeOptionsCache: (Required<NodeOptionsInterface<NodeData, LinkData>> | undefined)[];
|
|
380
397
|
protected isDragging: boolean;
|
|
381
398
|
protected highlightedNode: NodeInterface<NodeData> | null;
|
|
382
399
|
protected highlightedLink: LinkInterface<NodeData, LinkData> | null;
|
|
383
400
|
protected highlightedNeighbors: Set<string | number> | null;
|
|
384
401
|
protected highlightProgress: number;
|
|
385
|
-
protected
|
|
402
|
+
protected highlightStart: number | null;
|
|
403
|
+
protected highlightPositive: boolean;
|
|
404
|
+
protected highlightController: AbortController | undefined;
|
|
405
|
+
protected _lastNodeZoomK: number | undefined;
|
|
406
|
+
protected _lastLinkZoomK: number | undefined;
|
|
407
|
+
protected _zoomAnimating: boolean;
|
|
386
408
|
protected get simulationWorking(): boolean;
|
|
387
409
|
constructor({ links, nodes, root, forceSettings, linkSettings, listeners, nodeSettings, graphSettings, highlightSettings, }: GraphCanvasInterface<NodeData, LinkData>);
|
|
388
410
|
get dpi(): number;
|
|
389
411
|
getData(): Pick<GraphCanvasInterface<NodeData, LinkData>, "nodes" | "links">;
|
|
412
|
+
fitToView(margin?: number, duration?: number): void;
|
|
413
|
+
focusOnNode(nodeId: string | number, scale?: number, duration?: number): void;
|
|
414
|
+
protected animateHighlight(node: NodeInterface<NodeData> | undefined, link: LinkInterface<NodeData, LinkData> | undefined, baseDuration?: number): void;
|
|
415
|
+
protected animateZoom(area: HTMLCanvasElement, target: ZoomTransform, start: ZoomTransform, duration: number): void;
|
|
390
416
|
changeData(options: Pick<Partial<GraphCanvasInterface<NodeData, LinkData>>, "links" | "nodes">, alpha?: number, clearCache?: boolean | GraphCanvasCacheKeys[]): void;
|
|
391
417
|
changeSettings(options: Omit<Partial<GraphCanvasInterface<NodeData, LinkData>>, "links" | "nodes" | "listeners">, clearCache?: boolean | GraphCanvasCacheKeys[]): undefined;
|
|
392
418
|
updateRect(): void;
|
|
393
419
|
updateSize(): void;
|
|
394
420
|
clearCache(keys: boolean | GraphCanvasCacheKeys[]): void;
|
|
395
421
|
tick(): void;
|
|
396
|
-
restart(alpha?: number): void;
|
|
422
|
+
restart(alpha?: number, options?: Partial<PrecomputeForceSettingsInterface>): void;
|
|
397
423
|
start(): void;
|
|
398
424
|
stop(): void;
|
|
399
425
|
create(): void;
|
|
@@ -451,6 +477,14 @@ declare function nodeIdGetter<NodeData extends Record<string, unknown>>(node: No
|
|
|
451
477
|
|
|
452
478
|
declare function highlightSettingsGetter(settings: HighlightSettingsInterface | undefined, prevSettings?: Required<HighlightSettingsInterface>): Required<HighlightSettingsInterface>;
|
|
453
479
|
|
|
480
|
+
interface GraphBounds {
|
|
481
|
+
minX: number;
|
|
482
|
+
minY: number;
|
|
483
|
+
maxX: number;
|
|
484
|
+
maxY: number;
|
|
485
|
+
}
|
|
486
|
+
declare function computeGraphBounds<NodeData extends Record<string, unknown>>(nodes: NodeInterface<NodeData>[]): GraphBounds | null;
|
|
487
|
+
|
|
454
488
|
declare function pointerGetter(mouseEvent: MouseEvent | TouchEvent, areaRect: DOMRect, areaTransform: ZoomTransform): number[];
|
|
455
489
|
|
|
456
490
|
declare function dragPlaceCoefficientGetter<NodeData extends Record<string, unknown>>(node: NodeInterface<NodeData>, pointerX: number, pointerY: number): number | undefined;
|
|
@@ -497,11 +531,14 @@ type GetParticlePositionOptions = {
|
|
|
497
531
|
yStart: number;
|
|
498
532
|
xEnd: number;
|
|
499
533
|
yEnd: number;
|
|
500
|
-
|
|
501
|
-
|
|
534
|
+
xControl: number;
|
|
535
|
+
yControl: number;
|
|
502
536
|
distance: number;
|
|
537
|
+
totalCount: number;
|
|
538
|
+
speed: number;
|
|
503
539
|
};
|
|
504
540
|
declare function getParticlePosition(opts: GetParticlePositionOptions): void;
|
|
541
|
+
declare function approximateQuadraticBezierLength(x0: number, y0: number, x1: number, y1: number, x2: number, y2: number): number;
|
|
505
542
|
|
|
506
543
|
type LinkByPointerGetterOptions<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>> = {
|
|
507
544
|
mouseEvent: MouseEvent | TouchEvent;
|
|
@@ -597,9 +634,11 @@ declare function extractLinkPointIds<NodeData extends Record<string, unknown>, L
|
|
|
597
634
|
targetId: string | number;
|
|
598
635
|
};
|
|
599
636
|
|
|
600
|
-
declare function
|
|
637
|
+
declare function isEmptyObject(obj: Record<string, unknown>): boolean;
|
|
638
|
+
|
|
639
|
+
declare function getDrawLink<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>>(): (this: GraphCanvas<NodeData, LinkData>, link: LinkInterface<NodeData, LinkData>, index: number) => void;
|
|
601
640
|
|
|
602
|
-
declare function getDrawNode<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>>(nodeRenders: (() => void)[], textRenders: (() => void)[]): (this: GraphCanvas<NodeData, LinkData>, node: NodeInterface<NodeData
|
|
641
|
+
declare function getDrawNode<NodeData extends Record<string, unknown>, LinkData extends Record<string, unknown>>(nodeRenders: (() => void)[], textRenders: (() => void)[]): (this: GraphCanvas<NodeData, LinkData>, node: NodeInterface<NodeData>, index: number) => void;
|
|
603
642
|
|
|
604
643
|
type DrawTextOptions = {
|
|
605
644
|
lines: string[];
|
|
@@ -697,5 +736,5 @@ declare const NODE_OPTIONS_NODE_CONTROLS: GraphSettingsInputInterface<keyof Node
|
|
|
697
736
|
declare const NODE_OPTIONS_TEXT_CONTROLS: GraphSettingsInputInterface<keyof NodeOptionsTextInterface>[];
|
|
698
737
|
declare const NODE_OPTIONS_LABEL_CONTROLS: GraphSettingsInputInterface<keyof NodeOptionsLabelInterface>[];
|
|
699
738
|
|
|
700
|
-
export { COMMON_SETTINGS, FORCE_CONTROLS, FORCE_SETTINGS, GRAPH_CACHE_TYPE, GRAPH_SETTINGS, GraphCanvas, HIGHLIGHT_BY_LINK_FOR_ARROW_CONTROLS, HIGHLIGHT_BY_LINK_FOR_LABEL_CONTROLS, HIGHLIGHT_BY_LINK_FOR_LINK_CONTROLS, HIGHLIGHT_BY_LINK_FOR_NODE_CONTROLS, HIGHLIGHT_BY_LINK_FOR_TEXT_CONTROLS, HIGHLIGHT_BY_NODE_FOR_ARROW_CONTROLS, HIGHLIGHT_BY_NODE_FOR_LABEL_CONTROLS, HIGHLIGHT_BY_NODE_FOR_LINK_CONTROLS, HIGHLIGHT_BY_NODE_FOR_NODE_CONTROLS, HIGHLIGHT_BY_NODE_FOR_TEXT_CONTROLS, HIGHLIGHT_COMMON_CONTROLS, HIGHLIGHT_SETTINGS, LINK_OPTIONS, LINK_OPTIONS_ARROW_CONTROLS, LINK_OPTIONS_LINK_CONTROLS, LINK_OPTIONS_PARTICLE_CONTROLS, LINK_SETTINGS, LINK_SETTINGS_CONTROLS, NODE_OPTIONS, NODE_OPTIONS_LABEL_CONTROLS, NODE_OPTIONS_NODE_CONTROLS, NODE_OPTIONS_TEXT_CONTROLS, NODE_SETTINGS, NODE_SETTINGS_CONTROLS, animationByProgress, calculateLinkPositionByNode, colorGetter, colorToRgb, dragPlaceCoefficientGetter, drawText, extractLinkPointIds, extractRgb, fadeRgb, forceSettingsGetter, getDrawLink, getDrawNode, getParticlePosition, graphSettingsGetter, highlightSettingsGetter, isNodeVisible, isOverlapsNode, linkByPointerGetter, linkFade, linkHighlight, linkIterationExtractor, linkOptionsGetter, linkSettingsGetter, listenersGetter, nodeByPointerGetter, nodeFade, nodeHighlight, nodeIdGetter, nodeIterationExtractor, nodeOptionsGetter, nodeRadiusGetter, nodeSettingsGetter, nodeSizeGetter, nodeTextSizeGetter, pointerGetter, rgbAnimationByProgress };
|
|
701
|
-
export type { CachedNodeTextInterface, DragEventInterface, ForceSettingsInterface, GraphCanvasCacheKeys, GraphCanvasInterface, GraphCanvasSimulation, GraphSettingsInputInterface, GraphSettingsInterface, HighlighCommonSettingsInterface, HighlightByLinkForArrowSettingsInterface, HighlightByLinkForLabelSettingsInterface, HighlightByLinkForLinkSettingsInterface, HighlightByLinkForNodeSettingsInterface, HighlightByLinkForTextSettingsInterface, HighlightByNodeForArrowSettingsInterface, HighlightByNodeForLabelSettingsInterface, HighlightByNodeForLinkSettingsInterface, HighlightByNodeForNodeSettingsInterface, HighlightByNodeForTextSettingsInterface, HighlightSettingsInterface, LinkByPointerGetterOptions, LinkInterface, LinkIterationPropsInterface, LinkIterationPropsNoThisInterface, LinkOptionsArrowInterface, LinkOptionsInterface, LinkOptionsLinkInterface, LinkOptionsParticleInterface, LinkParticle, LinkSettingsInterface, ListenersInterface, NodeByPointerGetterOptions, NodeInterface, NodeIterationPropsInterface, NodeIterationPropsNoThisInterface, NodeOptionsInterface, NodeOptionsLabelInterface, NodeOptionsNodeInterface, NodeOptionsTextInterface, NodeRadiusGetterOptions, NodeSettingsInterface, NodeShape, NodeSizeGetterOptions, RGB, TextStyleEnum, ZoomEventInterface };
|
|
739
|
+
export { COMMON_SETTINGS, FORCE_CONTROLS, FORCE_SETTINGS, GRAPH_CACHE_TYPE, GRAPH_SETTINGS, GraphCanvas, HIGHLIGHT_BY_LINK_FOR_ARROW_CONTROLS, HIGHLIGHT_BY_LINK_FOR_LABEL_CONTROLS, HIGHLIGHT_BY_LINK_FOR_LINK_CONTROLS, HIGHLIGHT_BY_LINK_FOR_NODE_CONTROLS, HIGHLIGHT_BY_LINK_FOR_TEXT_CONTROLS, HIGHLIGHT_BY_NODE_FOR_ARROW_CONTROLS, HIGHLIGHT_BY_NODE_FOR_LABEL_CONTROLS, HIGHLIGHT_BY_NODE_FOR_LINK_CONTROLS, HIGHLIGHT_BY_NODE_FOR_NODE_CONTROLS, HIGHLIGHT_BY_NODE_FOR_TEXT_CONTROLS, HIGHLIGHT_COMMON_CONTROLS, HIGHLIGHT_SETTINGS, LINK_OPTIONS, LINK_OPTIONS_ARROW_CONTROLS, LINK_OPTIONS_LINK_CONTROLS, LINK_OPTIONS_PARTICLE_CONTROLS, LINK_SETTINGS, LINK_SETTINGS_CONTROLS, NODE_OPTIONS, NODE_OPTIONS_LABEL_CONTROLS, NODE_OPTIONS_NODE_CONTROLS, NODE_OPTIONS_TEXT_CONTROLS, NODE_SETTINGS, NODE_SETTINGS_CONTROLS, PERFOMANCE_NODE_OPTIONS, PERFORMANCE_FORCE_SETTINGS, PERFORMANCE_GRAPH_SETTINGS, PERFORMANCE_HIGHLIGHT_SETTINGS, PERFORMANCE_LINK_OPTIONS, PERFORMANCE_LINK_SETTINGS, PERFORMANCE_NODE_SETTINGS, animationByProgress, approximateQuadraticBezierLength, calculateLinkPositionByNode, colorGetter, colorToRgb, computeGraphBounds, dragPlaceCoefficientGetter, drawText, extractLinkPointIds, extractRgb, fadeRgb, forceSettingsGetter, getDrawLink, getDrawNode, getParticlePosition, graphSettingsGetter, highlightSettingsGetter, isEmptyObject, isNodeVisible, isOverlapsNode, linkByPointerGetter, linkFade, linkHighlight, linkIterationExtractor, linkOptionsGetter, linkSettingsGetter, listenersGetter, nodeByPointerGetter, nodeFade, nodeHighlight, nodeIdGetter, nodeIterationExtractor, nodeOptionsGetter, nodeRadiusGetter, nodeSettingsGetter, nodeSizeGetter, nodeTextSizeGetter, pointerGetter, rgbAnimationByProgress };
|
|
740
|
+
export type { CachedNodeTextInterface, DragEventInterface, ForceSettingsInterface, GraphBounds, GraphCanvasCacheKeys, GraphCanvasInterface, GraphCanvasSimulation, GraphSettingsInputInterface, GraphSettingsInterface, HighlighCommonSettingsInterface, HighlightByLinkForArrowSettingsInterface, HighlightByLinkForLabelSettingsInterface, HighlightByLinkForLinkSettingsInterface, HighlightByLinkForNodeSettingsInterface, HighlightByLinkForTextSettingsInterface, HighlightByNodeForArrowSettingsInterface, HighlightByNodeForLabelSettingsInterface, HighlightByNodeForLinkSettingsInterface, HighlightByNodeForNodeSettingsInterface, HighlightByNodeForTextSettingsInterface, HighlightSettingsInterface, LinkByPointerGetterOptions, LinkInterface, LinkIterationPropsInterface, LinkIterationPropsNoThisInterface, LinkOptionsArrowInterface, LinkOptionsInterface, LinkOptionsLinkInterface, LinkOptionsParticleInterface, LinkParticle, LinkSettingsInterface, ListenersInterface, NodeByPointerGetterOptions, NodeInterface, NodeIterationPropsInterface, NodeIterationPropsNoThisInterface, NodeOptionsInterface, NodeOptionsLabelInterface, NodeOptionsNodeInterface, NodeOptionsTextInterface, NodeRadiusGetterOptions, NodeSettingsInterface, NodeShape, NodeSizeGetterOptions, PrecomputeForceSettingsInterface, RGB, TextStyleEnum, ZoomEventInterface };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@krainovsd/graph",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0-beta.1",
|
|
4
4
|
"description": "Krainov graph",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "KrainovSD <denislosev48@gmail.com>",
|
|
@@ -62,7 +62,8 @@
|
|
|
62
62
|
"@vitejs/plugin-vue": "5.2.4",
|
|
63
63
|
"@krainovsd/vue-ui": "0.4.0-beta.23",
|
|
64
64
|
"@krainovsd/vue-icons": "0.1.4",
|
|
65
|
-
"sass-embedded": "1.81.0"
|
|
65
|
+
"sass-embedded": "1.81.0",
|
|
66
|
+
"@fontsource/nunito": "5.2.7"
|
|
66
67
|
},
|
|
67
68
|
"dependencies": {
|
|
68
69
|
"@krainovsd/js-helpers": "^0.16.5",
|