@krainovsd/graph 0.11.0 → 0.12.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 +39 -64
- package/lib/cjs/index.cjs.map +1 -1
- package/lib/esm/constants/highlight-controls.js +18 -18
- package/lib/esm/constants/highlight-controls.js.map +1 -1
- package/lib/esm/index.js +0 -1
- package/lib/esm/index.js.map +1 -1
- package/lib/esm/module/GraphCanvas/GraphCanvas.js +14 -12
- package/lib/esm/module/GraphCanvas/GraphCanvas.js.map +1 -1
- package/lib/esm/module/GraphCanvas/constants/graph-settings.js +0 -2
- package/lib/esm/module/GraphCanvas/constants/graph-settings.js.map +1 -1
- package/lib/esm/module/GraphCanvas/constants/highlight-settings.js +2 -2
- package/lib/esm/module/GraphCanvas/constants/highlight-settings.js.map +1 -1
- package/lib/esm/module/GraphCanvas/lib/utils/node-highlight.js +2 -1
- package/lib/esm/module/GraphCanvas/lib/utils/node-highlight.js.map +1 -1
- package/lib/esm/module/GraphCanvas/slices/draw-nodes.js +0 -2
- package/lib/esm/module/GraphCanvas/slices/draw-nodes.js.map +1 -1
- package/lib/esm/module/GraphCanvas/slices/init-draw.js +2 -2
- package/lib/esm/module/GraphCanvas/slices/init-draw.js.map +1 -1
- package/lib/esm/module/GraphCanvas/slices/init-resize.js +1 -3
- package/lib/esm/module/GraphCanvas/slices/init-resize.js.map +1 -1
- package/lib/index.d.ts +8 -9
- package/package.json +1 -1
- package/lib/esm/constants/graph-controls.js +0 -25
- package/lib/esm/constants/graph-controls.js.map +0 -1
package/lib/cjs/index.cjs
CHANGED
|
@@ -46,8 +46,6 @@ const GRAPH_SETTINGS = {
|
|
|
46
46
|
translateExtent: [[], []],
|
|
47
47
|
translateExtentEnable: true,
|
|
48
48
|
translateExtentCoefficient: [3, 3],
|
|
49
|
-
highlightUpFrames: 5,
|
|
50
|
-
highlightDownFrames: 5,
|
|
51
49
|
dragPlaceCoefficient: dragPlaceCoefficientGetter,
|
|
52
50
|
zoomInitial: null,
|
|
53
51
|
showDrawTime: true,
|
|
@@ -57,6 +55,8 @@ const GRAPH_SETTINGS = {
|
|
|
57
55
|
const HIGHLIGHT_SETTINGS = {
|
|
58
56
|
highlightByHoverNode: true,
|
|
59
57
|
highlightByHoverLink: true,
|
|
58
|
+
highlightUpFrames: 5,
|
|
59
|
+
highlightDownFrames: 5,
|
|
60
60
|
linkHoverExtraZone: 2,
|
|
61
61
|
/** Node */
|
|
62
62
|
highlightByNodeOnlyRoot: true,
|
|
@@ -64,7 +64,6 @@ const HIGHLIGHT_SETTINGS = {
|
|
|
64
64
|
highlightByNodeForNodeColor: null,
|
|
65
65
|
highlightByNodeForNodeSizingAdditional: 0.5,
|
|
66
66
|
highlightByNodeForNodeSizingAdditionalCoefficient: 0.35,
|
|
67
|
-
highlightByNodeForNodeColorFadingMin: 0.15,
|
|
68
67
|
highlightByNodeForNodeFadingMin: 0.21,
|
|
69
68
|
highlightByNodeForNodeBorderColor: null,
|
|
70
69
|
highlightByNodeForNodeBorderSizingAdditional: 0,
|
|
@@ -72,7 +71,6 @@ const HIGHLIGHT_SETTINGS = {
|
|
|
72
71
|
highlightByLinkForNodeColor: null,
|
|
73
72
|
highlightByLinkForNodeSizingAdditional: 0.5,
|
|
74
73
|
highlightByLinkForNodeSizingAdditionalCoefficient: 0.35,
|
|
75
|
-
highlightByLinkForNodeColorFadingMin: 0.15,
|
|
76
74
|
highlightByLinkForNodeFadingMin: 0.21,
|
|
77
75
|
highlightByLinkForNodeBorderColor: null,
|
|
78
76
|
highlightByLinkForNodeBorderSizingAdditional: 0,
|
|
@@ -1046,9 +1044,10 @@ function nodeFade(opts) {
|
|
|
1046
1044
|
/** Color Fading */
|
|
1047
1045
|
const colorRgb = extractRgb(colorToRgb(color));
|
|
1048
1046
|
if (colorRgb) {
|
|
1049
|
-
const colorRgbFade = fadeRgb(colorRgb, opts.
|
|
1047
|
+
const colorRgbFade = fadeRgb(colorRgb, opts.highlightForNodeFadingMin);
|
|
1050
1048
|
const colorFadeAnimation = rgbAnimationByProgress(colorRgb, colorRgbFade, opts.highlightProgress);
|
|
1051
1049
|
color = `rgb(${colorFadeAnimation.r}, ${colorFadeAnimation.g}, ${colorFadeAnimation.b})`;
|
|
1050
|
+
alpha = opts.nodeOptions.alpha;
|
|
1052
1051
|
}
|
|
1053
1052
|
}
|
|
1054
1053
|
return {
|
|
@@ -1557,7 +1556,6 @@ function getDrawNode(nodeRenders, textRenders) {
|
|
|
1557
1556
|
nodeOptions,
|
|
1558
1557
|
highlightForLabelFadingMin: this.highlightSettings.highlightByNodeForLabelFadingMin,
|
|
1559
1558
|
highlightForNodeColorFading: this.highlightSettings.highlightByNodeForNodeColorFading,
|
|
1560
|
-
highlightForNodeColorFadingMin: this.highlightSettings.highlightByNodeForNodeColorFadingMin,
|
|
1561
1559
|
highlightForNodeFadingMin: this.highlightSettings.highlightByNodeForNodeFadingMin,
|
|
1562
1560
|
highlightForTextFadingMin: this.highlightSettings.highlightByNodeForTextFadingMin,
|
|
1563
1561
|
});
|
|
@@ -1608,7 +1606,6 @@ function getDrawNode(nodeRenders, textRenders) {
|
|
|
1608
1606
|
nodeOptions,
|
|
1609
1607
|
highlightForLabelFadingMin: this.highlightSettings.highlightByLinkForLabelFadingMin,
|
|
1610
1608
|
highlightForNodeColorFading: this.highlightSettings.highlightByLinkForNodeColorFading,
|
|
1611
|
-
highlightForNodeColorFadingMin: this.highlightSettings.highlightByLinkForNodeColorFadingMin,
|
|
1612
1609
|
highlightForNodeFadingMin: this.highlightSettings.highlightByLinkForNodeFadingMin,
|
|
1613
1610
|
highlightForTextFadingMin: this.highlightSettings.highlightByLinkForTextFadingMin,
|
|
1614
1611
|
});
|
|
@@ -1950,7 +1947,7 @@ function initDraw() {
|
|
|
1950
1947
|
function calculateHighlight() {
|
|
1951
1948
|
this.highlightDrawing = true;
|
|
1952
1949
|
if (!this.highlightWorking && this.highlightProgress > 0) {
|
|
1953
|
-
const highlightDownStep = 1 / this.
|
|
1950
|
+
const highlightDownStep = 1 / this.highlightSettings.highlightDownFrames;
|
|
1954
1951
|
this.highlightProgress -= highlightDownStep;
|
|
1955
1952
|
if (!this.simulationWorking) {
|
|
1956
1953
|
return void requestAnimationFrame(() => this.draw());
|
|
@@ -1959,7 +1956,7 @@ function initDraw() {
|
|
|
1959
1956
|
return;
|
|
1960
1957
|
}
|
|
1961
1958
|
if (this.highlightWorking && this.highlightProgress < 1) {
|
|
1962
|
-
const highlightUpStep = 1 / this.
|
|
1959
|
+
const highlightUpStep = 1 / this.highlightSettings.highlightUpFrames;
|
|
1963
1960
|
this.highlightProgress += highlightUpStep;
|
|
1964
1961
|
if (!this.simulationWorking) {
|
|
1965
1962
|
return void requestAnimationFrame(() => this.draw());
|
|
@@ -2236,9 +2233,7 @@ function initResize() {
|
|
|
2236
2233
|
observer.disconnect();
|
|
2237
2234
|
return;
|
|
2238
2235
|
}
|
|
2239
|
-
|
|
2240
|
-
this.updateSize();
|
|
2241
|
-
});
|
|
2236
|
+
this.updateSize();
|
|
2242
2237
|
});
|
|
2243
2238
|
document.addEventListener("scroll", this.updateRect.bind(this), {
|
|
2244
2239
|
capture: true,
|
|
@@ -2552,8 +2547,20 @@ class GraphCanvas {
|
|
|
2552
2547
|
this.tick();
|
|
2553
2548
|
}
|
|
2554
2549
|
updateRect() {
|
|
2555
|
-
if (this.area)
|
|
2556
|
-
|
|
2550
|
+
if (!this.area)
|
|
2551
|
+
return;
|
|
2552
|
+
this.areaRect = this.area.getBoundingClientRect();
|
|
2553
|
+
}
|
|
2554
|
+
updateSize() {
|
|
2555
|
+
if (!this.area)
|
|
2556
|
+
return;
|
|
2557
|
+
const { width, height } = this.root.getBoundingClientRect();
|
|
2558
|
+
this.width = width;
|
|
2559
|
+
this.height = height;
|
|
2560
|
+
this.area.width = this.dpi * this.width;
|
|
2561
|
+
this.area.height = this.dpi * this.height;
|
|
2562
|
+
this.areaRect = this.area.getBoundingClientRect();
|
|
2563
|
+
this.draw();
|
|
2557
2564
|
}
|
|
2558
2565
|
clearCache(keys) {
|
|
2559
2566
|
if (!keys) {
|
|
@@ -2647,16 +2654,6 @@ class GraphCanvas {
|
|
|
2647
2654
|
.restart();
|
|
2648
2655
|
}
|
|
2649
2656
|
}
|
|
2650
|
-
updateSize() {
|
|
2651
|
-
this.clearHTMLElements();
|
|
2652
|
-
initArea.call(this);
|
|
2653
|
-
initDnd.call(this);
|
|
2654
|
-
initZoom.call(this);
|
|
2655
|
-
initResize.call(this);
|
|
2656
|
-
initPointer.call(this);
|
|
2657
|
-
if (!this.simulationWorking && !this.highlightWorking)
|
|
2658
|
-
this.draw();
|
|
2659
|
-
}
|
|
2660
2657
|
init() {
|
|
2661
2658
|
initArea.call(this);
|
|
2662
2659
|
initSimulation.call(this);
|
|
@@ -2802,27 +2799,6 @@ const FORCE_CONTROLS = [
|
|
|
2802
2799
|
},
|
|
2803
2800
|
];
|
|
2804
2801
|
|
|
2805
|
-
const GRAPH_CONTROLS = [
|
|
2806
|
-
{
|
|
2807
|
-
id: "highlightDownFrames",
|
|
2808
|
-
initialValue: GRAPH_SETTINGS.highlightDownFrames,
|
|
2809
|
-
max: 60,
|
|
2810
|
-
min: 1,
|
|
2811
|
-
step: 1,
|
|
2812
|
-
type: "range",
|
|
2813
|
-
label: "Скорость отмены анимации в кадрах",
|
|
2814
|
-
},
|
|
2815
|
-
{
|
|
2816
|
-
id: "highlightUpFrames",
|
|
2817
|
-
initialValue: GRAPH_SETTINGS.highlightUpFrames,
|
|
2818
|
-
max: 60,
|
|
2819
|
-
min: 1,
|
|
2820
|
-
step: 1,
|
|
2821
|
-
type: "range",
|
|
2822
|
-
label: "Скорость применения анимации в кадрах",
|
|
2823
|
-
},
|
|
2824
|
-
];
|
|
2825
|
-
|
|
2826
2802
|
const HIGHLIGHT_COMMON_CONTROLS = [
|
|
2827
2803
|
{
|
|
2828
2804
|
id: "highlightByHoverNode",
|
|
@@ -2845,6 +2821,24 @@ const HIGHLIGHT_COMMON_CONTROLS = [
|
|
|
2845
2821
|
type: "range",
|
|
2846
2822
|
label: "Расширение границы связи для курсора",
|
|
2847
2823
|
},
|
|
2824
|
+
{
|
|
2825
|
+
id: "highlightDownFrames",
|
|
2826
|
+
initialValue: HIGHLIGHT_SETTINGS.highlightDownFrames,
|
|
2827
|
+
max: 60,
|
|
2828
|
+
min: 1,
|
|
2829
|
+
step: 1,
|
|
2830
|
+
type: "range",
|
|
2831
|
+
label: "Скорость отмены анимации в кадрах",
|
|
2832
|
+
},
|
|
2833
|
+
{
|
|
2834
|
+
id: "highlightUpFrames",
|
|
2835
|
+
initialValue: HIGHLIGHT_SETTINGS.highlightUpFrames,
|
|
2836
|
+
max: 60,
|
|
2837
|
+
min: 1,
|
|
2838
|
+
step: 1,
|
|
2839
|
+
type: "range",
|
|
2840
|
+
label: "Скорость применения анимации в кадрах",
|
|
2841
|
+
},
|
|
2848
2842
|
];
|
|
2849
2843
|
const HIGHLIGHT_BY_NODE_FOR_NODE_CONTROLS = [
|
|
2850
2844
|
{
|
|
@@ -2874,15 +2868,6 @@ const HIGHLIGHT_BY_NODE_FOR_NODE_CONTROLS = [
|
|
|
2874
2868
|
type: "range",
|
|
2875
2869
|
label: "Граница прозрачности",
|
|
2876
2870
|
},
|
|
2877
|
-
{
|
|
2878
|
-
id: "highlightByNodeForNodeColorFadingMin",
|
|
2879
|
-
initialValue: HIGHLIGHT_SETTINGS.highlightByNodeForNodeColorFadingMin,
|
|
2880
|
-
max: 1,
|
|
2881
|
-
min: 0.01,
|
|
2882
|
-
step: 0.01,
|
|
2883
|
-
type: "range",
|
|
2884
|
-
label: "Граница прозрачности без альфа канала",
|
|
2885
|
-
},
|
|
2886
2871
|
{
|
|
2887
2872
|
id: "highlightByNodeForNodeSizingAdditional",
|
|
2888
2873
|
initialValue: HIGHLIGHT_SETTINGS.highlightByNodeForNodeSizingAdditional,
|
|
@@ -3082,15 +3067,6 @@ const HIGHLIGHT_BY_LINK_FOR_NODE_CONTROLS = [
|
|
|
3082
3067
|
type: "range",
|
|
3083
3068
|
label: "Граница прозрачности",
|
|
3084
3069
|
},
|
|
3085
|
-
{
|
|
3086
|
-
id: "highlightByLinkForNodeColorFadingMin",
|
|
3087
|
-
initialValue: HIGHLIGHT_SETTINGS.highlightByLinkForNodeColorFadingMin,
|
|
3088
|
-
max: 1,
|
|
3089
|
-
min: 0.01,
|
|
3090
|
-
step: 0.01,
|
|
3091
|
-
type: "range",
|
|
3092
|
-
label: "Граница прозрачности без альфа канала",
|
|
3093
|
-
},
|
|
3094
3070
|
{
|
|
3095
3071
|
id: "highlightByLinkForNodeSizingAdditional",
|
|
3096
3072
|
initialValue: HIGHLIGHT_SETTINGS.highlightByLinkForNodeSizingAdditional,
|
|
@@ -3824,7 +3800,6 @@ const NODE_OPTIONS_LABEL_CONTROLS = [
|
|
|
3824
3800
|
exports.COMMON_SETTINGS = COMMON_SETTINGS;
|
|
3825
3801
|
exports.FORCE_CONTROLS = FORCE_CONTROLS;
|
|
3826
3802
|
exports.FORCE_SETTINGS = FORCE_SETTINGS;
|
|
3827
|
-
exports.GRAPH_CONTROLS = GRAPH_CONTROLS;
|
|
3828
3803
|
exports.GRAPH_SETTINGS = GRAPH_SETTINGS;
|
|
3829
3804
|
exports.GraphCanvas = GraphCanvas;
|
|
3830
3805
|
exports.HIGHLIGHT_BY_LINK_FOR_ARROW_CONTROLS = HIGHLIGHT_BY_LINK_FOR_ARROW_CONTROLS;
|