@unovis/ts 1.5.1-exf.9 → 1.5.1-ql.2
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/components/donut/config.d.ts +0 -4
- package/components/donut/config.js +1 -1
- package/components/donut/config.js.map +1 -1
- package/components/donut/index.js +5 -35
- package/components/donut/index.js.map +1 -1
- package/components/graph/config.d.ts +1 -15
- package/components/graph/config.js +2 -5
- package/components/graph/config.js.map +1 -1
- package/components/graph/index.d.ts +9 -12
- package/components/graph/index.js +21 -33
- package/components/graph/index.js.map +1 -1
- package/components/graph/modules/link/index.d.ts +2 -3
- package/components/graph/modules/link/index.js +24 -47
- package/components/graph/modules/link/index.js.map +1 -1
- package/components/graph/modules/link/style.js +2 -0
- package/components/graph/modules/link/style.js.map +1 -1
- package/components/graph/modules/node/index.d.ts +0 -2
- package/components/graph/modules/node/index.js +4 -7
- package/components/graph/modules/node/index.js.map +1 -1
- package/components/graph/modules/panel/index.js +2 -2
- package/components/graph/modules/panel/index.js.map +1 -1
- package/components/graph/types.d.ts +0 -5
- package/components/graph/types.js.map +1 -1
- package/components/nested-donut/config.d.ts +1 -1
- package/components/nested-donut/config.js.map +1 -1
- package/components.d.ts +0 -3
- package/components.js +0 -2
- package/components.js.map +1 -1
- package/data-models/graph.d.ts +2 -3
- package/data-models/graph.js +6 -15
- package/data-models/graph.js.map +1 -1
- package/index.d.ts +0 -1
- package/index.js +0 -7
- package/index.js.map +1 -1
- package/package.json +2 -1
- package/types/graph.d.ts +0 -4
- package/types.d.ts +0 -1
- package/types.js +0 -1
- package/types.js.map +1 -1
- package/utils/data.d.ts +1 -1
- package/utils/data.js +6 -7
- package/utils/data.js.map +1 -1
- package/utils/text.d.ts +8 -8
- package/utils/text.js +8 -16
- package/utils/text.js.map +1 -1
- package/components/donut/constants.d.ts +0 -2
- package/components/donut/constants.js +0 -8
- package/components/donut/constants.js.map +0 -1
- package/components/treemap/config.d.ts +0 -26
- package/components/treemap/config.js +0 -6
- package/components/treemap/config.js.map +0 -1
- package/components/treemap/index.d.ts +0 -14
- package/components/treemap/index.js +0 -149
- package/components/treemap/index.js.map +0 -1
- package/components/treemap/style.d.ts +0 -19
- package/components/treemap/style.js +0 -49
- package/components/treemap/style.js.map +0 -1
- package/components/treemap/types.d.ts +0 -10
- package/components/treemap/types.js +0 -2
- package/components/treemap/types.js.map +0 -1
- package/data-models/index.d.ts +0 -4
- package/data-models/index.js +0 -5
- package/data-models/index.js.map +0 -1
|
@@ -38,9 +38,5 @@ export interface DonutConfigInterface<Datum> extends ComponentConfigInterface {
|
|
|
38
38
|
showBackground?: boolean;
|
|
39
39
|
/** Background angle range. When undefined, the value will be taken from `angleRange`. Default: `undefined` */
|
|
40
40
|
backgroundAngleRange?: [number, number];
|
|
41
|
-
/** Central label and sub-label horizontal offset in pixels. Default: `undefined` */
|
|
42
|
-
centralLabelOffsetX?: number;
|
|
43
|
-
/** Central label and sub-label vertical offset in pixels. Default: `undefined` */
|
|
44
|
-
centralLabelOffsetY?: number;
|
|
45
41
|
}
|
|
46
42
|
export declare const DonutDefaultConfig: DonutConfigInterface<unknown>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ComponentDefaultConfig } from '../../core/component/config.js';
|
|
2
2
|
|
|
3
3
|
// Core
|
|
4
|
-
const DonutDefaultConfig = Object.assign(Object.assign({}, ComponentDefaultConfig), { id: (d, i) => { var _a; return (_a = d.id) !== null && _a !== void 0 ? _a : i; }, value: undefined, angleRange: [0, 2 * Math.PI], padAngle: 0, sortFunction: undefined, cornerRadius: 0, color: undefined, radius: undefined, arcWidth: 20, centralLabel: undefined, centralSubLabel: undefined, centralSubLabelWrap: true, showEmptySegments: false, emptySegmentAngle: 0.5 * Math.PI / 180, showBackground: true, backgroundAngleRange: undefined
|
|
4
|
+
const DonutDefaultConfig = Object.assign(Object.assign({}, ComponentDefaultConfig), { id: (d, i) => { var _a; return (_a = d.id) !== null && _a !== void 0 ? _a : i; }, value: undefined, angleRange: [0, 2 * Math.PI], padAngle: 0, sortFunction: undefined, cornerRadius: 0, color: undefined, radius: undefined, arcWidth: 20, centralLabel: undefined, centralSubLabel: undefined, centralSubLabelWrap: true, showEmptySegments: false, emptySegmentAngle: 0.5 * Math.PI / 180, showBackground: true, backgroundAngleRange: undefined });
|
|
5
5
|
|
|
6
6
|
export { DonutDefaultConfig };
|
|
7
7
|
//# sourceMappingURL=config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sources":["../../../src/components/donut/config.ts"],"sourcesContent":["// Core\nimport { ComponentConfigInterface, ComponentDefaultConfig } from 'core/component/config'\n\n// Types\nimport { ColorAccessor, NumericAccessor } from 'types/accessor'\n\nexport interface DonutConfigInterface<Datum> extends ComponentConfigInterface {\n /** Accessor function for getting the unique data record id. Used for more persistent data updates. Default: `(d, i) => d.id ?? i` */\n id?: ((d: Datum, i: number, ...any: unknown[]) => string | number);\n /** Value accessor function. Default: `undefined` */\n value: NumericAccessor<Datum>;\n /** Diagram angle range. Default: `[0, 2 * Math.PI]` */\n angleRange?: [number, number];\n /** Pad angle. Default: `0` */\n padAngle?: number;\n /** Custom sort function. Default: `undefined` */\n sortFunction?: (a: Datum, b: Datum) => number;\n /** Corner Radius. Default: `0` */\n cornerRadius?: number;\n /** Color accessor function. Default: `undefined` */\n color?: ColorAccessor<Datum>;\n /** Explicitly set the donut outer radius. Default: `undefined` */\n radius?: number;\n /** Arc width in pixels. Set to `0` if you want to have a pie chart. Default: `20` */\n arcWidth?: number;\n /** Central label accessor function or text. Default: `undefined` */\n centralLabel?: string;\n /** Central sub-label accessor function or text. Default: `undefined` */\n centralSubLabel?: string;\n /** Enables wrapping for the sub-label. Default: `true` */\n centralSubLabelWrap?: boolean;\n /** When true, the component will display empty segments (the ones that have `0` values) as tiny slices.\n * Default: `false`\n */\n showEmptySegments?: boolean;\n /** Angular size for empty segments in radians. Default: `0.5 * Math.PI / 180` */\n emptySegmentAngle?: number;\n /** Show donut background. The color is configurable via\n * the `--vis-donut-background-color` and `--vis-dark-donut-background-color` CSS variables.\n * Default: `true`\n */\n showBackground?: boolean;\n /** Background angle range. When undefined, the value will be taken from `angleRange`. Default: `undefined` */\n backgroundAngleRange?: [number, number];\n
|
|
1
|
+
{"version":3,"file":"config.js","sources":["../../../src/components/donut/config.ts"],"sourcesContent":["// Core\nimport { ComponentConfigInterface, ComponentDefaultConfig } from 'core/component/config'\n\n// Types\nimport { ColorAccessor, NumericAccessor } from 'types/accessor'\n\nexport interface DonutConfigInterface<Datum> extends ComponentConfigInterface {\n /** Accessor function for getting the unique data record id. Used for more persistent data updates. Default: `(d, i) => d.id ?? i` */\n id?: ((d: Datum, i: number, ...any: unknown[]) => string | number);\n /** Value accessor function. Default: `undefined` */\n value: NumericAccessor<Datum>;\n /** Diagram angle range. Default: `[0, 2 * Math.PI]` */\n angleRange?: [number, number];\n /** Pad angle. Default: `0` */\n padAngle?: number;\n /** Custom sort function. Default: `undefined` */\n sortFunction?: (a: Datum, b: Datum) => number;\n /** Corner Radius. Default: `0` */\n cornerRadius?: number;\n /** Color accessor function. Default: `undefined` */\n color?: ColorAccessor<Datum>;\n /** Explicitly set the donut outer radius. Default: `undefined` */\n radius?: number;\n /** Arc width in pixels. Set to `0` if you want to have a pie chart. Default: `20` */\n arcWidth?: number;\n /** Central label accessor function or text. Default: `undefined` */\n centralLabel?: string;\n /** Central sub-label accessor function or text. Default: `undefined` */\n centralSubLabel?: string;\n /** Enables wrapping for the sub-label. Default: `true` */\n centralSubLabelWrap?: boolean;\n /** When true, the component will display empty segments (the ones that have `0` values) as tiny slices.\n * Default: `false`\n */\n showEmptySegments?: boolean;\n /** Angular size for empty segments in radians. Default: `0.5 * Math.PI / 180` */\n emptySegmentAngle?: number;\n /** Show donut background. The color is configurable via\n * the `--vis-donut-background-color` and `--vis-dark-donut-background-color` CSS variables.\n * Default: `true`\n */\n showBackground?: boolean;\n /** Background angle range. When undefined, the value will be taken from `angleRange`. Default: `undefined` */\n backgroundAngleRange?: [number, number];\n}\n\nexport const DonutDefaultConfig: DonutConfigInterface<unknown> = {\n ...ComponentDefaultConfig,\n id: (d: unknown, i: number): string | number => (d as { id: string }).id ?? i,\n value: undefined,\n angleRange: [0, 2 * Math.PI],\n padAngle: 0,\n sortFunction: undefined,\n cornerRadius: 0,\n color: undefined,\n radius: undefined,\n arcWidth: 20,\n centralLabel: undefined,\n centralSubLabel: undefined,\n centralSubLabelWrap: true,\n showEmptySegments: false,\n emptySegmentAngle: 0.5 * Math.PI / 180,\n showBackground: true,\n backgroundAngleRange: undefined,\n}\n"],"names":[],"mappings":";;AAAA;MA8Ca,kBAAkB,GAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAC1B,sBAAsB,CACzB,EAAA,EAAA,EAAE,EAAE,CAAC,CAAU,EAAE,CAAS,KAAsB,EAAA,IAAA,EAAA,CAAA,CAAA,OAAA,MAAC,CAAoB,CAAC,EAAE,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAI,CAAC,CAAA,EAAA,EAC7E,KAAK,EAAE,SAAS,EAChB,UAAU,EAAE,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,EAAE,CAAC,EAC5B,QAAQ,EAAE,CAAC,EACX,YAAY,EAAE,SAAS,EACvB,YAAY,EAAE,CAAC,EACf,KAAK,EAAE,SAAS,EAChB,MAAM,EAAE,SAAS,EACjB,QAAQ,EAAE,EAAE,EACZ,YAAY,EAAE,SAAS,EACvB,eAAe,EAAE,SAAS,EAC1B,mBAAmB,EAAE,IAAI,EACzB,iBAAiB,EAAE,KAAK,EACxB,iBAAiB,EAAE,GAAG,GAAG,IAAI,CAAC,EAAE,GAAG,GAAG,EACtC,cAAc,EAAE,IAAI,EACpB,oBAAoB,EAAE,SAAS,EAAA;;;;"}
|
|
@@ -6,7 +6,6 @@ import { getNumber, isNumber, clamp } from '../../utils/data.js';
|
|
|
6
6
|
import { wrapSVGText } from '../../utils/text.js';
|
|
7
7
|
import { DonutDefaultConfig } from './config.js';
|
|
8
8
|
import { createArc, updateArc, removeArc } from './modules/arc.js';
|
|
9
|
-
import { DONUT_HALF_ANGLE_RANGES } from './constants.js';
|
|
10
9
|
import * as style from './style.js';
|
|
11
10
|
import { centralLabel, centralSubLabel, segment, segmentExit, background } from './style.js';
|
|
12
11
|
|
|
@@ -41,22 +40,8 @@ class Donut extends ComponentCore {
|
|
|
41
40
|
}))
|
|
42
41
|
.filter(d => config.showEmptySegments || getNumber(d.datum, config.value, d.index));
|
|
43
42
|
const duration = isNumber(customDuration) ? customDuration : config.duration;
|
|
44
|
-
|
|
45
|
-
// One of these is true if we are dealing with a half-donut.
|
|
46
|
-
const [isHalfDonutTop, isHalfDonutRight, isHalfDonutBottom, isHalfDonutLeft,] = DONUT_HALF_ANGLE_RANGES.map(angleRange => config.angleRange && (config.angleRange[0] === angleRange[0] &&
|
|
47
|
-
config.angleRange[1] === angleRange[1]));
|
|
48
|
-
const isVerticalHalfDonut = isHalfDonutTop || isHalfDonutBottom;
|
|
49
|
-
const isHorizontalHalfDonut = isHalfDonutRight || isHalfDonutLeft;
|
|
50
|
-
// Compute the bounding box of the donut,
|
|
51
|
-
// considering it may be a half-donut
|
|
52
|
-
const width = this._width * (isHorizontalHalfDonut ? 2 : 1);
|
|
53
|
-
const height = this._height * (isVerticalHalfDonut ? 2 : 1);
|
|
54
|
-
const outerRadius = config.radius || Math.min(width - bleed.left - bleed.right, height - bleed.top - bleed.bottom) / 2;
|
|
43
|
+
const outerRadius = config.radius || Math.min(this._width - bleed.left - bleed.right, this._height - bleed.top - bleed.bottom) / 2;
|
|
55
44
|
const innerRadius = config.arcWidth === 0 ? 0 : clamp(outerRadius - config.arcWidth, 0, outerRadius - 1);
|
|
56
|
-
const translateY = this._height / 2 + (isHalfDonutTop ? outerRadius / 2 : isHalfDonutBottom ? -outerRadius / 2 : 0);
|
|
57
|
-
const translateX = this._width / 2 + (isHalfDonutLeft ? outerRadius / 2 : isHalfDonutRight ? -outerRadius / 2 : 0);
|
|
58
|
-
const translate = `translate(${translateX},${translateY})`;
|
|
59
|
-
this.arcGroup.attr('transform', translate);
|
|
60
45
|
this.arcGen
|
|
61
46
|
.startAngle(d => d.startAngle)
|
|
62
47
|
.endAngle(d => d.endAngle)
|
|
@@ -70,6 +55,7 @@ class Donut extends ComponentCore {
|
|
|
70
55
|
.padAngle(config.padAngle)
|
|
71
56
|
.value(d => getNumber(d.datum, config.value, d.index) || 0)
|
|
72
57
|
.sort((a, b) => { var _a; return (_a = config.sortFunction) === null || _a === void 0 ? void 0 : _a.call(config, a.datum, b.datum); });
|
|
58
|
+
this.arcGroup.attr('transform', `translate(${this._width / 2},${this._height / 2})`);
|
|
73
59
|
const arcData = pieGen(data).map(d => {
|
|
74
60
|
const arc = Object.assign(Object.assign({}, d), { data: d.data.datum, index: d.data.index, innerRadius,
|
|
75
61
|
outerRadius });
|
|
@@ -93,36 +79,20 @@ class Donut extends ComponentCore {
|
|
|
93
79
|
.attr('class', segmentExit)
|
|
94
80
|
.call(removeArc, duration);
|
|
95
81
|
// Label
|
|
96
|
-
const labelTextAnchor = isHalfDonutRight ? 'start' : isHalfDonutLeft ? 'end' : 'middle';
|
|
97
82
|
this.centralLabel
|
|
83
|
+
.attr('transform', `translate(${this._width / 2},${this._height / 2})`)
|
|
98
84
|
.attr('dy', config.centralSubLabel ? '-0.55em' : null)
|
|
99
|
-
.style('text-anchor', labelTextAnchor)
|
|
100
85
|
.text((_e = config.centralLabel) !== null && _e !== void 0 ? _e : null);
|
|
101
86
|
this.centralSubLabel
|
|
87
|
+
.attr('transform', `translate(${this._width / 2},${this._height / 2})`)
|
|
102
88
|
.attr('dy', config.centralLabel ? '0.55em' : null)
|
|
103
|
-
.style('text-anchor', labelTextAnchor)
|
|
104
89
|
.text((_f = config.centralSubLabel) !== null && _f !== void 0 ? _f : null);
|
|
105
90
|
if (config.centralSubLabelWrap)
|
|
106
91
|
wrapSVGText(this.centralSubLabel, innerRadius * 1.9);
|
|
107
|
-
// Label placement
|
|
108
|
-
const labelTranslateX = (config.centralLabelOffsetX || 0) + translateX;
|
|
109
|
-
let labelTranslateY = (config.centralLabelOffsetY || 0) + translateY;
|
|
110
|
-
// Special case label placement for half donut
|
|
111
|
-
if (isVerticalHalfDonut && config.centralLabelOffsetX === undefined && config.centralLabelOffsetY === undefined) {
|
|
112
|
-
const halfDonutLabelOffsetY = isHalfDonutTop
|
|
113
|
-
? -this.centralSubLabel.node().getBoundingClientRect().height
|
|
114
|
-
: isHalfDonutBottom
|
|
115
|
-
? this.centralLabel.node().getBoundingClientRect().height
|
|
116
|
-
: 0;
|
|
117
|
-
labelTranslateY = halfDonutLabelOffsetY + translateY;
|
|
118
|
-
}
|
|
119
|
-
const labelTranslate = `translate(${labelTranslateX},${labelTranslateY})`;
|
|
120
|
-
this.centralLabel.attr('transform', labelTranslate);
|
|
121
|
-
this.centralSubLabel.attr('transform', labelTranslate);
|
|
122
92
|
// Background
|
|
123
93
|
this.arcBackground.attr('class', background)
|
|
124
94
|
.attr('visibility', config.showBackground ? null : 'hidden')
|
|
125
|
-
.attr('transform', translate);
|
|
95
|
+
.attr('transform', `translate(${this._width / 2},${this._height / 2})`);
|
|
126
96
|
smartTransition(this.arcBackground, duration)
|
|
127
97
|
.attr('d', this.arcGen({
|
|
128
98
|
startAngle: (_k = (_h = (_g = config.backgroundAngleRange) === null || _g === void 0 ? void 0 : _g[0]) !== null && _h !== void 0 ? _h : (_j = config.angleRange) === null || _j === void 0 ? void 0 : _j[0]) !== null && _k !== void 0 ? _k : 0,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/components/donut/index.ts"],"sourcesContent":["import { Selection } from 'd3-selection'\nimport { pie, arc } from 'd3-shape'\n\n// Core\nimport { ComponentCore } from 'core/component'\nimport { SeriesDataModel } from 'data-models/series'\n\n// Utils\nimport { smartTransition } from 'utils/d3'\nimport { isNumber, clamp, getNumber } from 'utils/data'\nimport { wrapSVGText } from 'utils/text'\n\n// Types\nimport { Spacing } from 'types/spacing'\n\n// Local Types\nimport { DonutArcDatum, DonutArcAnimState, DonutDatum } from './types'\n\n// Config\nimport { DonutDefaultConfig, DonutConfigInterface } from './config'\n\n// Modules\nimport { createArc, updateArc, removeArc } from './modules/arc'\n\n// Constants\nimport { DONUT_HALF_ANGLE_RANGES } from './constants'\n\n// Styles\nimport * as s from './style'\n\nexport class Donut<Datum> extends ComponentCore<Datum[], DonutConfigInterface<Datum>> {\n static selectors = s\n protected _defaultConfig = DonutDefaultConfig as DonutConfigInterface<Datum>\n public config: DonutConfigInterface<Datum> = this._defaultConfig\n\n datamodel: SeriesDataModel<Datum> = new SeriesDataModel()\n\n arcBackground: Selection<SVGPathElement, unknown, SVGGElement, unknown>\n arcGroup: Selection<SVGGElement, unknown, SVGGElement, unknown>\n centralLabel: Selection<SVGTextElement, unknown, SVGGElement, unknown>\n centralSubLabel: Selection<SVGTextElement, unknown, SVGGElement, unknown>\n arcGen = arc<DonutArcAnimState>()\n\n events = {\n }\n\n constructor (config?: DonutConfigInterface<Datum>) {\n super()\n if (config) this.setConfig(config)\n this.arcBackground = this.g.append('path')\n this.arcGroup = this.g.append('g')\n this.centralLabel = this.g.append('text')\n .attr('class', s.centralLabel)\n this.centralSubLabel = this.g.append('text')\n .attr('class', s.centralSubLabel)\n }\n\n get bleed (): Spacing {\n return { top: 0, bottom: 0, left: 0, right: 0 }\n }\n\n _render (customDuration?: number): void {\n const { config, datamodel, bleed } = this\n\n // Wrap data to preserve original indices\n const data: DonutDatum<Datum>[] = datamodel.data\n .map((d, i) => ({\n index: i,\n datum: d,\n }))\n .filter(d => config.showEmptySegments || getNumber(d.datum, config.value, d.index))\n\n const duration = isNumber(customDuration) ? customDuration : config.duration\n\n // Handle half-donut cases, which adjust the scaling and positioning.\n // One of these is true if we are dealing with a half-donut.\n const [\n isHalfDonutTop,\n isHalfDonutRight,\n isHalfDonutBottom,\n isHalfDonutLeft,\n ] = DONUT_HALF_ANGLE_RANGES.map(angleRange =>\n config.angleRange && (\n config.angleRange[0] === angleRange[0] &&\n config.angleRange[1] === angleRange[1]\n )\n )\n const isVerticalHalfDonut = isHalfDonutTop || isHalfDonutBottom\n const isHorizontalHalfDonut = isHalfDonutRight || isHalfDonutLeft\n\n // Compute the bounding box of the donut,\n // considering it may be a half-donut\n const width = this._width * (isHorizontalHalfDonut ? 2 : 1)\n const height = this._height * (isVerticalHalfDonut ? 2 : 1)\n\n const outerRadius = config.radius || Math.min(width - bleed.left - bleed.right, height - bleed.top - bleed.bottom) / 2\n const innerRadius = config.arcWidth === 0 ? 0 : clamp(outerRadius - config.arcWidth, 0, outerRadius - 1)\n\n const translateY = this._height / 2 + (isHalfDonutTop ? outerRadius / 2 : isHalfDonutBottom ? -outerRadius / 2 : 0)\n const translateX = this._width / 2 + (isHalfDonutLeft ? outerRadius / 2 : isHalfDonutRight ? -outerRadius / 2 : 0)\n const translate = `translate(${translateX},${translateY})`\n\n this.arcGroup.attr('transform', translate)\n\n this.arcGen\n .startAngle(d => d.startAngle)\n .endAngle(d => d.endAngle)\n .innerRadius(d => d.innerRadius)\n .outerRadius(d => d.outerRadius)\n .padAngle(d => d.padAngle)\n .cornerRadius(config.cornerRadius)\n\n const pieGen = pie<DonutDatum<Datum>>()\n .startAngle(config.angleRange?.[0] ?? 0)\n .endAngle(config.angleRange?.[1] ?? 2 * Math.PI)\n .padAngle(config.padAngle)\n .value(d => getNumber(d.datum, config.value, d.index) || 0)\n .sort((a, b) => config.sortFunction?.(a.datum, b.datum))\n\n const arcData: DonutArcDatum<Datum>[] = pieGen(data).map(d => {\n const arc = {\n ...d,\n data: d.data.datum,\n index: d.data.index,\n innerRadius,\n outerRadius,\n }\n\n if (config.showEmptySegments && d.endAngle - d.startAngle - d.padAngle <= Number.EPSILON) {\n arc.endAngle = d.startAngle + Math.max(config.emptySegmentAngle, config.padAngle)\n arc.padAngle = d.padAngle / 2\n }\n return arc\n })\n\n // Arc segments\n const arcsSelection = this.arcGroup\n .selectAll<SVGPathElement, DonutArcDatum<Datum>>(`.${s.segment}`)\n .data(arcData, (d: DonutArcDatum<Datum>) => config.id(d.data, d.index))\n\n const arcsEnter = arcsSelection.enter().append('path')\n .attr('class', s.segment)\n .call(createArc, config)\n\n const arcsMerged = arcsSelection.merge(arcsEnter)\n arcsMerged.call(updateArc, config, this.arcGen, duration)\n arcsMerged.sort((a, b) => b.value - a.value)\n\n arcsSelection.exit<DonutArcDatum<Datum>>()\n .attr('class', s.segmentExit)\n .call(removeArc, duration)\n\n // Label\n const labelTextAnchor = isHalfDonutRight ? 'start' : isHalfDonutLeft ? 'end' : 'middle'\n this.centralLabel\n .attr('dy', config.centralSubLabel ? '-0.55em' : null)\n .style('text-anchor', labelTextAnchor)\n .text(config.centralLabel ?? null)\n\n this.centralSubLabel\n .attr('dy', config.centralLabel ? '0.55em' : null)\n .style('text-anchor', labelTextAnchor)\n .text(config.centralSubLabel ?? null)\n\n if (config.centralSubLabelWrap) wrapSVGText(this.centralSubLabel, innerRadius * 1.9)\n\n // Label placement\n const labelTranslateX = (config.centralLabelOffsetX || 0) + translateX\n let labelTranslateY = (config.centralLabelOffsetY || 0) + translateY\n\n // Special case label placement for half donut\n if (isVerticalHalfDonut && config.centralLabelOffsetX === undefined && config.centralLabelOffsetY === undefined) {\n const halfDonutLabelOffsetY = isHalfDonutTop\n ? -this.centralSubLabel.node().getBoundingClientRect().height\n : isHalfDonutBottom\n ? this.centralLabel.node().getBoundingClientRect().height\n : 0\n labelTranslateY = halfDonutLabelOffsetY + translateY\n }\n const labelTranslate = `translate(${labelTranslateX},${labelTranslateY})`\n this.centralLabel.attr('transform', labelTranslate)\n this.centralSubLabel.attr('transform', labelTranslate)\n\n // Background\n this.arcBackground.attr('class', s.background)\n .attr('visibility', config.showBackground ? null : 'hidden')\n .attr('transform', translate)\n\n smartTransition(this.arcBackground, duration)\n .attr('d', this.arcGen({\n startAngle: config.backgroundAngleRange?.[0] ?? config.angleRange?.[0] ?? 0,\n endAngle: config.backgroundAngleRange?.[1] ?? config.angleRange?.[1] ?? 2 * Math.PI,\n innerRadius,\n outerRadius,\n }))\n }\n}\n\n"],"names":["s.centralLabel","s.centralSubLabel","s.segment","s.segmentExit","s.background","s"],"mappings":";;;;;;;;;;;;AA8BM,MAAO,KAAa,SAAQ,aAAmD,CAAA;AAgBnF,IAAA,WAAA,CAAa,MAAoC,EAAA;AAC/C,QAAA,KAAK,EAAE,CAAA;QAfC,IAAc,CAAA,cAAA,GAAG,kBAAiD,CAAA;AACrE,QAAA,IAAA,CAAA,MAAM,GAAgC,IAAI,CAAC,cAAc,CAAA;AAEhE,QAAA,IAAA,CAAA,SAAS,GAA2B,IAAI,eAAe,EAAE,CAAA;QAMzD,IAAM,CAAA,MAAA,GAAG,GAAG,EAAqB,CAAA;QAEjC,IAAM,CAAA,MAAA,GAAG,EACR,CAAA;AAIC,QAAA,IAAI,MAAM;AAAE,YAAA,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAA;QAClC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;QAC1C,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;QAClC,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;AACtC,aAAA,IAAI,CAAC,OAAO,EAAEA,YAAc,CAAC,CAAA;QAChC,IAAI,CAAC,eAAe,GAAG,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC;AACzC,aAAA,IAAI,CAAC,OAAO,EAAEC,eAAiB,CAAC,CAAA;KACpC;AAED,IAAA,IAAI,KAAK,GAAA;AACP,QAAA,OAAO,EAAE,GAAG,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE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GAAA,EAAA,GAAI,MAAA,MAAM,CAAC,UAAU,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAG,CAAC,CAAC,mCAAI,CAAC,GAAG,IAAI,CAAC,EAAE;YACnF,WAAW;YACX,WAAW;AACZ,SAAA,CAAC,CAAC,CAAA;KACN;;AApKM,KAAS,CAAA,SAAA,GAAGC,KAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/donut/index.ts"],"sourcesContent":["import { Selection } from 'd3-selection'\nimport { pie, arc } from 'd3-shape'\n\n// Core\nimport { ComponentCore } from 'core/component'\nimport { SeriesDataModel } from 'data-models/series'\n\n// Utils\nimport { smartTransition } from 'utils/d3'\nimport { isNumber, clamp, getNumber } from 'utils/data'\nimport { wrapSVGText } from 'utils/text'\n\n// Types\nimport { Spacing } from 'types/spacing'\n\n// Local Types\nimport { DonutArcDatum, DonutArcAnimState, DonutDatum } from './types'\n\n// Config\nimport { DonutDefaultConfig, DonutConfigInterface } from './config'\n\n// Modules\nimport { createArc, updateArc, removeArc } from './modules/arc'\n\n// Styles\nimport * as s from './style'\n\nexport class Donut<Datum> extends ComponentCore<Datum[], DonutConfigInterface<Datum>> {\n static selectors = s\n protected _defaultConfig = DonutDefaultConfig as DonutConfigInterface<Datum>\n public config: DonutConfigInterface<Datum> = this._defaultConfig\n\n datamodel: SeriesDataModel<Datum> = new SeriesDataModel()\n\n arcBackground: Selection<SVGPathElement, unknown, SVGGElement, unknown>\n arcGroup: Selection<SVGGElement, unknown, SVGGElement, unknown>\n centralLabel: Selection<SVGTextElement, unknown, SVGGElement, unknown>\n centralSubLabel: Selection<SVGTextElement, unknown, SVGGElement, unknown>\n arcGen = arc<DonutArcAnimState>()\n\n events = {\n }\n\n constructor (config?: DonutConfigInterface<Datum>) {\n super()\n if (config) this.setConfig(config)\n this.arcBackground = this.g.append('path')\n this.arcGroup = this.g.append('g')\n this.centralLabel = this.g.append('text')\n .attr('class', s.centralLabel)\n this.centralSubLabel = this.g.append('text')\n .attr('class', s.centralSubLabel)\n }\n\n get bleed (): Spacing {\n return { top: 0, bottom: 0, left: 0, right: 0 }\n }\n\n _render (customDuration?: number): void {\n const { config, datamodel, bleed } = this\n\n // Wrap data to preserve original indices\n const data: DonutDatum<Datum>[] = datamodel.data\n .map((d, i) => ({\n index: i,\n datum: d,\n }))\n .filter(d => config.showEmptySegments || getNumber(d.datum, config.value, d.index))\n\n const duration = isNumber(customDuration) ? customDuration : config.duration\n const outerRadius = config.radius || Math.min(this._width - bleed.left - bleed.right, this._height - bleed.top - bleed.bottom) / 2\n const innerRadius = config.arcWidth === 0 ? 0 : clamp(outerRadius - config.arcWidth, 0, outerRadius - 1)\n\n this.arcGen\n .startAngle(d => d.startAngle)\n .endAngle(d => d.endAngle)\n .innerRadius(d => d.innerRadius)\n .outerRadius(d => d.outerRadius)\n .padAngle(d => d.padAngle)\n .cornerRadius(config.cornerRadius)\n\n const pieGen = pie<DonutDatum<Datum>>()\n .startAngle(config.angleRange?.[0] ?? 0)\n .endAngle(config.angleRange?.[1] ?? 2 * Math.PI)\n .padAngle(config.padAngle)\n .value(d => getNumber(d.datum, config.value, d.index) || 0)\n .sort((a, b) => config.sortFunction?.(a.datum, b.datum))\n\n this.arcGroup.attr('transform', `translate(${this._width / 2},${this._height / 2})`)\n\n const arcData: DonutArcDatum<Datum>[] = pieGen(data).map(d => {\n const arc = {\n ...d,\n data: d.data.datum,\n index: d.data.index,\n innerRadius,\n outerRadius,\n }\n\n if (config.showEmptySegments && d.endAngle - d.startAngle - d.padAngle <= Number.EPSILON) {\n arc.endAngle = d.startAngle + Math.max(config.emptySegmentAngle, config.padAngle)\n arc.padAngle = d.padAngle / 2\n }\n return arc\n })\n\n // Arc segments\n const arcsSelection = this.arcGroup\n .selectAll<SVGPathElement, DonutArcDatum<Datum>>(`.${s.segment}`)\n .data(arcData, (d: DonutArcDatum<Datum>) => config.id(d.data, d.index))\n\n const arcsEnter = arcsSelection.enter().append('path')\n .attr('class', s.segment)\n .call(createArc, config)\n\n const arcsMerged = arcsSelection.merge(arcsEnter)\n arcsMerged.call(updateArc, config, this.arcGen, duration)\n arcsMerged.sort((a, b) => b.value - a.value)\n\n arcsSelection.exit<DonutArcDatum<Datum>>()\n .attr('class', s.segmentExit)\n .call(removeArc, duration)\n\n // Label\n this.centralLabel\n .attr('transform', `translate(${this._width / 2},${this._height / 2})`)\n .attr('dy', config.centralSubLabel ? '-0.55em' : null)\n .text(config.centralLabel ?? null)\n\n this.centralSubLabel\n .attr('transform', `translate(${this._width / 2},${this._height / 2})`)\n .attr('dy', config.centralLabel ? '0.55em' : null)\n .text(config.centralSubLabel ?? null)\n\n if (config.centralSubLabelWrap) wrapSVGText(this.centralSubLabel, innerRadius * 1.9)\n\n // Background\n this.arcBackground.attr('class', s.background)\n .attr('visibility', config.showBackground ? null : 'hidden')\n .attr('transform', `translate(${this._width / 2},${this._height / 2})`)\n\n smartTransition(this.arcBackground, duration)\n .attr('d', this.arcGen({\n startAngle: config.backgroundAngleRange?.[0] ?? config.angleRange?.[0] ?? 0,\n endAngle: config.backgroundAngleRange?.[1] ?? config.angleRange?.[1] ?? 2 * Math.PI,\n innerRadius,\n outerRadius,\n }))\n }\n}\n"],"names":["s.centralLabel","s.centralSubLabel","s.segment","s.segmentExit","s.background","s"],"mappings":";;;;;;;;;;;AA2BM,MAAO,KAAa,SAAQ,aAAmD,CAAA;AAgBnF,IAAA,WAAA,CAAa,MAAoC,EAAA;AAC/C,QAAA,KAAK,EAAE,CAAA;QAfC,IAAc,CAAA,cAAA,GAAG,kBAAiD,CAAA;AACrE,QAAA,IAAA,CAAA,MAAM,GAAgC,IAAI,CAAC,cAAc,CAAA;AAEhE,QAAA,IAAA,CAAA,SAAS,GAA2B,IAAI,eAAe,EAAE,CAAA;QAMzD,IAAM,CAAA,MAAA,GAAG,GAAG,EAAqB,CAAA;QAEjC,IAAM,CAAA,MAAA,GAAG,EACR,CAAA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AC,MAAI,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAA,CAAA,EAAA,GAAA,MAAM,CAAC,UAAU,0CAAG,CAAC,CAAC,mCAAI,CAAC;YAC3E,QAAQ,EAAE,MAAA,CAAA,EAAA,GAAA,CAAA,EAAA,GAAA,MAAM,CAAC,oBAAoB,MAAG,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,CAAC,CAAC,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,EAAA,GAAI,MAAA,MAAM,CAAC,UAAU,MAAA,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAG,CAAC,CAAC,mCAAI,CAAC,GAAG,IAAI,CAAC,EAAE;YACnF,WAAW;YACX,WAAW;AACZ,SAAA,CAAC,CAAC,CAAA;KACN;;AAxHM,KAAS,CAAA,SAAA,GAAGC,KAAC;;;;"}
|
|
@@ -2,10 +2,9 @@ import { D3BrushEvent } from 'd3-brush';
|
|
|
2
2
|
import { D3DragEvent } from 'd3-drag';
|
|
3
3
|
import { D3ZoomEvent, ZoomTransform } from 'd3-zoom';
|
|
4
4
|
import { Selection } from 'd3-selection';
|
|
5
|
-
import type { GraphDataModel } from "../../data-models/graph";
|
|
6
5
|
import { ComponentConfigInterface } from "../../core/component/config";
|
|
7
6
|
import { TrimMode } from "../../types/text";
|
|
8
|
-
import { GraphInputLink, GraphInputNode
|
|
7
|
+
import { GraphInputLink, GraphInputNode } from "../../types/graph";
|
|
9
8
|
import { BooleanAccessor, ColorAccessor, NumericAccessor, StringAccessor, GenericAccessor } from "../../types/accessor";
|
|
10
9
|
import { GraphLayoutType, GraphCircleLabel, GraphLinkStyle, GraphLinkArrowStyle, GraphPanelConfig, GraphForceLayoutSettings, GraphElkLayoutSettings, GraphNodeShape, GraphDagreLayoutSetting, GraphNode, GraphLink, GraphNodeSelectionHighlightMode } from './types';
|
|
11
10
|
export interface GraphConfigInterface<N extends GraphInputNode, L extends GraphInputLink> extends ComponentConfigInterface {
|
|
@@ -110,12 +109,6 @@ export interface GraphConfigInterface<N extends GraphInputNode, L extends GraphI
|
|
|
110
109
|
* `1.5` - very curve.
|
|
111
110
|
* Default: `0` */
|
|
112
111
|
linkCurvature?: NumericAccessor<L>;
|
|
113
|
-
/** Highlight links on hover. Default: `true` */
|
|
114
|
-
linkHighlightOnHover?: boolean;
|
|
115
|
-
/** Offset [x,y] in pixels from the source node's center point where the link should start. Default: `undefined` */
|
|
116
|
-
linkSourcePointOffset?: GenericAccessor<[number, number], GraphLink<N, L>>;
|
|
117
|
-
/** Offset [x,y] in pixels from the target node's center point where the link should end. Default: `undefined` */
|
|
118
|
-
linkTargetPointOffset?: GenericAccessor<[number, number], GraphLink<N, L>>;
|
|
119
112
|
/** Set selected link by its unique id. Default: `undefined` */
|
|
120
113
|
selectedLinkId?: number | string;
|
|
121
114
|
/** Node size accessor function or constant value. Default: `30` */
|
|
@@ -213,12 +206,5 @@ export interface GraphConfigInterface<N extends GraphInputNode, L extends GraphI
|
|
|
213
206
|
onNodeSelectionDrag?: (selectedNodes: GraphNode<N, L>[], event: D3DragEvent<SVGGElement, GraphNode<N, L>, unknown>) => void;
|
|
214
207
|
/** Callback function to be called when the graph rendering is complete. Default: `undefined` */
|
|
215
208
|
onRenderComplete?: (g: Selection<SVGGElement, unknown, null, undefined>, nodes: GraphNode<N, L>[], links: GraphLink<N, L>[], config: GraphConfigInterface<N, L>, duration: number, zoomLevel: number, width: number, height: number) => void;
|
|
216
|
-
/** Determines whether the component should update when new data is provided.
|
|
217
|
-
* This function takes the previous and new data as parameters and returns a boolean
|
|
218
|
-
* indicating whether the update should proceed. Useful for fine-grained control over
|
|
219
|
-
* update behavior when your data has a complex nested structure.
|
|
220
|
-
* By default the `isEqual` function from Unovis will be used to do the comparison.
|
|
221
|
-
*/
|
|
222
|
-
shouldDataUpdate?: (prevData: GraphInputData<N, L>, nextData: GraphInputData<N, L>, datamodel: GraphDataModel<N, L, GraphNode<N, L>, GraphLink<N, L>>) => boolean;
|
|
223
209
|
}
|
|
224
210
|
export declare const GraphDefaultConfig: GraphConfigInterface<GraphInputNode, GraphInputLink>;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { isEqual } from '../../utils/data.js';
|
|
2
1
|
import { ComponentDefaultConfig } from '../../core/component/config.js';
|
|
3
2
|
import { TrimMode } from '../../types/text.js';
|
|
4
3
|
import { GraphLayoutType, GraphLinkStyle, GraphNodeShape, GraphNodeSelectionHighlightMode } from './types.js';
|
|
5
4
|
|
|
6
|
-
//
|
|
5
|
+
// Config
|
|
7
6
|
const GraphDefaultConfig = Object.assign(Object.assign({}, ComponentDefaultConfig), { duration: 1000, zoomScaleExtent: [0.35, 1.25], disableZoom: false, zoomEventFilter: undefined, disableDrag: false, disableBrush: false, zoomThrottledUpdateNodeThreshold: 100, layoutType: GraphLayoutType.Force, layoutAutofit: true, layoutAutofitTolerance: 8.0, layoutNonConnectedAside: false, layoutGroupOrder: [], layoutParallelSubGroupsPerRow: 1, layoutParallelNodesPerColumn: 6, layoutParallelGroupSpacing: undefined, layoutParallelSortConnectionsByGroup: undefined, layoutNodeGroup: (n) => n.group, layoutParallelNodeSubGroup: (n) => n.subgroup, forceLayoutSettings: {
|
|
8
7
|
linkDistance: 60,
|
|
9
8
|
linkStrength: 0.45,
|
|
@@ -15,9 +14,7 @@ const GraphDefaultConfig = Object.assign(Object.assign({}, ComponentDefaultConfi
|
|
|
15
14
|
}, dagreLayoutSettings: {
|
|
16
15
|
rankdir: 'BT',
|
|
17
16
|
ranker: 'longest-path',
|
|
18
|
-
}, layoutElkSettings: undefined, layoutElkNodeGroups: undefined, linkFlowAnimDuration: 20000, linkFlowParticleSize: 2, linkWidth: 1, linkStyle: GraphLinkStyle.Solid, linkBandWidth: 0, linkArrow: undefined, linkStroke: undefined, linkFlow: false, linkLabel: undefined, linkLabelShiftFromCenter: true, linkNeighborSpacing: 8, linkDisabled: false, linkCurvature: 0,
|
|
19
|
-
return !isEqual(prevData, nextData);
|
|
20
|
-
} });
|
|
17
|
+
}, layoutElkSettings: undefined, layoutElkNodeGroups: undefined, linkFlowAnimDuration: 20000, linkFlowParticleSize: 2, linkWidth: 1, linkStyle: GraphLinkStyle.Solid, linkBandWidth: 0, linkArrow: undefined, linkStroke: undefined, linkFlow: false, linkLabel: undefined, linkLabelShiftFromCenter: true, linkNeighborSpacing: 8, linkDisabled: false, linkCurvature: 0, selectedLinkId: undefined, nodeGaugeAnimDuration: 1500, nodeSize: 30, nodeStrokeWidth: 3, nodeShape: GraphNodeShape.Circle, nodeGaugeValue: 0, nodeIcon: (n) => n.icon, nodeIconSize: undefined, nodeLabel: (n) => n.label, nodeLabelTrim: true, nodeLabelTrimLength: 15, nodeLabelTrimMode: TrimMode.Middle, nodeSubLabel: '', nodeSubLabelTrim: true, nodeSubLabelTrimLength: 15, nodeSubLabelTrimMode: TrimMode.Middle, nodeSideLabels: undefined, nodeBottomIcon: undefined, nodeDisabled: false, nodeFill: (n) => n.fill, nodeGaugeFill: undefined, nodeStroke: (n) => n.stroke, nodeEnterPosition: undefined, nodeEnterScale: 0.75, nodeExitPosition: undefined, nodeExitScale: 0.75, nodeSort: undefined, nodeSelectionHighlightMode: GraphNodeSelectionHighlightMode.GreyoutNonConnected, selectedNodeId: undefined, selectedNodeIds: undefined, panels: undefined, onNodeDragStart: undefined, onNodeDrag: undefined, onNodeDragEnd: undefined, onZoom: undefined, onZoomStart: undefined, onZoomEnd: undefined, onLayoutCalculated: undefined, onNodeSelectionBrush: undefined, onNodeSelectionDrag: undefined, onRenderComplete: undefined });
|
|
21
18
|
|
|
22
19
|
export { GraphDefaultConfig };
|
|
23
20
|
//# sourceMappingURL=config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sources":["../../../src/components/graph/config.ts"],"sourcesContent":["import { D3BrushEvent } from 'd3-brush'\nimport { D3DragEvent } from 'd3-drag'\nimport { D3ZoomEvent, ZoomTransform } from 'd3-zoom'\nimport { Selection } from 'd3-selection'\n\n// Core\nimport type { GraphDataModel } from 'data-models/graph'\n\n// Utils\nimport { isEqual } from 'utils/data'\n\n// Config\nimport { ComponentConfigInterface, ComponentDefaultConfig } from 'core/component/config'\n\n// Types\nimport { TrimMode } from 'types/text'\nimport { GraphInputLink, GraphInputNode, GraphInputData } from 'types/graph'\nimport { BooleanAccessor, ColorAccessor, NumericAccessor, StringAccessor, GenericAccessor } from 'types/accessor'\n\n// Local Types\nimport {\n GraphLayoutType,\n GraphCircleLabel,\n GraphLinkStyle,\n GraphLinkArrowStyle,\n GraphPanelConfig,\n GraphForceLayoutSettings,\n GraphElkLayoutSettings,\n GraphNodeShape,\n GraphDagreLayoutSetting,\n GraphNode,\n GraphLink,\n GraphNodeSelectionHighlightMode,\n} from './types'\n\n\nexport interface GraphConfigInterface<N extends GraphInputNode, L extends GraphInputLink> extends ComponentConfigInterface {\n // Zoom and drag\n /** Zoom level constraints. Default: [0.35, 1.25] */\n zoomScaleExtent?: [number, number];\n /** Disable zooming. Default: `false` */\n disableZoom?: boolean;\n /** Custom Zoom event filter to better control which actions should trigger zooming.\n * Learn more: https://d3js.org/d3-zoom#zoom_filter.\n * Default: `undefined` */\n zoomEventFilter?: (event: PointerEvent) => boolean;\n /** Disable node dragging. Default: `false` */\n disableDrag?: boolean;\n /** Disable brush for multiple node selection. Default: `false` */\n disableBrush?: boolean;\n /** Interval to re-render the graph when zooming. Default: `100` */\n zoomThrottledUpdateNodeThreshold?: number;\n\n // Layout general settings\n /** Type of the graph layout. Default: `GraphLayoutType.Force` */\n layoutType?: GraphLayoutType | string;\n /** Fit the graph to container on data or config updates, or on container resize. Default: `true` */\n layoutAutofit?: boolean;\n /** Tolerance constant defining whether the graph should be fitted to container\n * (on data or config update, or container resize) after a zoom / pan interaction or not.\n * `0` — Stop fitting after any pan or zoom\n * `Number.POSITIVE_INFINITY` — Always fit\n * Default: `8.0` */\n layoutAutofitTolerance?: number;\n /** Place non-connected nodes at the bottom of the graph. Default: `false` */\n layoutNonConnectedAside?: boolean;\n\n // Settings for Parallel and Concentric layouts\n /** Node group accessor function.\n * Only for `GraphLayoutType.Parallel`, `GraphLayoutType.ParallelHorizontal` and `GraphLayoutType.Concentric` layouts.\n * Default: `node => node.group` */\n layoutNodeGroup?: StringAccessor<N>;\n /** Order of the layout groups.\n * Only for `GraphLayoutType.Parallel`, `GraphLayoutType.ParallelHorizontal` and `GraphLayoutType.Concentric` layouts.\n * Default: `[]` */\n layoutGroupOrder?: string[];\n\n // Setting for Parallel layouts only\n /** Sets the number of nodes in a sub-group after which they'll continue on the next column (or row if `layoutType` is\n * `GraphLayoutType.ParallelHorizontal`).\n * Only for `GraphLayoutType.Parallel` and `GraphLayoutType.ParallelHorizontal` layouts.\n * Default: `6` */\n layoutParallelNodesPerColumn?: number;\n /** Node sub-group accessor function.\n * Only for `GraphLayoutType.Parallel` and `GraphLayoutType.ParallelHorizontal` layouts.\n * Default: `node => node.subgroup` */\n layoutParallelNodeSubGroup?: StringAccessor<N>;\n /** Number of sub-groups per row (or column if `layoutType` is `GraphLayoutType.ParallelHorizontal`) in a group.\n * Only for `GraphLayoutType.Parallel` and `GraphLayoutType.ParallelHorizontal` layouts.\n * Default: `1` */\n layoutParallelSubGroupsPerRow?: number;\n /** Spacing between groups.\n * Only for `GraphLayoutType.Parallel` and `GraphLayoutType.ParallelHorizontal` layouts.\n * Default: `undefined` */\n layoutParallelGroupSpacing?: number;\n /** Set a group by name to have priority in sorting the graph links.\n * Only for `GraphLayoutType.Parallel` and `GraphLayoutType.ParallelHorizontal` layouts.\n * Default: `undefined` */\n layoutParallelSortConnectionsByGroup?: string;\n\n // Force layout\n /** Force Layout settings, see the `d3-force` package for more details */\n forceLayoutSettings?: GraphForceLayoutSettings<N, L>;\n\n // Dagre layout\n /** Darge Layout settings, see the `dagrejs` package\n * for more details: https://github.com/dagrejs/dagre/wiki#configuring-the-layout\n */\n dagreLayoutSettings?: GraphDagreLayoutSetting;\n\n // ELK layout\n /** ELK layout options, see the `elkjs` package for more details: https://github.com/kieler/elkjs.\n * If you want to specify custom layout option for each node group, you can provide an accessor function that\n * receives group name ('root' for the top-level configuration) as the first argument and returns an object containing\n * layout options. Default: `undefined`\n */\n layoutElkSettings?: GenericAccessor<GraphElkLayoutSettings, string> | undefined;\n /** Array of accessor functions to define nested node groups for the ELK Layered layout.\n * E.g.: `[n => n.group, n => n.subGroup]`.\n * Default: `undefined` */\n layoutElkNodeGroups?: StringAccessor<N>[];\n\n // Links\n /** Link width accessor function ot constant value. Default: `1` */\n linkWidth?: NumericAccessor<L>;\n /** Link style accessor function or constant value. Default: `GraphLinkStyle.Solid` */\n linkStyle?: GenericAccessor<GraphLinkStyle, L>;\n /** Link band width accessor function or constant value. Default: `0` */\n linkBandWidth?: NumericAccessor<L>;\n /** Link arrow accessor function or constant value. Default: `undefined` */\n linkArrow?: GenericAccessor<GraphLinkArrowStyle | string | boolean, L> | undefined;\n /** Link stroke color accessor function or constant value. Default: `undefined` */\n linkStroke?: ColorAccessor<L>;\n /** Link disabled state accessor function or constant value. Default: `false` */\n linkDisabled?: BooleanAccessor<L>;\n /** Link flow animation accessor function or constant value. Default: `false` */\n linkFlow?: BooleanAccessor<L>;\n /** Animation duration of the flow (traffic) circles. Default: `20000` */\n linkFlowAnimDuration?: number;\n /** Size of the moving particles that represent traffic flow. Default: `2` */\n linkFlowParticleSize?: number;\n /** Link label accessor function or constant value. Default: `undefined` */\n linkLabel?: GenericAccessor<GraphCircleLabel | GraphCircleLabel[], L> | undefined;\n /** Shift label along the link center a little bit to avoid overlap with the link arrow. Default: `true` */\n linkLabelShiftFromCenter?: BooleanAccessor<L>;\n /** Spacing between neighboring links. Default: `8` */\n linkNeighborSpacing?: number;\n /** Curvature of the link. Recommended value range: [0:1.5].\n * `0` - straight line,\n * `1` - nice curvature,\n * `1.5` - very curve.\n * Default: `0` */\n linkCurvature?: NumericAccessor<L>;\n /** Highlight links on hover. Default: `true` */\n linkHighlightOnHover?: boolean;\n /** Offset [x,y] in pixels from the source node's center point where the link should start. Default: `undefined` */\n linkSourcePointOffset?: GenericAccessor<[number, number], GraphLink<N, L>>;\n /** Offset [x,y] in pixels from the target node's center point where the link should end. Default: `undefined` */\n linkTargetPointOffset?: GenericAccessor<[number, number], GraphLink<N, L>>;\n /** Set selected link by its unique id. Default: `undefined` */\n selectedLinkId?: number | string;\n\n // Nodes\n /** Node size accessor function or constant value. Default: `30` */\n nodeSize?: NumericAccessor<N>;\n /** Node stroke width accessor function or constant value. Default: `3` */\n nodeStrokeWidth?: NumericAccessor<N>;\n /** Node shape accessor function or constant value. Default: `GraphNodeShape.Circle` */\n nodeShape?: GenericAccessor<GraphNodeShape | string, N>;\n /** Node gauge outline accessor function or constant value in the range [0,100]. Default: `0` */\n nodeGaugeValue?: NumericAccessor<N>;\n /** Node gauge outline fill color accessor function or constant value. Default: `undefined` */\n nodeGaugeFill?: ColorAccessor<N>;\n /** Animation duration of the node gauge outline. Default: `1500` */\n nodeGaugeAnimDuration?: number;\n /** Node central icon accessor function or constant value. Default: `node => node.icon` */\n nodeIcon?: StringAccessor<N>;\n /** Node central icon size accessor function or constant value. Default: `undefined` */\n nodeIconSize?: NumericAccessor<N>;\n /** Node label accessor function or constant value. Default: `node => node.label` */\n nodeLabel?: StringAccessor<N>;\n /** Defines whether to trim the node labels or not. Default: `true` */\n nodeLabelTrim?: BooleanAccessor<N>;\n /** Node label trimming mode. Default: `TrimMode.Middle` */\n nodeLabelTrimMode?: GenericAccessor<TrimMode | string, N>;\n /** Node label maximum allowed text length above which the label will be trimmed. Default: `15` */\n nodeLabelTrimLength?: NumericAccessor<N>;\n /** Node sub-label accessor function or constant value: Default: `''` */\n nodeSubLabel?: StringAccessor<N>;\n /** Defines whether to trim the node sub-labels or not. Default: `true` */\n nodeSubLabelTrim?: BooleanAccessor<N>;\n /** Node sub-label trimming mode. Default: `TrimMode.Middle` */\n nodeSubLabelTrimMode?: GenericAccessor<TrimMode | string, N>;\n /** Node sub-label maximum allowed text length above which the label will be trimmed. Default: `15` */\n nodeSubLabelTrimLength?: NumericAccessor<N>;\n /** Node circular side labels accessor function. The function should return an array of GraphCircleLabel objects. Default: `undefined` */\n nodeSideLabels?: GenericAccessor<GraphCircleLabel[], N>;\n /** Node bottom icon accessor function. Default: `undefined` */\n nodeBottomIcon?: StringAccessor<N>;\n /** Node disabled state accessor function or constant value. Default: `false` */\n nodeDisabled?: BooleanAccessor<N>;\n /** Node fill color accessor function or constant value. Default: `node => node.fill` */\n nodeFill?: ColorAccessor<N>;\n /** Node stroke color accessor function or constant value. Default: `node => node.stroke` */\n nodeStroke?: ColorAccessor<N>;\n /** Sorting function to determine node placement. Default: `undefined` */\n nodeSort?: ((a: N, b: N) => number);\n /** Specify the initial position for entering nodes as [x, y]. Default: `undefined` */\n nodeEnterPosition?: GenericAccessor<[number, number], N> | undefined;\n /** Specify the initial scale for entering nodes in the range [0,1]. Default: `0.75` */\n nodeEnterScale?: NumericAccessor<N> | undefined;\n /** Specify the destination position for exiting nodes as [x, y]. Default: `undefined` */\n nodeExitPosition?: GenericAccessor<[number, number], N> | undefined;\n /** Specify the destination scale for exiting nodes in the range [0,1]. Default: `0.75` */\n nodeExitScale?: NumericAccessor<N> | undefined;\n /** Custom \"enter\" function for node rendering. Default: `undefined` */\n nodeEnterCustomRenderFunction?:\n (datum: GraphNode<N, L>, nodeGroupElementSelection: Selection<SVGGElement, GraphNode<N, L>, null, unknown>, config: GraphConfigInterface<N, L>, duration: number, zoomLevel: number) => void;\n /** Custom \"update\" function for node rendering. Default: `undefined` */\n nodeUpdateCustomRenderFunction?:\n (datum: GraphNode<N, L>, nodeGroupElementSelection: Selection<SVGGElement, GraphNode<N, L>, null, unknown>, config: GraphConfigInterface<N, L>, duration: number, zoomLevel: number) => void;\n /** Custom partial \"update\" function for node rendering which will be triggered after the following events:\n * - Full node update (`nodeUpdateCustomRenderFunction`);\n * - Background click;\n * - Node and Link mouseover and mouseout;\n * - Node brushing,\n * Default: `undefined` */\n nodePartialUpdateCustomRenderFunction?:\n (datum: GraphNode<N, L>, nodeGroupElementSelection: Selection<SVGGElement, GraphNode<N, L>, null, unknown>, config: GraphConfigInterface<N, L>, duration: number, zoomLevel: number) => void;\n /** Custom \"exit\" function for node rendering. Default: `undefined` */\n nodeExitCustomRenderFunction?:\n (datum: GraphNode<N, L>, nodeGroupElementSelection: Selection<SVGGElement, GraphNode<N, L>, null, unknown>, config: GraphConfigInterface<N, L>, duration: number, zoomLevel: number) => void;\n /** Custom render function that will be called while zooming / panning the graph. Default: `undefined` */\n nodeOnZoomCustomRenderFunction?:\n (datum: GraphNode<N, L>, nodeGroupElementSelection: Selection<SVGGElement, GraphNode<N, L>, null, unknown>, config: GraphConfigInterface<N, L>, zoomLevel: number) => void;\n /** Define the mode for highlighting selected nodes in the graph. Default: `GraphNodeSelectionHighlightMode.GreyoutNonConnected` */\n nodeSelectionHighlightMode?: GraphNodeSelectionHighlightMode;\n /** Set selected node by unique id. Default: `undefined` */\n selectedNodeId?: number | string;\n /** Set selected nodes by unique id. Default: `undefined` */\n selectedNodeIds?: number[] | string[];\n\n /** Panels configuration. An array of `GraphPanelConfig` objects. Default: `[]` */\n panels?: GraphPanelConfig[] | undefined;\n\n // Events\n /** Graph node drag start callback function. Default: `undefined` */\n onNodeDragStart?: (n: GraphNode<N, L>, event: D3DragEvent<SVGGElement, GraphNode<N, L>, unknown>) => void | undefined;\n /** Graph node drag callback function. Default: `undefined` */\n onNodeDrag?: (n: GraphNode<N, L>, event: D3DragEvent<SVGGElement, GraphNode<N, L>, unknown>) => void | undefined;\n /** Graph node drag end callback function. Default: `undefined` */\n onNodeDragEnd?: (n: GraphNode<N, L>, event: D3DragEvent<SVGGElement, GraphNode<N, L>, unknown>) => void | undefined;\n /** Zoom event callback. Default: `undefined` */\n onZoom?: (zoomScale: number, zoomScaleExtent: [number, number], event: D3ZoomEvent<SVGGElement, unknown> | undefined, transform: ZoomTransform) => void;\n /** Zoom start event callback. Default: `undefined` */\n onZoomStart?: (zoomScale: number, zoomScaleExtent: [number, number], event: D3ZoomEvent<SVGGElement, unknown> | undefined, transform: ZoomTransform) => void;\n /** Zoom end event callback. Default: `undefined` */\n onZoomEnd?: (zoomScale: number, zoomScaleExtent: [number, number], event: D3ZoomEvent<SVGGElement, unknown> | undefined, transform: ZoomTransform) => void;\n /** Callback function to be called when the graph layout is calculated. Default: `undefined` */\n onLayoutCalculated?: (nodes: GraphNode<N, L>[], links: GraphLink<N, L>[]) => void;\n /** Graph node selection brush callback function. Default: `undefined` */\n onNodeSelectionBrush?: (selectedNodes: GraphNode<N, L>[], event: D3BrushEvent<SVGGElement> | undefined) => void;\n /** Graph multiple node drag callback function. Default: `undefined` */\n onNodeSelectionDrag?: (selectedNodes: GraphNode<N, L>[], event: D3DragEvent<SVGGElement, GraphNode<N, L>, unknown>) => void;\n /** Callback function to be called when the graph rendering is complete. Default: `undefined` */\n onRenderComplete?: (\n g: Selection<SVGGElement, unknown, null, undefined>,\n nodes: GraphNode<N, L>[],\n links: GraphLink<N, L>[],\n config: GraphConfigInterface<N, L>,\n duration: number,\n zoomLevel: number,\n width: number,\n height: number\n ) => void;\n\n /** Determines whether the component should update when new data is provided.\n * This function takes the previous and new data as parameters and returns a boolean\n * indicating whether the update should proceed. Useful for fine-grained control over\n * update behavior when your data has a complex nested structure.\n * By default the `isEqual` function from Unovis will be used to do the comparison.\n */\n shouldDataUpdate?: (\n prevData: GraphInputData<N, L>,\n nextData: GraphInputData<N, L>,\n datamodel: GraphDataModel<N, L, GraphNode<N, L>, GraphLink<N, L>>\n ) => boolean;\n}\n\nexport const GraphDefaultConfig: GraphConfigInterface<GraphInputNode, GraphInputLink> = {\n ...ComponentDefaultConfig,\n duration: 1000,\n zoomScaleExtent: [0.35, 1.25],\n disableZoom: false,\n zoomEventFilter: undefined,\n disableDrag: false,\n disableBrush: false,\n zoomThrottledUpdateNodeThreshold: 100,\n layoutType: GraphLayoutType.Force,\n layoutAutofit: true,\n layoutAutofitTolerance: 8.0,\n layoutNonConnectedAside: false,\n\n layoutGroupOrder: [],\n layoutParallelSubGroupsPerRow: 1,\n layoutParallelNodesPerColumn: 6,\n layoutParallelGroupSpacing: undefined,\n layoutParallelSortConnectionsByGroup: undefined,\n layoutNodeGroup: (n: GraphInputNode): string => (n as { group: string }).group,\n layoutParallelNodeSubGroup: (n: GraphInputNode): string => (n as { subgroup: string }).subgroup,\n\n forceLayoutSettings: {\n linkDistance: 60,\n linkStrength: 0.45,\n charge: -500,\n forceXStrength: 0.15,\n forceYStrength: 0.25,\n numIterations: undefined,\n fixNodePositionAfterSimulation: false,\n },\n\n dagreLayoutSettings: {\n rankdir: 'BT',\n ranker: 'longest-path',\n },\n\n layoutElkSettings: undefined,\n layoutElkNodeGroups: undefined,\n\n linkFlowAnimDuration: 20000,\n linkFlowParticleSize: 2,\n linkWidth: 1,\n linkStyle: GraphLinkStyle.Solid,\n linkBandWidth: 0,\n linkArrow: undefined,\n linkStroke: undefined,\n linkFlow: false,\n linkLabel: undefined,\n linkLabelShiftFromCenter: true,\n linkNeighborSpacing: 8,\n linkDisabled: false,\n linkCurvature: 0,\n linkHighlightOnHover: true,\n linkSourcePointOffset: undefined,\n linkTargetPointOffset: undefined,\n selectedLinkId: undefined,\n\n nodeSize: 30,\n nodeStrokeWidth: 3,\n nodeShape: GraphNodeShape.Circle,\n nodeGaugeValue: 0,\n nodeIcon: (n: GraphInputNode): string => (n as { icon: string }).icon,\n nodeIconSize: undefined,\n nodeLabel: (n: GraphInputNode): string => (n as { label: string }).label,\n nodeLabelTrim: true,\n nodeLabelTrimLength: 15,\n nodeLabelTrimMode: TrimMode.Middle,\n nodeSubLabel: '',\n nodeSubLabelTrim: true,\n nodeSubLabelTrimLength: 15,\n nodeSubLabelTrimMode: TrimMode.Middle,\n nodeSideLabels: undefined,\n nodeBottomIcon: undefined,\n nodeDisabled: false,\n nodeFill: (n: GraphInputNode): string => (n as { fill: string }).fill,\n nodeGaugeFill: undefined,\n nodeStroke: (n: GraphInputNode): string => (n as { stroke: string }).stroke,\n nodeEnterPosition: undefined,\n nodeEnterScale: 0.75,\n nodeExitPosition: undefined,\n nodeExitScale: 0.75,\n nodeSort: undefined,\n nodeSelectionHighlightMode: GraphNodeSelectionHighlightMode.GreyoutNonConnected,\n nodeGaugeAnimDuration: 1500,\n\n selectedNodeId: undefined,\n selectedNodeIds: undefined,\n\n panels: undefined,\n\n onNodeDragStart: undefined,\n onNodeDrag: undefined,\n onNodeDragEnd: undefined,\n onZoom: undefined,\n onZoomStart: undefined,\n onZoomEnd: undefined,\n onLayoutCalculated: undefined,\n onNodeSelectionBrush: undefined,\n onNodeSelectionDrag: undefined,\n onRenderComplete: undefined,\n\n shouldDataUpdate: (prevData: GraphInputData<GraphInputNode, GraphInputLink>, nextData: GraphInputData<GraphInputNode, GraphInputLink>): boolean => {\n return !isEqual(prevData, nextData)\n },\n}\n"],"names":[],"mappings":";;;;;AAQA;MAyRa,kBAAkB,GAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAC1B,sBAAsB,CACzB,EAAA,EAAA,QAAQ,EAAE,IAAI,EACd,eAAe,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,EAC7B,WAAW,EAAE,KAAK,EAClB,eAAe,EAAE,SAAS,EAC1B,WAAW,EAAE,KAAK,EAClB,YAAY,EAAE,KAAK,EACnB,gCAAgC,EAAE,GAAG,EACrC,UAAU,EAAE,eAAe,CAAC,KAAK,EACjC,aAAa,EAAE,IAAI,EACnB,sBAAsB,EAAE,GAAG,EAC3B,uBAAuB,EAAE,KAAK,EAE9B,gBAAgB,EAAE,EAAE,EACpB,6BAA6B,EAAE,CAAC,EAChC,4BAA4B,EAAE,CAAC,EAC/B,0BAA0B,EAAE,SAAS,EACrC,oCAAoC,EAAE,SAAS,EAC/C,eAAe,EAAE,CAAC,CAAiB,KAAc,CAAuB,CAAC,KAAK,EAC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AClC,YAAY,EAAE,EAAE,EAChB,gBAAgB,EAAE,IAAI,EACtB,sBAAsB,EAAE,EAAE,EAC1B,oBAAoB,EAAE,QAAQ,CAAC,MAAM,EACrC,cAAc,EAAE,SAAS,EACzB,cAAc,EAAE,SAAS,EACzB,YAAY,EAAE,KAAK,EACnB,QAAQ,EAAE,CAAC,CAAiB,KAAc,CAAsB,CAAC,IAAI,EACrE,aAAa,EAAE,SAAS,EACxB,UAAU,EAAE,CAAC,CAAiB,KAAc,CAAwB,CAAC,MAAM,EAC3E,iBAAiB,EAAE,SAAS,EAC5B,cAAc,EAAE,IAAI,EACpB,gBAAgB,EAAE,SAAS,EAC3B,aAAa,EAAE,IAAI,EACnB,QAAQ,EAAE,SAAS,EACnB,0BAA0B,EAAE,+BAA+B,CAAC,mBAAmB,EAC/E,qBAAqB,EAAE,IAAI,EAE3B,cAAc,EAAE,SAAS,EACzB,eAAe,EAAE,SAAS,EAE1B,MAAM,EAAE,SAAS,EAEjB,eAAe,EAAE,SAAS,EAC1B,UAAU,EAAE,SAAS,EACrB,aAAa,EAAE,SAAS,EACxB,MAAM,EAAE,SAAS,EACjB,WAAW,EAAE,SAAS,EACtB,SAAS,EAAE,SAAS,EACpB,kBAAkB,EAAE,SAAS,EAC7B,oBAAoB,EAAE,SAAS,EAC/B,mBAAmB,EAAE,SAAS,EAC9B,gBAAgB,EAAE,SAAS,EAE3B,gBAAgB,EAAE,CAAC,QAAwD,EAAE,QAAwD,KAAa;AAChJ,QAAA,OAAO,CAAC,OAAO,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAA;AACrC,KAAC;;;;"}
|
|
1
|
+
{"version":3,"file":"config.js","sources":["../../../src/components/graph/config.ts"],"sourcesContent":["import { D3BrushEvent } from 'd3-brush'\nimport { D3DragEvent } from 'd3-drag'\nimport { D3ZoomEvent, ZoomTransform } from 'd3-zoom'\nimport { Selection } from 'd3-selection'\n\n// Config\nimport { ComponentConfigInterface, ComponentDefaultConfig } from 'core/component/config'\n\n// Types\nimport { TrimMode } from 'types/text'\nimport { GraphInputLink, GraphInputNode } from 'types/graph'\nimport { BooleanAccessor, ColorAccessor, NumericAccessor, StringAccessor, GenericAccessor } from 'types/accessor'\n\n// Local Types\nimport {\n GraphLayoutType,\n GraphCircleLabel,\n GraphLinkStyle,\n GraphLinkArrowStyle,\n GraphPanelConfig,\n GraphForceLayoutSettings,\n GraphElkLayoutSettings,\n GraphNodeShape,\n GraphDagreLayoutSetting,\n GraphNode,\n GraphLink,\n GraphNodeSelectionHighlightMode,\n} from './types'\n\n\nexport interface GraphConfigInterface<N extends GraphInputNode, L extends GraphInputLink> extends ComponentConfigInterface {\n // Zoom and drag\n /** Zoom level constraints. Default: [0.35, 1.25] */\n zoomScaleExtent?: [number, number];\n /** Disable zooming. Default: `false` */\n disableZoom?: boolean;\n /** Custom Zoom event filter to better control which actions should trigger zooming.\n * Learn more: https://d3js.org/d3-zoom#zoom_filter.\n * Default: `undefined` */\n zoomEventFilter?: (event: PointerEvent) => boolean;\n /** Disable node dragging. Default: `false` */\n disableDrag?: boolean;\n /** Disable brush for multiple node selection. Default: `false` */\n disableBrush?: boolean;\n /** Interval to re-render the graph when zooming. Default: `100` */\n zoomThrottledUpdateNodeThreshold?: number;\n\n // Layout general settings\n /** Type of the graph layout. Default: `GraphLayoutType.Force` */\n layoutType?: GraphLayoutType | string;\n /** Fit the graph to container on data or config updates, or on container resize. Default: `true` */\n layoutAutofit?: boolean;\n /** Tolerance constant defining whether the graph should be fitted to container\n * (on data or config update, or container resize) after a zoom / pan interaction or not.\n * `0` — Stop fitting after any pan or zoom\n * `Number.POSITIVE_INFINITY` — Always fit\n * Default: `8.0` */\n layoutAutofitTolerance?: number;\n /** Place non-connected nodes at the bottom of the graph. Default: `false` */\n layoutNonConnectedAside?: boolean;\n\n // Settings for Parallel and Concentric layouts\n /** Node group accessor function.\n * Only for `GraphLayoutType.Parallel`, `GraphLayoutType.ParallelHorizontal` and `GraphLayoutType.Concentric` layouts.\n * Default: `node => node.group` */\n layoutNodeGroup?: StringAccessor<N>;\n /** Order of the layout groups.\n * Only for `GraphLayoutType.Parallel`, `GraphLayoutType.ParallelHorizontal` and `GraphLayoutType.Concentric` layouts.\n * Default: `[]` */\n layoutGroupOrder?: string[];\n\n // Setting for Parallel layouts only\n /** Sets the number of nodes in a sub-group after which they'll continue on the next column (or row if `layoutType` is\n * `GraphLayoutType.ParallelHorizontal`).\n * Only for `GraphLayoutType.Parallel` and `GraphLayoutType.ParallelHorizontal` layouts.\n * Default: `6` */\n layoutParallelNodesPerColumn?: number;\n /** Node sub-group accessor function.\n * Only for `GraphLayoutType.Parallel` and `GraphLayoutType.ParallelHorizontal` layouts.\n * Default: `node => node.subgroup` */\n layoutParallelNodeSubGroup?: StringAccessor<N>;\n /** Number of sub-groups per row (or column if `layoutType` is `GraphLayoutType.ParallelHorizontal`) in a group.\n * Only for `GraphLayoutType.Parallel` and `GraphLayoutType.ParallelHorizontal` layouts.\n * Default: `1` */\n layoutParallelSubGroupsPerRow?: number;\n /** Spacing between groups.\n * Only for `GraphLayoutType.Parallel` and `GraphLayoutType.ParallelHorizontal` layouts.\n * Default: `undefined` */\n layoutParallelGroupSpacing?: number;\n /** Set a group by name to have priority in sorting the graph links.\n * Only for `GraphLayoutType.Parallel` and `GraphLayoutType.ParallelHorizontal` layouts.\n * Default: `undefined` */\n layoutParallelSortConnectionsByGroup?: string;\n\n // Force layout\n /** Force Layout settings, see the `d3-force` package for more details */\n forceLayoutSettings?: GraphForceLayoutSettings<N, L>;\n\n // Dagre layout\n /** Darge Layout settings, see the `dagrejs` package\n * for more details: https://github.com/dagrejs/dagre/wiki#configuring-the-layout\n */\n dagreLayoutSettings?: GraphDagreLayoutSetting;\n\n // ELK layout\n /** ELK layout options, see the `elkjs` package for more details: https://github.com/kieler/elkjs.\n * If you want to specify custom layout option for each node group, you can provide an accessor function that\n * receives group name ('root' for the top-level configuration) as the first argument and returns an object containing\n * layout options. Default: `undefined`\n */\n layoutElkSettings?: GenericAccessor<GraphElkLayoutSettings, string> | undefined;\n /** Array of accessor functions to define nested node groups for the ELK Layered layout.\n * E.g.: `[n => n.group, n => n.subGroup]`.\n * Default: `undefined` */\n layoutElkNodeGroups?: StringAccessor<N>[];\n\n // Links\n /** Link width accessor function ot constant value. Default: `1` */\n linkWidth?: NumericAccessor<L>;\n /** Link style accessor function or constant value. Default: `GraphLinkStyle.Solid` */\n linkStyle?: GenericAccessor<GraphLinkStyle, L>;\n /** Link band width accessor function or constant value. Default: `0` */\n linkBandWidth?: NumericAccessor<L>;\n /** Link arrow accessor function or constant value. Default: `undefined` */\n linkArrow?: GenericAccessor<GraphLinkArrowStyle | string | boolean, L> | undefined;\n /** Link stroke color accessor function or constant value. Default: `undefined` */\n linkStroke?: ColorAccessor<L>;\n /** Link disabled state accessor function or constant value. Default: `false` */\n linkDisabled?: BooleanAccessor<L>;\n /** Link flow animation accessor function or constant value. Default: `false` */\n linkFlow?: BooleanAccessor<L>;\n /** Animation duration of the flow (traffic) circles. Default: `20000` */\n linkFlowAnimDuration?: number;\n /** Size of the moving particles that represent traffic flow. Default: `2` */\n linkFlowParticleSize?: number;\n /** Link label accessor function or constant value. Default: `undefined` */\n linkLabel?: GenericAccessor<GraphCircleLabel | GraphCircleLabel[], L> | undefined;\n /** Shift label along the link center a little bit to avoid overlap with the link arrow. Default: `true` */\n linkLabelShiftFromCenter?: BooleanAccessor<L>;\n /** Spacing between neighboring links. Default: `8` */\n linkNeighborSpacing?: number;\n /** Curvature of the link. Recommended value range: [0:1.5].\n * `0` - straight line,\n * `1` - nice curvature,\n * `1.5` - very curve.\n * Default: `0` */\n linkCurvature?: NumericAccessor<L>;\n /** Set selected link by its unique id. Default: `undefined` */\n selectedLinkId?: number | string;\n\n // Nodes\n /** Node size accessor function or constant value. Default: `30` */\n nodeSize?: NumericAccessor<N>;\n /** Node stroke width accessor function or constant value. Default: `3` */\n nodeStrokeWidth?: NumericAccessor<N>;\n /** Node shape accessor function or constant value. Default: `GraphNodeShape.Circle` */\n nodeShape?: GenericAccessor<GraphNodeShape | string, N>;\n /** Node gauge outline accessor function or constant value in the range [0,100]. Default: `0` */\n nodeGaugeValue?: NumericAccessor<N>;\n /** Node gauge outline fill color accessor function or constant value. Default: `undefined` */\n nodeGaugeFill?: ColorAccessor<N>;\n /** Animation duration of the node gauge outline. Default: `1500` */\n nodeGaugeAnimDuration?: number;\n /** Node central icon accessor function or constant value. Default: `node => node.icon` */\n nodeIcon?: StringAccessor<N>;\n /** Node central icon size accessor function or constant value. Default: `undefined` */\n nodeIconSize?: NumericAccessor<N>;\n /** Node label accessor function or constant value. Default: `node => node.label` */\n nodeLabel?: StringAccessor<N>;\n /** Defines whether to trim the node labels or not. Default: `true` */\n nodeLabelTrim?: BooleanAccessor<N>;\n /** Node label trimming mode. Default: `TrimMode.Middle` */\n nodeLabelTrimMode?: GenericAccessor<TrimMode | string, N>;\n /** Node label maximum allowed text length above which the label will be trimmed. Default: `15` */\n nodeLabelTrimLength?: NumericAccessor<N>;\n /** Node sub-label accessor function or constant value: Default: `''` */\n nodeSubLabel?: StringAccessor<N>;\n /** Defines whether to trim the node sub-labels or not. Default: `true` */\n nodeSubLabelTrim?: BooleanAccessor<N>;\n /** Node sub-label trimming mode. Default: `TrimMode.Middle` */\n nodeSubLabelTrimMode?: GenericAccessor<TrimMode | string, N>;\n /** Node sub-label maximum allowed text length above which the label will be trimmed. Default: `15` */\n nodeSubLabelTrimLength?: NumericAccessor<N>;\n /** Node circular side labels accessor function. The function should return an array of GraphCircleLabel objects. Default: `undefined` */\n nodeSideLabels?: GenericAccessor<GraphCircleLabel[], N>;\n /** Node bottom icon accessor function. Default: `undefined` */\n nodeBottomIcon?: StringAccessor<N>;\n /** Node disabled state accessor function or constant value. Default: `false` */\n nodeDisabled?: BooleanAccessor<N>;\n /** Node fill color accessor function or constant value. Default: `node => node.fill` */\n nodeFill?: ColorAccessor<N>;\n /** Node stroke color accessor function or constant value. Default: `node => node.stroke` */\n nodeStroke?: ColorAccessor<N>;\n /** Sorting function to determine node placement. Default: `undefined` */\n nodeSort?: ((a: N, b: N) => number);\n /** Specify the initial position for entering nodes as [x, y]. Default: `undefined` */\n nodeEnterPosition?: GenericAccessor<[number, number], N> | undefined;\n /** Specify the initial scale for entering nodes in the range [0,1]. Default: `0.75` */\n nodeEnterScale?: NumericAccessor<N> | undefined;\n /** Specify the destination position for exiting nodes as [x, y]. Default: `undefined` */\n nodeExitPosition?: GenericAccessor<[number, number], N> | undefined;\n /** Specify the destination scale for exiting nodes in the range [0,1]. Default: `0.75` */\n nodeExitScale?: NumericAccessor<N> | undefined;\n /** Custom \"enter\" function for node rendering. Default: `undefined` */\n nodeEnterCustomRenderFunction?:\n (datum: GraphNode<N, L>, nodeGroupElementSelection: Selection<SVGGElement, GraphNode<N, L>, null, unknown>, config: GraphConfigInterface<N, L>, duration: number, zoomLevel: number) => void;\n /** Custom \"update\" function for node rendering. Default: `undefined` */\n nodeUpdateCustomRenderFunction?:\n (datum: GraphNode<N, L>, nodeGroupElementSelection: Selection<SVGGElement, GraphNode<N, L>, null, unknown>, config: GraphConfigInterface<N, L>, duration: number, zoomLevel: number) => void;\n /** Custom partial \"update\" function for node rendering which will be triggered after the following events:\n * - Full node update (`nodeUpdateCustomRenderFunction`);\n * - Background click;\n * - Node and Link mouseover and mouseout;\n * - Node brushing,\n * Default: `undefined` */\n nodePartialUpdateCustomRenderFunction?:\n (datum: GraphNode<N, L>, nodeGroupElementSelection: Selection<SVGGElement, GraphNode<N, L>, null, unknown>, config: GraphConfigInterface<N, L>, duration: number, zoomLevel: number) => void;\n /** Custom \"exit\" function for node rendering. Default: `undefined` */\n nodeExitCustomRenderFunction?:\n (datum: GraphNode<N, L>, nodeGroupElementSelection: Selection<SVGGElement, GraphNode<N, L>, null, unknown>, config: GraphConfigInterface<N, L>, duration: number, zoomLevel: number) => void;\n /** Custom render function that will be called while zooming / panning the graph. Default: `undefined` */\n nodeOnZoomCustomRenderFunction?:\n (datum: GraphNode<N, L>, nodeGroupElementSelection: Selection<SVGGElement, GraphNode<N, L>, null, unknown>, config: GraphConfigInterface<N, L>, zoomLevel: number) => void;\n /** Define the mode for highlighting selected nodes in the graph. Default: `GraphNodeSelectionHighlightMode.GreyoutNonConnected` */\n nodeSelectionHighlightMode?: GraphNodeSelectionHighlightMode;\n /** Set selected node by unique id. Default: `undefined` */\n selectedNodeId?: number | string;\n /** Set selected nodes by unique id. Default: `undefined` */\n selectedNodeIds?: number[] | string[];\n\n /** Panels configuration. An array of `GraphPanelConfig` objects. Default: `[]` */\n panels?: GraphPanelConfig[] | undefined;\n\n // Events\n /** Graph node drag start callback function. Default: `undefined` */\n onNodeDragStart?: (n: GraphNode<N, L>, event: D3DragEvent<SVGGElement, GraphNode<N, L>, unknown>) => void | undefined;\n /** Graph node drag callback function. Default: `undefined` */\n onNodeDrag?: (n: GraphNode<N, L>, event: D3DragEvent<SVGGElement, GraphNode<N, L>, unknown>) => void | undefined;\n /** Graph node drag end callback function. Default: `undefined` */\n onNodeDragEnd?: (n: GraphNode<N, L>, event: D3DragEvent<SVGGElement, GraphNode<N, L>, unknown>) => void | undefined;\n /** Zoom event callback. Default: `undefined` */\n onZoom?: (zoomScale: number, zoomScaleExtent: [number, number], event: D3ZoomEvent<SVGGElement, unknown> | undefined, transform: ZoomTransform) => void;\n /** Zoom start event callback. Default: `undefined` */\n onZoomStart?: (zoomScale: number, zoomScaleExtent: [number, number], event: D3ZoomEvent<SVGGElement, unknown> | undefined, transform: ZoomTransform) => void;\n /** Zoom end event callback. Default: `undefined` */\n onZoomEnd?: (zoomScale: number, zoomScaleExtent: [number, number], event: D3ZoomEvent<SVGGElement, unknown> | undefined, transform: ZoomTransform) => void;\n /** Callback function to be called when the graph layout is calculated. Default: `undefined` */\n onLayoutCalculated?: (nodes: GraphNode<N, L>[], links: GraphLink<N, L>[]) => void;\n /** Graph node selection brush callback function. Default: `undefined` */\n onNodeSelectionBrush?: (selectedNodes: GraphNode<N, L>[], event: D3BrushEvent<SVGGElement> | undefined) => void;\n /** Graph multiple node drag callback function. Default: `undefined` */\n onNodeSelectionDrag?: (selectedNodes: GraphNode<N, L>[], event: D3DragEvent<SVGGElement, GraphNode<N, L>, unknown>) => void;\n /** Callback function to be called when the graph rendering is complete. Default: `undefined` */\n onRenderComplete?: (\n g: Selection<SVGGElement, unknown, null, undefined>,\n nodes: GraphNode<N, L>[],\n links: GraphLink<N, L>[],\n config: GraphConfigInterface<N, L>,\n duration: number,\n zoomLevel: number,\n width: number,\n height: number\n ) => void;\n}\n\nexport const GraphDefaultConfig: GraphConfigInterface<GraphInputNode, GraphInputLink> = {\n ...ComponentDefaultConfig,\n duration: 1000,\n zoomScaleExtent: [0.35, 1.25],\n disableZoom: false,\n zoomEventFilter: undefined,\n disableDrag: false,\n disableBrush: false,\n zoomThrottledUpdateNodeThreshold: 100,\n layoutType: GraphLayoutType.Force,\n layoutAutofit: true,\n layoutAutofitTolerance: 8.0,\n layoutNonConnectedAside: false,\n\n layoutGroupOrder: [],\n layoutParallelSubGroupsPerRow: 1,\n layoutParallelNodesPerColumn: 6,\n layoutParallelGroupSpacing: undefined,\n layoutParallelSortConnectionsByGroup: undefined,\n layoutNodeGroup: (n: GraphInputNode): string => (n as { group: string }).group,\n layoutParallelNodeSubGroup: (n: GraphInputNode): string => (n as { subgroup: string }).subgroup,\n\n forceLayoutSettings: {\n linkDistance: 60,\n linkStrength: 0.45,\n charge: -500,\n forceXStrength: 0.15,\n forceYStrength: 0.25,\n numIterations: undefined,\n fixNodePositionAfterSimulation: false,\n },\n\n dagreLayoutSettings: {\n rankdir: 'BT',\n ranker: 'longest-path',\n },\n\n layoutElkSettings: undefined,\n layoutElkNodeGroups: undefined,\n\n linkFlowAnimDuration: 20000,\n linkFlowParticleSize: 2,\n linkWidth: 1,\n linkStyle: GraphLinkStyle.Solid,\n linkBandWidth: 0,\n linkArrow: undefined,\n linkStroke: undefined,\n linkFlow: false,\n linkLabel: undefined,\n linkLabelShiftFromCenter: true,\n linkNeighborSpacing: 8,\n linkDisabled: false,\n linkCurvature: 0,\n selectedLinkId: undefined,\n nodeGaugeAnimDuration: 1500,\n\n nodeSize: 30,\n nodeStrokeWidth: 3,\n nodeShape: GraphNodeShape.Circle,\n nodeGaugeValue: 0,\n nodeIcon: (n: GraphInputNode): string => (n as { icon: string }).icon,\n nodeIconSize: undefined,\n nodeLabel: (n: GraphInputNode): string => (n as { label: string }).label,\n nodeLabelTrim: true,\n nodeLabelTrimLength: 15,\n nodeLabelTrimMode: TrimMode.Middle,\n nodeSubLabel: '',\n nodeSubLabelTrim: true,\n nodeSubLabelTrimLength: 15,\n nodeSubLabelTrimMode: TrimMode.Middle,\n nodeSideLabels: undefined,\n nodeBottomIcon: undefined,\n nodeDisabled: false,\n nodeFill: (n: GraphInputNode): string => (n as { fill: string }).fill,\n nodeGaugeFill: undefined,\n nodeStroke: (n: GraphInputNode): string => (n as { stroke: string }).stroke,\n nodeEnterPosition: undefined,\n nodeEnterScale: 0.75,\n nodeExitPosition: undefined,\n nodeExitScale: 0.75,\n nodeSort: undefined,\n nodeSelectionHighlightMode: GraphNodeSelectionHighlightMode.GreyoutNonConnected,\n\n selectedNodeId: undefined,\n selectedNodeIds: undefined,\n\n panels: undefined,\n\n onNodeDragStart: undefined,\n onNodeDrag: undefined,\n onNodeDragEnd: undefined,\n onZoom: undefined,\n onZoomStart: undefined,\n onZoomEnd: undefined,\n onLayoutCalculated: undefined,\n onNodeSelectionBrush: undefined,\n onNodeSelectionDrag: undefined,\n onRenderComplete: undefined,\n}\n"],"names":[],"mappings":";;;;AAKA;MAoQa,kBAAkB,GAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,EAAA,EAC1B,sBAAsB,CACzB,EAAA,EAAA,QAAQ,EAAE,IAAI,EACd,eAAe,EAAE,CAAC,IAAI,EAAE,IAAI,CAAC,EAC7B,WAAW,EAAE,KAAK,EAClB,eAAe,EAAE,SAAS,EAC1B,WAAW,EAAE,KAAK,EAClB,YA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
3
3
|
import { GraphDataModel } from "../../data-models/graph";
|
|
4
|
-
import { GraphInputLink, GraphInputNode
|
|
4
|
+
import { GraphInputLink, GraphInputNode } from "../../types/graph";
|
|
5
5
|
import { Spacing } from "../../types/spacing";
|
|
6
6
|
import { GraphNode, GraphLink } from './types';
|
|
7
7
|
import { GraphConfigInterface } from './config';
|
|
8
8
|
import * as nodeSelectors from './modules/node/style';
|
|
9
|
-
export declare class Graph<N extends GraphInputNode, L extends GraphInputLink> extends ComponentCore<
|
|
9
|
+
export declare class Graph<N extends GraphInputNode, L extends GraphInputLink> extends ComponentCore<{
|
|
10
|
+
nodes: N[];
|
|
11
|
+
links?: L[];
|
|
12
|
+
}, GraphConfigInterface<N, L>> {
|
|
10
13
|
static selectors: {
|
|
11
14
|
root: string;
|
|
12
15
|
graphGroup: string;
|
|
@@ -19,7 +22,6 @@ export declare class Graph<N extends GraphInputNode, L extends GraphInputLink> e
|
|
|
19
22
|
dimmedNode: string;
|
|
20
23
|
link: string;
|
|
21
24
|
linkLine: string;
|
|
22
|
-
linkLabel: string;
|
|
23
25
|
dimmedLink: string;
|
|
24
26
|
panel: string;
|
|
25
27
|
panelRect: string;
|
|
@@ -61,7 +63,6 @@ export declare class Graph<N extends GraphInputNode, L extends GraphInputLink> e
|
|
|
61
63
|
private _isDragging;
|
|
62
64
|
private _brushBehavior;
|
|
63
65
|
private _groupDragInit;
|
|
64
|
-
private _linkPathLengthMap;
|
|
65
66
|
events: {
|
|
66
67
|
[x: string]: {
|
|
67
68
|
click: () => void;
|
|
@@ -81,7 +82,10 @@ export declare class Graph<N extends GraphInputNode, L extends GraphInputLink> e
|
|
|
81
82
|
get selectedNodes(): GraphNode<N, L>[];
|
|
82
83
|
get selectedLink(): GraphLink<N, L>;
|
|
83
84
|
constructor(config?: GraphConfigInterface<N, L>);
|
|
84
|
-
setData(data:
|
|
85
|
+
setData(data: {
|
|
86
|
+
nodes: N[];
|
|
87
|
+
links?: L[];
|
|
88
|
+
}): void;
|
|
85
89
|
setConfig(config: GraphConfigInterface<N, L>): void;
|
|
86
90
|
get bleed(): Spacing;
|
|
87
91
|
_render(customDuration?: number): void;
|
|
@@ -139,11 +143,4 @@ export declare class Graph<N extends GraphInputNode, L extends GraphInputLink> e
|
|
|
139
143
|
x: number;
|
|
140
144
|
y: number;
|
|
141
145
|
} | undefined;
|
|
142
|
-
/** Set the node state by id */
|
|
143
|
-
setNodeStateById(nodeId: string, state: GraphNode<N, L>['_state']): void;
|
|
144
|
-
/** Call a partial render to update the positions of the nodes and their links.
|
|
145
|
-
* This can be useful when you've changed the node positions manually outside
|
|
146
|
-
* of the component and want to update the graph.
|
|
147
|
-
*/
|
|
148
|
-
updateNodePositions(duration?: number): void;
|
|
149
146
|
}
|
|
@@ -7,18 +7,18 @@ import { drag } from 'd3-drag';
|
|
|
7
7
|
import { interval } from 'd3-timer';
|
|
8
8
|
import { ComponentCore } from '../../core/component/index.js';
|
|
9
9
|
import { GraphDataModel } from '../../data-models/graph.js';
|
|
10
|
-
import { isNumber, isFunction, clamp, getBoolean, shallowDiff, isPlainObject
|
|
10
|
+
import { isEqual, isNumber, isFunction, clamp, getBoolean, shallowDiff, isPlainObject } from '../../utils/data.js';
|
|
11
11
|
import { smartTransition } from '../../utils/d3.js';
|
|
12
12
|
import { GraphLayoutType, GraphNodeSelectionHighlightMode, GraphLinkArrowStyle } from './types.js';
|
|
13
13
|
import { GraphDefaultConfig } from './config.js';
|
|
14
14
|
import { background, graphGroup, brush, root } from './style.js';
|
|
15
15
|
import * as style from './modules/node/style.js';
|
|
16
16
|
import { nodes, gNode, gNodeExit, brushed, brushable, node, nodeGauge, sideLabelGroup, label, greyedOutNode } from './modules/node/style.js';
|
|
17
|
-
import { links, gLink, gLinkExit, link,
|
|
17
|
+
import { links, gLink, gLinkExit, link, greyedOutLink } from './modules/link/style.js';
|
|
18
18
|
import { panels, gPanel, panel, panelSelection, label as label$1, labelText, sideIconGroup, sideIconShape, sideIconSymbol } from './modules/panel/style.js';
|
|
19
|
-
import { createNodes, updateNodes, removeNodes, updateNodesPartial, zoomNodesThrottled, zoomNodes
|
|
19
|
+
import { createNodes, updateNodes, removeNodes, updateNodesPartial, zoomNodesThrottled, zoomNodes } from './modules/node/index.js';
|
|
20
20
|
import { getMaxNodeSize, getX, getY, getNodeSize } from './modules/node/helper.js';
|
|
21
|
-
import { createLinks, updateLinks, removeLinks, updateLinksPartial, animateLinkFlow, zoomLinksThrottled, zoomLinks
|
|
21
|
+
import { createLinks, updateLinks, removeLinks, updateLinksPartial, animateLinkFlow, zoomLinksThrottled, zoomLinks } from './modules/link/index.js';
|
|
22
22
|
import { getArrowPath, getDoubleArrowPath } from './modules/link/helper.js';
|
|
23
23
|
import { removePanels, createPanels, updatePanels } from './modules/panel/index.js';
|
|
24
24
|
import { updatePanelNumNodes, updatePanelBBoxSize, initPanels, setPanelForNodes } from './modules/panel/helper.js';
|
|
@@ -35,8 +35,6 @@ class Graph extends ComponentCore {
|
|
|
35
35
|
this._shouldSetPanels = false;
|
|
36
36
|
this._isAutoFitDisabled = false;
|
|
37
37
|
this._isDragging = false;
|
|
38
|
-
// A map for storing link total path lengths to optimize rendering performance
|
|
39
|
-
this._linkPathLengthMap = new Map();
|
|
40
38
|
this.events = {
|
|
41
39
|
[Graph.selectors.background]: {
|
|
42
40
|
click: this._onBackgroundClick.bind(this),
|
|
@@ -84,7 +82,7 @@ class Graph extends ComponentCore {
|
|
|
84
82
|
}
|
|
85
83
|
setData(data) {
|
|
86
84
|
const { config } = this;
|
|
87
|
-
if (
|
|
85
|
+
if (isEqual(this.datamodel.data, data))
|
|
88
86
|
return;
|
|
89
87
|
this.datamodel.nodeSort = config.nodeSort;
|
|
90
88
|
this.datamodel.data = data;
|
|
@@ -180,7 +178,7 @@ class Graph extends ComponentCore {
|
|
|
180
178
|
this._resetSelectionGreyoutState();
|
|
181
179
|
if (this.config.selectedNodeId || this.config.selectedNodeIds) {
|
|
182
180
|
const selectedIds = (_a = this.config.selectedNodeIds) !== null && _a !== void 0 ? _a : [this.config.selectedNodeId];
|
|
183
|
-
const selectedNodes = selectedIds.map(id => datamodel.
|
|
181
|
+
const selectedNodes = selectedIds.map(id => datamodel.getNodeFromId(id));
|
|
184
182
|
this._setNodeSelectionState(selectedNodes);
|
|
185
183
|
}
|
|
186
184
|
if (this.config.selectedLinkId) {
|
|
@@ -200,6 +198,14 @@ class Graph extends ComponentCore {
|
|
|
200
198
|
this.g.on('.zoom', null);
|
|
201
199
|
else
|
|
202
200
|
this.g.call(this._zoomBehavior).on('dblclick.zoom', null);
|
|
201
|
+
// While the graph is animating we disable pointer events on the graph group
|
|
202
|
+
if (animDuration) {
|
|
203
|
+
this._graphGroup.attr('pointer-events', 'none');
|
|
204
|
+
}
|
|
205
|
+
smartTransition(this._graphGroup, animDuration)
|
|
206
|
+
.on('end interrupt', () => {
|
|
207
|
+
this._graphGroup.attr('pointer-events', null);
|
|
208
|
+
});
|
|
203
209
|
// We need to set up events and attributes again because the rendering might have been delayed by the layout
|
|
204
210
|
// calculation and they were not set up properly (see the render function of `ComponentCore`)
|
|
205
211
|
this._setUpComponentEventsThrottled();
|
|
@@ -241,13 +247,13 @@ class Graph extends ComponentCore {
|
|
|
241
247
|
_drawLinks(duration) {
|
|
242
248
|
const { config, datamodel: { links } } = this;
|
|
243
249
|
const linkGroups = this._linksGroup
|
|
244
|
-
.selectAll(`.${gLink}
|
|
250
|
+
.selectAll(`.${gLink}`)
|
|
245
251
|
.data(links, (d) => String(d._id));
|
|
246
252
|
const linkGroupsEnter = linkGroups.enter().append('g')
|
|
247
253
|
.attr('class', gLink)
|
|
248
254
|
.call(createLinks, config, duration);
|
|
249
255
|
const linkGroupsMerged = linkGroups.merge(linkGroupsEnter);
|
|
250
|
-
linkGroupsMerged.call(updateLinks, config, duration, this._scale, this._getLinkArrowDefId
|
|
256
|
+
linkGroupsMerged.call(updateLinks, config, duration, this._scale, this._getLinkArrowDefId);
|
|
251
257
|
const linkGroupsExit = linkGroups.exit();
|
|
252
258
|
linkGroupsExit
|
|
253
259
|
.attr('class', gLinkExit)
|
|
@@ -483,8 +489,7 @@ class Graph extends ComponentCore {
|
|
|
483
489
|
_onLinkMouseOver(d) {
|
|
484
490
|
if (this._isDragging)
|
|
485
491
|
return;
|
|
486
|
-
|
|
487
|
-
d._state.hovered = true;
|
|
492
|
+
d._state.hovered = true;
|
|
488
493
|
this._updateNodesLinksPartial();
|
|
489
494
|
}
|
|
490
495
|
_onLinkMouseOut(d) {
|
|
@@ -502,7 +507,7 @@ class Graph extends ComponentCore {
|
|
|
502
507
|
const linkElements = this._linksGroup.selectAll(`.${gLink}`);
|
|
503
508
|
const linksToAnimate = linkElements.filter(d => !d._state.greyout);
|
|
504
509
|
linksToAnimate.each(d => { d._state.flowAnimTime = t; });
|
|
505
|
-
animateLinkFlow(linksToAnimate, this.config, this._scale
|
|
510
|
+
animateLinkFlow(linksToAnimate, this.config, this._scale);
|
|
506
511
|
}
|
|
507
512
|
_onZoom(t, event) {
|
|
508
513
|
const { config, datamodel: { nodes } } = this;
|
|
@@ -646,10 +651,10 @@ class Graph extends ComponentCore {
|
|
|
646
651
|
const target = l.target;
|
|
647
652
|
return source._id === d._id || target._id === d._id;
|
|
648
653
|
});
|
|
649
|
-
linksToUpdate.call(updateLinks, config, 0, scale, this._getLinkArrowDefId
|
|
654
|
+
linksToUpdate.call(updateLinks, config, 0, scale, this._getLinkArrowDefId);
|
|
650
655
|
const linksToAnimate = linksToUpdate.filter(d => d._state.greyout);
|
|
651
656
|
if (linksToAnimate.size())
|
|
652
|
-
animateLinkFlow(linksToAnimate, config, this._scale
|
|
657
|
+
animateLinkFlow(linksToAnimate, config, this._scale);
|
|
653
658
|
(_a = config.onNodeDrag) === null || _a === void 0 ? void 0 : _a.call(config, d, event);
|
|
654
659
|
}
|
|
655
660
|
_onDragEnded(d, event, nodeSelection) {
|
|
@@ -680,7 +685,7 @@ class Graph extends ComponentCore {
|
|
|
680
685
|
selectedNodes.each(n => this._updateNodePosition(n, n.x + dx, n.y + dy));
|
|
681
686
|
const connectedLinks = smartTransition(this._linksGroup.selectAll(`.${gLink}`)
|
|
682
687
|
.filter(l => { var _a, _b, _c, _d; return ((_b = (_a = l.source) === null || _a === void 0 ? void 0 : _a._state) === null || _b === void 0 ? void 0 : _b.isDragged) || ((_d = (_c = l.target) === null || _c === void 0 ? void 0 : _c._state) === null || _d === void 0 ? void 0 : _d.isDragged); }));
|
|
683
|
-
connectedLinks.call(updateLinks, this.config, 0, this._scale, this._getLinkArrowDefId
|
|
688
|
+
connectedLinks.call(updateLinks, this.config, 0, this._scale, this._getLinkArrowDefId);
|
|
684
689
|
}
|
|
685
690
|
else {
|
|
686
691
|
this._isDragging = false;
|
|
@@ -807,22 +812,6 @@ class Graph extends ComponentCore {
|
|
|
807
812
|
};
|
|
808
813
|
}
|
|
809
814
|
}
|
|
810
|
-
/** Set the node state by id */
|
|
811
|
-
setNodeStateById(nodeId, state) {
|
|
812
|
-
this.datamodel.setNodeStateById(nodeId, state);
|
|
813
|
-
}
|
|
814
|
-
/** Call a partial render to update the positions of the nodes and their links.
|
|
815
|
-
* This can be useful when you've changed the node positions manually outside
|
|
816
|
-
* of the component and want to update the graph.
|
|
817
|
-
*/
|
|
818
|
-
updateNodePositions(duration) {
|
|
819
|
-
const { config } = this;
|
|
820
|
-
const animDuration = isNumber(duration) ? duration : config.duration;
|
|
821
|
-
const linkElements = this._linksGroup.selectAll(`.${gLink}:not(.${gLinkExit}`);
|
|
822
|
-
updateLinkLines(linkElements, config, animDuration, this._scale, this._getLinkArrowDefId, this._linkPathLengthMap);
|
|
823
|
-
const nodeElements = this._nodesGroup.selectAll(`.${gNode}:not(.${gNodeExit})`);
|
|
824
|
-
updateNodePositions(nodeElements, animDuration);
|
|
825
|
-
}
|
|
826
815
|
}
|
|
827
816
|
Graph.selectors = {
|
|
828
817
|
root: root,
|
|
@@ -836,7 +825,6 @@ Graph.selectors = {
|
|
|
836
825
|
dimmedNode: greyedOutNode,
|
|
837
826
|
link: gLink,
|
|
838
827
|
linkLine: link,
|
|
839
|
-
linkLabel: linkLabelGroup,
|
|
840
828
|
dimmedLink: greyedOutLink,
|
|
841
829
|
panel: gPanel,
|
|
842
830
|
panelRect: panel,
|