@unovis/ts 1.5.0-version.9 → 1.5.1-exf.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/axis/config.d.ts +10 -1
- package/components/axis/config.js +1 -1
- package/components/axis/config.js.map +1 -1
- package/components/axis/index.d.ts +19 -19
- package/components/axis/index.js +63 -8
- package/components/axis/index.js.map +1 -1
- package/components/axis/style.d.ts +1 -0
- package/components/axis/style.js +7 -2
- package/components/axis/style.js.map +1 -1
- package/components/crosshair/index.js +6 -0
- package/components/crosshair/index.js.map +1 -1
- package/components/donut/config.d.ts +4 -0
- package/components/donut/config.js +1 -1
- package/components/donut/config.js.map +1 -1
- package/components/donut/index.d.ts +2 -0
- package/components/donut/index.js +41 -6
- package/components/donut/index.js.map +1 -1
- package/components/graph/config.d.ts +39 -6
- package/components/graph/config.js +7 -4
- package/components/graph/config.js.map +1 -1
- package/components/graph/index.d.ts +22 -15
- package/components/graph/index.js +233 -98
- package/components/graph/index.js.map +1 -1
- package/components/graph/modules/link/index.d.ts +2 -1
- package/components/graph/modules/link/index.js +87 -51
- package/components/graph/modules/link/index.js.map +1 -1
- package/components/graph/modules/link/style.js +0 -2
- package/components/graph/modules/link/style.js.map +1 -1
- package/components/graph/modules/node/index.d.ts +2 -1
- package/components/graph/modules/node/index.js +47 -23
- package/components/graph/modules/node/index.js.map +1 -1
- package/components/graph/modules/node/style.d.ts +2 -0
- package/components/graph/modules/node/style.js +34 -4
- package/components/graph/modules/node/style.js.map +1 -1
- package/components/graph/modules/panel/index.js +1 -0
- package/components/graph/modules/panel/index.js.map +1 -1
- package/components/graph/style.d.ts +1 -0
- package/components/graph/style.js +22 -1
- package/components/graph/style.js.map +1 -1
- package/components/graph/types.d.ts +8 -0
- package/components/graph/types.js +8 -2
- package/components/graph/types.js.map +1 -1
- package/components/leaflet-map/modules/map.js +2 -1
- package/components/leaflet-map/modules/map.js.map +1 -1
- package/components/scatter/index.d.ts +1 -0
- package/components/scatter/index.js +19 -12
- package/components/scatter/index.js.map +1 -1
- package/components/scatter/modules/point.js +1 -3
- package/components/scatter/modules/point.js.map +1 -1
- package/components/scatter/types.d.ts +2 -0
- package/components/tooltip/index.d.ts +7 -0
- package/components/tooltip/index.js +17 -5
- package/components/tooltip/index.js.map +1 -1
- package/components/topojson-map/config.js +2 -2
- package/components/topojson-map/config.js.map +1 -1
- package/components/topojson-map/index.js +22 -5
- package/components/topojson-map/index.js.map +1 -1
- package/containers/single-container/index.js +2 -2
- package/containers/single-container/index.js.map +1 -1
- package/containers/xy-container/index.js +4 -2
- package/containers/xy-container/index.js.map +1 -1
- package/core/container/config.d.ts +2 -4
- package/core/container/config.js.map +1 -1
- package/core/container/index.d.ts +2 -1
- package/core/container/index.js +26 -19
- package/core/container/index.js.map +1 -1
- package/data-models/graph.d.ts +2 -0
- package/data-models/graph.js +6 -0
- package/data-models/graph.js.map +1 -1
- package/index.d.ts +1 -4
- package/index.js +13 -5
- package/index.js.map +1 -1
- package/maps/world-simple.json.js +2430 -42
- package/package.json +2 -2
- package/types/graph.d.ts +6 -0
- package/types.js +1 -1
- package/utils/data.d.ts +2 -1
- package/utils/data.js +18 -8
- package/utils/data.js.map +1 -1
- package/utils/index.d.ts +12 -0
- package/utils/index.js +13 -0
- package/utils/index.js.map +1 -0
- package/utils/scale.js +4 -0
- package/utils/scale.js.map +1 -0
- package/utils/type.js +2 -0
- package/utils/type.js.map +1 -0
|
@@ -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}\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;
|
|
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 /** Central label and sub-label horizontal offset in pixels. Default: `undefined` */\n centralLabelOffsetX?: number;\n\n /** Central label and sub-label vertical offset in pixels. Default: `undefined` */\n centralLabelOffsetY?: 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 centralLabelOffsetX: undefined,\n centralLabelOffsetY: undefined,\n}\n"],"names":[],"mappings":";;AAAA;MAoDa,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,CAAC,EAAA,GAAA,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,EAC/B,mBAAmB,EAAE,SAAS,EAC9B,mBAAmB,EAAE,SAAS,EAAA;;;;"}
|
|
@@ -5,6 +5,8 @@ import { Spacing } from "../../types/spacing";
|
|
|
5
5
|
import { DonutArcAnimState } from './types';
|
|
6
6
|
import { DonutConfigInterface } from './config';
|
|
7
7
|
import * as s from './style';
|
|
8
|
+
export declare const DONUT_HALF_ANGLE_RANGES: [number, number][];
|
|
9
|
+
export declare const DONUT_HALF_ANGLE_RANGE_TOP: [number, number], DONUT_HALF_ANGLE_RANGE_RIGHT: [number, number], DONUT_HALF_ANGLE_RANGE_BOTTOM: [number, number], DONUT_HALF_ANGLE_RANGE_LEFT: [number, number];
|
|
8
10
|
export declare class Donut<Datum> extends ComponentCore<Datum[], DonutConfigInterface<Datum>> {
|
|
9
11
|
static selectors: typeof s;
|
|
10
12
|
protected _defaultConfig: DonutConfigInterface<Datum>;
|
|
@@ -9,6 +9,12 @@ import { createArc, updateArc, removeArc } from './modules/arc.js';
|
|
|
9
9
|
import * as style from './style.js';
|
|
10
10
|
import { centralLabel, centralSubLabel, segment, segmentExit, background } from './style.js';
|
|
11
11
|
|
|
12
|
+
// Constants that support half donuts
|
|
13
|
+
const DONUT_HALF_ANGLE_RANGES = Array.from({ length: 4 }, (_, i) => {
|
|
14
|
+
const offset = -Math.PI / 2 + i * Math.PI / 2;
|
|
15
|
+
return [offset, offset + Math.PI];
|
|
16
|
+
});
|
|
17
|
+
const [DONUT_HALF_ANGLE_RANGE_TOP, DONUT_HALF_ANGLE_RANGE_RIGHT, DONUT_HALF_ANGLE_RANGE_BOTTOM, DONUT_HALF_ANGLE_RANGE_LEFT,] = DONUT_HALF_ANGLE_RANGES;
|
|
12
18
|
class Donut extends ComponentCore {
|
|
13
19
|
constructor(config) {
|
|
14
20
|
super();
|
|
@@ -40,8 +46,22 @@ class Donut extends ComponentCore {
|
|
|
40
46
|
}))
|
|
41
47
|
.filter(d => config.showEmptySegments || getNumber(d.datum, config.value, d.index));
|
|
42
48
|
const duration = isNumber(customDuration) ? customDuration : config.duration;
|
|
43
|
-
|
|
49
|
+
// Handle half-donut cases, which adjust the scaling and positioning.
|
|
50
|
+
// One of these is true if we are dealing with a half-donut.
|
|
51
|
+
const [isHalfDonutTop, isHalfDonutRight, isHalfDonutBottom, isHalfDonutLeft,] = DONUT_HALF_ANGLE_RANGES.map(angleRange => config.angleRange && (config.angleRange[0] === angleRange[0] &&
|
|
52
|
+
config.angleRange[1] === angleRange[1]));
|
|
53
|
+
const isVerticalHalfDonut = isHalfDonutTop || isHalfDonutBottom;
|
|
54
|
+
const isHorizontalHalfDonut = isHalfDonutRight || isHalfDonutLeft;
|
|
55
|
+
// Compute the bounding box of the donut,
|
|
56
|
+
// considering it may be a half-donut
|
|
57
|
+
const width = this._width * (isHorizontalHalfDonut ? 2 : 1);
|
|
58
|
+
const height = this._height * (isVerticalHalfDonut ? 2 : 1);
|
|
59
|
+
const outerRadius = config.radius || Math.min(width - bleed.left - bleed.right, height - bleed.top - bleed.bottom) / 2;
|
|
44
60
|
const innerRadius = config.arcWidth === 0 ? 0 : clamp(outerRadius - config.arcWidth, 0, outerRadius - 1);
|
|
61
|
+
const translateY = this._height / 2 + (isHalfDonutTop ? outerRadius / 2 : isHalfDonutBottom ? -outerRadius / 2 : 0);
|
|
62
|
+
const translateX = this._width / 2 + (isHalfDonutLeft ? outerRadius / 2 : isHalfDonutRight ? -outerRadius / 2 : 0);
|
|
63
|
+
const translate = `translate(${translateX},${translateY})`;
|
|
64
|
+
this.arcGroup.attr('transform', translate);
|
|
45
65
|
this.arcGen
|
|
46
66
|
.startAngle(d => d.startAngle)
|
|
47
67
|
.endAngle(d => d.endAngle)
|
|
@@ -55,7 +75,6 @@ class Donut extends ComponentCore {
|
|
|
55
75
|
.padAngle(config.padAngle)
|
|
56
76
|
.value(d => getNumber(d.datum, config.value, d.index) || 0)
|
|
57
77
|
.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})`);
|
|
59
78
|
const arcData = pieGen(data).map(d => {
|
|
60
79
|
const arc = Object.assign(Object.assign({}, d), { data: d.data.datum, index: d.data.index, innerRadius,
|
|
61
80
|
outerRadius });
|
|
@@ -79,20 +98,36 @@ class Donut extends ComponentCore {
|
|
|
79
98
|
.attr('class', segmentExit)
|
|
80
99
|
.call(removeArc, duration);
|
|
81
100
|
// Label
|
|
101
|
+
const labelTextAnchor = isHalfDonutRight ? 'start' : isHalfDonutLeft ? 'end' : 'middle';
|
|
82
102
|
this.centralLabel
|
|
83
|
-
.attr('transform', `translate(${this._width / 2},${this._height / 2})`)
|
|
84
103
|
.attr('dy', config.centralSubLabel ? '-0.55em' : null)
|
|
104
|
+
.style('text-anchor', labelTextAnchor)
|
|
85
105
|
.text((_e = config.centralLabel) !== null && _e !== void 0 ? _e : null);
|
|
86
106
|
this.centralSubLabel
|
|
87
|
-
.attr('transform', `translate(${this._width / 2},${this._height / 2})`)
|
|
88
107
|
.attr('dy', config.centralLabel ? '0.55em' : null)
|
|
108
|
+
.style('text-anchor', labelTextAnchor)
|
|
89
109
|
.text((_f = config.centralSubLabel) !== null && _f !== void 0 ? _f : null);
|
|
90
110
|
if (config.centralSubLabelWrap)
|
|
91
111
|
wrapSVGText(this.centralSubLabel, innerRadius * 1.9);
|
|
112
|
+
// Label placement
|
|
113
|
+
const labelTranslateX = (config.centralLabelOffsetX || 0) + translateX;
|
|
114
|
+
let labelTranslateY = (config.centralLabelOffsetY || 0) + translateY;
|
|
115
|
+
// Special case label placement for half donut
|
|
116
|
+
if (isVerticalHalfDonut && config.centralLabelOffsetX === undefined && config.centralLabelOffsetY === undefined) {
|
|
117
|
+
const halfDonutLabelOffsetY = isHalfDonutTop
|
|
118
|
+
? -this.centralSubLabel.node().getBoundingClientRect().height
|
|
119
|
+
: isHalfDonutBottom
|
|
120
|
+
? this.centralLabel.node().getBoundingClientRect().height
|
|
121
|
+
: 0;
|
|
122
|
+
labelTranslateY = halfDonutLabelOffsetY + translateY;
|
|
123
|
+
}
|
|
124
|
+
const labelTranslate = `translate(${labelTranslateX},${labelTranslateY})`;
|
|
125
|
+
this.centralLabel.attr('transform', labelTranslate);
|
|
126
|
+
this.centralSubLabel.attr('transform', labelTranslate);
|
|
92
127
|
// Background
|
|
93
128
|
this.arcBackground.attr('class', background)
|
|
94
129
|
.attr('visibility', config.showBackground ? null : 'hidden')
|
|
95
|
-
.attr('transform',
|
|
130
|
+
.attr('transform', translate);
|
|
96
131
|
smartTransition(this.arcBackground, duration)
|
|
97
132
|
.attr('d', this.arcGen({
|
|
98
133
|
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,
|
|
@@ -104,5 +139,5 @@ class Donut extends ComponentCore {
|
|
|
104
139
|
}
|
|
105
140
|
Donut.selectors = style;
|
|
106
141
|
|
|
107
|
-
export { Donut };
|
|
142
|
+
export { DONUT_HALF_ANGLE_RANGES, DONUT_HALF_ANGLE_RANGE_BOTTOM, DONUT_HALF_ANGLE_RANGE_LEFT, DONUT_HALF_ANGLE_RANGE_RIGHT, DONUT_HALF_ANGLE_RANGE_TOP, Donut };
|
|
108
143
|
//# sourceMappingURL=index.js.map
|
|
@@ -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// 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 inn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AAQ,CAAC;AAC3D,aAAA,IAAI,CAAC,WAAW,EAAE,CAAa,UAAA,EAAA,IAAI,CAAC,MAAM,GAAG,CAAC,CAAA,CAAA,EAAI,IAAI,CAAC,OAAO,GAAG,CAAC,CAAA,CAAA,CAAG,CAAC,CAAA;AAEzE,QAAA,eAAe,CAAC,IAAI,CAAC,aAAa,EAAE,QAAQ,CAAC;AAC1C,aAAA,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC;AACrB,YAAA,UAAU,EAAE,CAAA,EAAA,GAAA,CAAA,EAAA,GAAA,MAAA,MAAM,CAAC,oBAAoB,MAAG,IAAA,IAAA,EAAA,KAAA,KAAA,CAAA,GAAA,KAAA,CAAA,GAAA,EAAA,CAAA,CAAC,CAAC,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;;;;"}
|
|
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\n// Constants that support half donuts\nexport const DONUT_HALF_ANGLE_RANGES = Array.from({ length: 4 }, (_, i): [number, number] => {\n const offset = -Math.PI / 2 + i * Math.PI / 2\n return [offset, offset + Math.PI]\n})\n\nexport const [\n DONUT_HALF_ANGLE_RANGE_TOP,\n DONUT_HALF_ANGLE_RANGE_RIGHT,\n DONUT_HALF_ANGLE_RANGE_BOTTOM,\n DONUT_HALF_ANGLE_RANGE_LEFT,\n] = DONUT_HALF_ANGLE_RANGES\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"],"names":["s.centralLabel","s.centralSubLabel","s.segment","s.segmentExit","s.background","s"],"mappings":";;;;;;;;;;;AA2BA;AACa,MAAA,uBAAuB,GAAG,KAAK,CAAC,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,CAAC,KAAsB;AAC1F,IAAA,MAAM,MAAM,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,EAAE,GAAG,CAAC,CAAA;IAC7C,OAAO,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,EAAE,CAAC,CAAA;AACnC,CAAC,EAAC;AAEK,MAAM,CACX,0BAA0B,EAC1B,4BAA4B,EAC5B,6BAA6B,EAC7B,2BAA2B,EAC5B,GAAG,wBAAuB;AAErB,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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import { Selection } from 'd3-selection';
|
|
4
5
|
import { ComponentConfigInterface } from "../../core/component/config";
|
|
5
6
|
import { TrimMode } from "../../types/text";
|
|
6
|
-
import { GraphInputLink, GraphInputNode } from "../../types/graph";
|
|
7
|
+
import { GraphInputLink, GraphInputNode, GraphInputData } from "../../types/graph";
|
|
7
8
|
import { BooleanAccessor, ColorAccessor, NumericAccessor, StringAccessor, GenericAccessor } from "../../types/accessor";
|
|
8
|
-
import { GraphLayoutType, GraphCircleLabel, GraphLinkStyle, GraphLinkArrowStyle, GraphPanelConfig, GraphForceLayoutSettings, GraphElkLayoutSettings, GraphNodeShape, GraphDagreLayoutSetting, GraphNode, GraphLink } from './types';
|
|
9
|
+
import { GraphLayoutType, GraphCircleLabel, GraphLinkStyle, GraphLinkArrowStyle, GraphPanelConfig, GraphForceLayoutSettings, GraphElkLayoutSettings, GraphNodeShape, GraphDagreLayoutSetting, GraphNode, GraphLink, GraphNodeSelectionHighlightMode } from './types';
|
|
9
10
|
export interface GraphConfigInterface<N extends GraphInputNode, L extends GraphInputLink> extends ComponentConfigInterface {
|
|
10
11
|
/** Zoom level constraints. Default: [0.35, 1.25] */
|
|
11
12
|
zoomScaleExtent?: [number, number];
|
|
@@ -17,6 +18,8 @@ export interface GraphConfigInterface<N extends GraphInputNode, L extends GraphI
|
|
|
17
18
|
zoomEventFilter?: (event: PointerEvent) => boolean;
|
|
18
19
|
/** Disable node dragging. Default: `false` */
|
|
19
20
|
disableDrag?: boolean;
|
|
21
|
+
/** Disable brush for multiple node selection. Default: `false` */
|
|
22
|
+
disableBrush?: boolean;
|
|
20
23
|
/** Interval to re-render the graph when zooming. Default: `100` */
|
|
21
24
|
zoomThrottledUpdateNodeThreshold?: number;
|
|
22
25
|
/** Type of the graph layout. Default: `GraphLayoutType.Force` */
|
|
@@ -95,7 +98,7 @@ export interface GraphConfigInterface<N extends GraphInputNode, L extends GraphI
|
|
|
95
98
|
/** Size of the moving particles that represent traffic flow. Default: `2` */
|
|
96
99
|
linkFlowParticleSize?: number;
|
|
97
100
|
/** Link label accessor function or constant value. Default: `undefined` */
|
|
98
|
-
linkLabel?: GenericAccessor<GraphCircleLabel, L> | undefined;
|
|
101
|
+
linkLabel?: GenericAccessor<GraphCircleLabel | GraphCircleLabel[], L> | undefined;
|
|
99
102
|
/** Shift label along the link center a little bit to avoid overlap with the link arrow. Default: `true` */
|
|
100
103
|
linkLabelShiftFromCenter?: BooleanAccessor<L>;
|
|
101
104
|
/** Spacing between neighboring links. Default: `8` */
|
|
@@ -106,6 +109,8 @@ export interface GraphConfigInterface<N extends GraphInputNode, L extends GraphI
|
|
|
106
109
|
* `1.5` - very curve.
|
|
107
110
|
* Default: `0` */
|
|
108
111
|
linkCurvature?: NumericAccessor<L>;
|
|
112
|
+
/** Highlight links on hover. Default: `true` */
|
|
113
|
+
linkHighlightOnHover?: boolean;
|
|
109
114
|
/** Set selected link by its unique id. Default: `undefined` */
|
|
110
115
|
selectedLinkId?: number | string;
|
|
111
116
|
/** Node size accessor function or constant value. Default: `30` */
|
|
@@ -164,10 +169,23 @@ export interface GraphConfigInterface<N extends GraphInputNode, L extends GraphI
|
|
|
164
169
|
nodeEnterCustomRenderFunction?: (datum: GraphNode<N, L>, nodeGroupElementSelection: Selection<SVGGElement, GraphNode<N, L>, null, unknown>, config: GraphConfigInterface<N, L>, duration: number, zoomLevel: number) => void;
|
|
165
170
|
/** Custom "update" function for node rendering. Default: `undefined` */
|
|
166
171
|
nodeUpdateCustomRenderFunction?: (datum: GraphNode<N, L>, nodeGroupElementSelection: Selection<SVGGElement, GraphNode<N, L>, null, unknown>, config: GraphConfigInterface<N, L>, duration: number, zoomLevel: number) => void;
|
|
172
|
+
/** Custom partial "update" function for node rendering which will be triggered after the following events:
|
|
173
|
+
* - Full node update (`nodeUpdateCustomRenderFunction`);
|
|
174
|
+
* - Background click;
|
|
175
|
+
* - Node and Link mouseover and mouseout;
|
|
176
|
+
* - Node brushing,
|
|
177
|
+
* Default: `undefined` */
|
|
178
|
+
nodePartialUpdateCustomRenderFunction?: (datum: GraphNode<N, L>, nodeGroupElementSelection: Selection<SVGGElement, GraphNode<N, L>, null, unknown>, config: GraphConfigInterface<N, L>, duration: number, zoomLevel: number) => void;
|
|
167
179
|
/** Custom "exit" function for node rendering. Default: `undefined` */
|
|
168
180
|
nodeExitCustomRenderFunction?: (datum: GraphNode<N, L>, nodeGroupElementSelection: Selection<SVGGElement, GraphNode<N, L>, null, unknown>, config: GraphConfigInterface<N, L>, duration: number, zoomLevel: number) => void;
|
|
181
|
+
/** Custom render function that will be called while zooming / panning the graph. Default: `undefined` */
|
|
182
|
+
nodeOnZoomCustomRenderFunction?: (datum: GraphNode<N, L>, nodeGroupElementSelection: Selection<SVGGElement, GraphNode<N, L>, null, unknown>, config: GraphConfigInterface<N, L>, zoomLevel: number) => void;
|
|
183
|
+
/** Define the mode for highlighting selected nodes in the graph. Default: `GraphNodeSelectionHighlightMode.GreyoutNonConnected` */
|
|
184
|
+
nodeSelectionHighlightMode?: GraphNodeSelectionHighlightMode;
|
|
169
185
|
/** Set selected node by unique id. Default: `undefined` */
|
|
170
186
|
selectedNodeId?: number | string;
|
|
187
|
+
/** Set selected nodes by unique id. Default: `undefined` */
|
|
188
|
+
selectedNodeIds?: number[] | string[];
|
|
171
189
|
/** Panels configuration. An array of `GraphPanelConfig` objects. Default: `[]` */
|
|
172
190
|
panels?: GraphPanelConfig[] | undefined;
|
|
173
191
|
/** Graph node drag start callback function. Default: `undefined` */
|
|
@@ -177,10 +195,25 @@ export interface GraphConfigInterface<N extends GraphInputNode, L extends GraphI
|
|
|
177
195
|
/** Graph node drag end callback function. Default: `undefined` */
|
|
178
196
|
onNodeDragEnd?: (n: GraphNode<N, L>, event: D3DragEvent<SVGGElement, GraphNode<N, L>, unknown>) => void | undefined;
|
|
179
197
|
/** Zoom event callback. Default: `undefined` */
|
|
180
|
-
onZoom?: (zoomScale: number, zoomScaleExtent: [number, number], event: D3ZoomEvent<SVGGElement, unknown> | undefined) => void;
|
|
198
|
+
onZoom?: (zoomScale: number, zoomScaleExtent: [number, number], event: D3ZoomEvent<SVGGElement, unknown> | undefined, transform: ZoomTransform) => void;
|
|
199
|
+
/** Zoom start event callback. Default: `undefined` */
|
|
200
|
+
onZoomStart?: (zoomScale: number, zoomScaleExtent: [number, number], event: D3ZoomEvent<SVGGElement, unknown> | undefined, transform: ZoomTransform) => void;
|
|
201
|
+
/** Zoom end event callback. Default: `undefined` */
|
|
202
|
+
onZoomEnd?: (zoomScale: number, zoomScaleExtent: [number, number], event: D3ZoomEvent<SVGGElement, unknown> | undefined, transform: ZoomTransform) => void;
|
|
181
203
|
/** Callback function to be called when the graph layout is calculated. Default: `undefined` */
|
|
182
|
-
onLayoutCalculated?: (
|
|
204
|
+
onLayoutCalculated?: (nodes: GraphNode<N, L>[], links: GraphLink<N, L>[]) => void;
|
|
205
|
+
/** Graph node selection brush callback function. Default: `undefined` */
|
|
206
|
+
onNodeSelectionBrush?: (selectedNodes: GraphNode<N, L>[], event: D3BrushEvent<SVGGElement> | undefined) => void;
|
|
207
|
+
/** Graph multiple node drag callback function. Default: `undefined` */
|
|
208
|
+
onNodeSelectionDrag?: (selectedNodes: GraphNode<N, L>[], event: D3DragEvent<SVGGElement, GraphNode<N, L>, unknown>) => void;
|
|
183
209
|
/** Callback function to be called when the graph rendering is complete. Default: `undefined` */
|
|
184
210
|
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;
|
|
211
|
+
/** Determines whether the component should update when new data is provided.
|
|
212
|
+
* This function takes the previous and new data as parameters and returns a boolean
|
|
213
|
+
* indicating whether the update should proceed. Useful for fine-grained control over
|
|
214
|
+
* update behavior when your data has a complex nested structure.
|
|
215
|
+
* By default the `isEqual` function from Unovis will be used to do the comparison.
|
|
216
|
+
*/
|
|
217
|
+
shouldDataUpdate?: (prevData: GraphInputData<N, L>, nextData: GraphInputData<N, L>) => boolean;
|
|
185
218
|
}
|
|
186
219
|
export declare const GraphDefaultConfig: GraphConfigInterface<GraphInputNode, GraphInputLink>;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { isEqual } from '../../utils/data.js';
|
|
1
2
|
import { ComponentDefaultConfig } from '../../core/component/config.js';
|
|
2
3
|
import { TrimMode } from '../../types/text.js';
|
|
3
|
-
import { GraphLayoutType, GraphLinkStyle, GraphNodeShape } from './types.js';
|
|
4
|
+
import { GraphLayoutType, GraphLinkStyle, GraphNodeShape, GraphNodeSelectionHighlightMode } from './types.js';
|
|
4
5
|
|
|
5
|
-
//
|
|
6
|
-
const GraphDefaultConfig = Object.assign(Object.assign({}, ComponentDefaultConfig), { duration: 1000, zoomScaleExtent: [0.35, 1.25], disableZoom: false, zoomEventFilter: undefined, disableDrag: 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: {
|
|
6
|
+
// Utils
|
|
7
|
+
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: {
|
|
7
8
|
linkDistance: 60,
|
|
8
9
|
linkStrength: 0.45,
|
|
9
10
|
charge: -500,
|
|
@@ -14,7 +15,9 @@ const GraphDefaultConfig = Object.assign(Object.assign({}, ComponentDefaultConfi
|
|
|
14
15
|
}, dagreLayoutSettings: {
|
|
15
16
|
rankdir: 'BT',
|
|
16
17
|
ranker: 'longest-path',
|
|
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, selectedNodeId: undefined, panels: undefined, onNodeDragStart: undefined, onNodeDrag: undefined, onNodeDragEnd: undefined, onZoom: undefined, onLayoutCalculated: undefined, onRenderComplete: undefined
|
|
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, linkHighlightOnHover: true, 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, shouldDataUpdate: (prevData, nextData) => {
|
|
19
|
+
return !isEqual(prevData, nextData);
|
|
20
|
+
} });
|
|
18
21
|
|
|
19
22
|
export { GraphDefaultConfig };
|
|
20
23
|
//# sourceMappingURL=config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sources":["../../../src/components/graph/config.ts"],"sourcesContent":["import { D3DragEvent } from 'd3-drag'\nimport { D3ZoomEvent } 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} from './types'\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 /** 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, 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 \"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 /** Set selected node by unique id. Default: `undefined` */\n selectedNodeId?: 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) => void;\n /** Callback function to be called when the graph layout is calculated. Default: `undefined` */\n onLayoutCalculated?: (n: GraphNode<N, L>[], links: GraphLink<N, L>[]) => 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 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\n selectedNodeId: undefined,\n panels: undefined,\n\n onNodeDragStart: undefined,\n onNodeDrag: undefined,\n onNodeDragEnd: undefined,\n onZoom: undefined,\n onLayoutCalculated: undefined,\n onRenderComplete: undefined,\n}\n"],"names":[],"mappings":";;;;AAIA;MAyOa,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,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,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K,EACxE,aAAa,EAAE,IAAI,EACnB,mBAAmB,EAAE,EAAE,EACvB,iBAAiB,EAAE,QAAQ,CAAC,MAAM,EAClC,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,EAEnB,cAAc,EAAE,SAAS,EACzB,MAAM,EAAE,SAAS,EAEjB,eAAe,EAAE,SAAS,EAC1B,UAAU,EAAE,SAAS,EACrB,aAAa,EAAE,SAAS,EACxB,MAAM,EAAE,SAAS,EACjB,kBAAkB,EAAE,SAAS,EAC7B,gBAAgB,EAAE,SAAS,EAAA;;;;"}
|
|
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// 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 /** 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?: (prevData: GraphInputData<N, L>, nextData: GraphInputData<N, L>) => 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 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 shouldDataUpdate: (prevData: GraphInputData<GraphInputNode, GraphInputLink>, nextData: GraphInputData<GraphInputNode, GraphInputLink>): boolean => {\n return !isEqual(prevData, nextData)\n },\n}\n"],"names":[],"mappings":";;;;;AAKA;MAiRa,kBAAkB,GAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CAAA,MAAA,CA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E,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,15 +1,12 @@
|
|
|
1
1
|
import { Selection } from 'd3-selection';
|
|
2
2
|
import { ComponentCore } from "../../core/component";
|
|
3
3
|
import { GraphDataModel } from "../../data-models/graph";
|
|
4
|
-
import { GraphInputLink, GraphInputNode } from "../../types/graph";
|
|
4
|
+
import { GraphInputLink, GraphInputNode, GraphInputData } 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<{
|
|
10
|
-
nodes: N[];
|
|
11
|
-
links?: L[];
|
|
12
|
-
}, GraphConfigInterface<N, L>> {
|
|
9
|
+
export declare class Graph<N extends GraphInputNode, L extends GraphInputLink> extends ComponentCore<GraphInputData<N, L>, GraphConfigInterface<N, L>> {
|
|
13
10
|
static selectors: {
|
|
14
11
|
root: string;
|
|
15
12
|
graphGroup: string;
|
|
@@ -22,6 +19,7 @@ export declare class Graph<N extends GraphInputNode, L extends GraphInputLink> e
|
|
|
22
19
|
dimmedNode: string;
|
|
23
20
|
link: string;
|
|
24
21
|
linkLine: string;
|
|
22
|
+
linkLabel: string;
|
|
25
23
|
dimmedLink: string;
|
|
26
24
|
panel: string;
|
|
27
25
|
panelRect: string;
|
|
@@ -37,12 +35,13 @@ export declare class Graph<N extends GraphInputNode, L extends GraphInputLink> e
|
|
|
37
35
|
protected _defaultConfig: GraphConfigInterface<N, L>;
|
|
38
36
|
config: GraphConfigInterface<N, L>;
|
|
39
37
|
datamodel: GraphDataModel<N, L, GraphNode<N, L>, GraphLink<N, L>>;
|
|
40
|
-
private
|
|
38
|
+
private _selectedNodes;
|
|
41
39
|
private _selectedLink;
|
|
42
40
|
private _graphGroup;
|
|
43
41
|
private _panelsGroup;
|
|
44
42
|
private _linksGroup;
|
|
45
43
|
private _nodesGroup;
|
|
44
|
+
private _brush;
|
|
46
45
|
private _timer;
|
|
47
46
|
private _isFirstRender;
|
|
48
47
|
private _prevWidth;
|
|
@@ -60,6 +59,8 @@ export declare class Graph<N extends GraphInputNode, L extends GraphInputLink> e
|
|
|
60
59
|
private _scale;
|
|
61
60
|
private _initialTransform;
|
|
62
61
|
private _isDragging;
|
|
62
|
+
private _brushBehavior;
|
|
63
|
+
private _groupDragInit;
|
|
63
64
|
events: {
|
|
64
65
|
[x: string]: {
|
|
65
66
|
click: () => void;
|
|
@@ -76,12 +77,10 @@ export declare class Graph<N extends GraphInputNode, L extends GraphInputLink> e
|
|
|
76
77
|
};
|
|
77
78
|
};
|
|
78
79
|
get selectedNode(): GraphNode<N, L>;
|
|
80
|
+
get selectedNodes(): GraphNode<N, L>[];
|
|
79
81
|
get selectedLink(): GraphLink<N, L>;
|
|
80
82
|
constructor(config?: GraphConfigInterface<N, L>);
|
|
81
|
-
setData(data:
|
|
82
|
-
nodes: N[];
|
|
83
|
-
links?: L[];
|
|
84
|
-
}): void;
|
|
83
|
+
setData(data: GraphInputData<N, L>): void;
|
|
85
84
|
setConfig(config: GraphConfigInterface<N, L>): void;
|
|
86
85
|
get bleed(): Spacing;
|
|
87
86
|
_render(customDuration?: number): void;
|
|
@@ -93,10 +92,10 @@ export declare class Graph<N extends GraphInputNode, L extends GraphInputLink> e
|
|
|
93
92
|
private _initPanelsData;
|
|
94
93
|
private _fit;
|
|
95
94
|
private _getTransform;
|
|
96
|
-
private
|
|
97
|
-
private
|
|
98
|
-
private
|
|
99
|
-
private
|
|
95
|
+
private _setNodeSelectionState;
|
|
96
|
+
private _setLinkSelectionState;
|
|
97
|
+
private _resetSelectionGreyoutState;
|
|
98
|
+
private _updateNodesLinksPartial;
|
|
100
99
|
private _onBackgroundClick;
|
|
101
100
|
private _onNodeClick;
|
|
102
101
|
private _onNodeMouseOut;
|
|
@@ -106,9 +105,17 @@ export declare class Graph<N extends GraphInputNode, L extends GraphInputLink> e
|
|
|
106
105
|
private _onLinkMouseOut;
|
|
107
106
|
private _onLinkFlowTimerFrame;
|
|
108
107
|
private _onZoom;
|
|
108
|
+
private _onZoomStart;
|
|
109
|
+
private _onZoomEnd;
|
|
110
|
+
private _updateNodePosition;
|
|
111
|
+
private _onBrush;
|
|
112
|
+
private _handleDrag;
|
|
109
113
|
private _onDragStarted;
|
|
110
114
|
private _onDragged;
|
|
111
115
|
private _onDragEnded;
|
|
116
|
+
private _dragSelectedNodes;
|
|
117
|
+
private _activateBrush;
|
|
118
|
+
private _clearBrush;
|
|
112
119
|
private _shouldLayoutRecalculate;
|
|
113
120
|
private _getLinkArrowDefId;
|
|
114
121
|
private _addSVGDefs;
|
|
@@ -116,7 +123,7 @@ export declare class Graph<N extends GraphInputNode, L extends GraphInputLink> e
|
|
|
116
123
|
zoomOut(increment?: number): void;
|
|
117
124
|
setZoom(zoomLevel: number): void;
|
|
118
125
|
getZoom(): number;
|
|
119
|
-
fitView(duration?: number): void;
|
|
126
|
+
fitView(duration?: number, nodeIds?: (string | number)[]): void;
|
|
120
127
|
/** Enable automatic fitting to container if it was disabled due to previous zoom / pan interactions */
|
|
121
128
|
resetAutofitState(): void;
|
|
122
129
|
/** Get current coordinates of the nodes as an array of { id: string; x: number; y: number } objects */
|