@deck.gl-community/graph-layers 9.2.0-beta.8 → 9.2.5
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/dist/_deprecated/old-constants.d.ts.map +1 -1
- package/dist/_deprecated/old-constants.js.map +1 -1
- package/dist/core/graph-layout.d.ts.map +1 -1
- package/dist/core/graph-layout.js.map +1 -1
- package/dist/core/interaction-manager.d.ts.map +1 -1
- package/dist/core/interaction-manager.js.map +1 -1
- package/dist/graph/arrow-graph.d.ts.map +1 -1
- package/dist/graph/arrow-graph.js.map +1 -1
- package/dist/graph/classic-graph.d.ts.map +1 -1
- package/dist/graph/classic-graph.js +1 -3
- package/dist/graph/classic-graph.js.map +1 -1
- package/dist/graph/functions/arrow-utils.d.ts.map +1 -1
- package/dist/graph/functions/arrow-utils.js +5 -3
- package/dist/graph/functions/arrow-utils.js.map +1 -1
- package/dist/graph/functions/create-graph-from-data.d.ts.map +1 -1
- package/dist/graph/functions/create-graph-from-data.js.map +1 -1
- package/dist/graph/graph-normalization.d.ts.map +1 -1
- package/dist/graph/graph-normalization.js.map +1 -1
- package/dist/graph-data/arrow-graph-data-builder.d.ts.map +1 -1
- package/dist/graph-data/arrow-graph-data-builder.js.map +1 -1
- package/dist/graph-data/graph-data-builder.d.ts.map +1 -1
- package/dist/graph-data/plain-graph-data-builder.d.ts.map +1 -1
- package/dist/graph-style-schema.cdn.js +1 -1
- package/dist/graph-style-schema.json +1 -1
- package/dist/index.cjs +42 -39
- package/dist/index.cjs.map +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/layers/common-layers/grid-layer/grid-layer.d.ts.map +1 -1
- package/dist/layers/common-layers/grid-layer/grid-layer.js +6 -16
- package/dist/layers/common-layers/grid-layer/grid-layer.js.map +1 -1
- package/dist/layers/edge-attachment-helper.d.ts.map +1 -1
- package/dist/layers/edge-attachment-helper.js +1 -3
- package/dist/layers/edge-attachment-helper.js.map +1 -1
- package/dist/layers/edge-layer.js +4 -4
- package/dist/layers/edge-layer.js.map +1 -1
- package/dist/layers/edge-layers/arrow-2d-geometry.js +1 -8
- package/dist/layers/edge-layers/arrow-2d-geometry.js.map +1 -1
- package/dist/layers/graph-layer.d.ts.map +1 -1
- package/dist/layers/graph-layer.js +9 -11
- package/dist/layers/graph-layer.js.map +1 -1
- package/dist/layouts/d3-dag/collapsable-d3-dag-layout.d.ts.map +1 -1
- package/dist/layouts/d3-dag/collapsable-d3-dag-layout.js.map +1 -1
- package/dist/layouts/d3-dag/d3-dag-layout.d.ts.map +1 -1
- package/dist/layouts/d3-dag/d3-dag-layout.js +9 -2
- package/dist/layouts/d3-dag/d3-dag-layout.js.map +1 -1
- package/dist/layouts/experimental/radial-layout.d.ts.map +1 -1
- package/dist/layouts/experimental/radial-layout.js.map +1 -1
- package/dist/layouts/simple-layout.d.ts.map +1 -1
- package/dist/layouts/simple-layout.js +4 -1
- package/dist/layouts/simple-layout.js.map +1 -1
- package/dist/loaders/dot-graph-loader.d.ts.map +1 -1
- package/dist/loaders/dot-graph-loader.js +10 -3
- package/dist/loaders/dot-graph-loader.js.map +1 -1
- package/dist/loaders/json-graph-loader.d.ts.map +1 -1
- package/dist/loaders/json-graph-loader.js +2 -2
- package/dist/loaders/json-graph-loader.js.map +1 -1
- package/dist/loaders/parsers/parse-json-graph.js +2 -1
- package/dist/loaders/parsers/parse-json-graph.js.map +1 -1
- package/dist/style/graph-layer-stylesheet.d.ts.map +1 -1
- package/dist/style/graph-layer-stylesheet.js +7 -7
- package/dist/style/graph-layer-stylesheet.js.map +1 -1
- package/dist/style/graph-style-engine.js +3 -1
- package/dist/style/graph-style-engine.js.map +1 -1
- package/dist/style/graph-stylesheet-schema.d.ts.map +1 -1
- package/dist/style/graph-stylesheet-schema.js +9 -17
- package/dist/style/graph-stylesheet-schema.js.map +1 -1
- package/dist/style/style-property.d.ts.map +1 -1
- package/dist/style/style-property.js +17 -5
- package/dist/style/style-property.js.map +1 -1
- package/dist/style/stylesheet-engine.d.ts.map +1 -1
- package/dist/style/stylesheet-engine.js +1 -1
- package/dist/style/stylesheet-engine.js.map +1 -1
- package/dist/utils/collapsed-chains.d.ts.map +1 -1
- package/dist/utils/collapsed-chains.js.map +1 -1
- package/dist/utils/node-boundary.d.ts.map +1 -1
- package/dist/utils/node-boundary.js +1 -1
- package/dist/utils/node-boundary.js.map +1 -1
- package/dist/utils/rank-grid.d.ts.map +1 -1
- package/dist/utils/rank-grid.js +5 -2
- package/dist/utils/rank-grid.js.map +1 -1
- package/package.json +8 -8
- package/src/_deprecated/old-constants.ts +12 -6
- package/src/core/graph-layout.ts +2 -6
- package/src/core/interaction-manager.ts +2 -1
- package/src/graph/arrow-graph.ts +17 -10
- package/src/graph/classic-graph.ts +8 -5
- package/src/graph/functions/arrow-utils.ts +8 -4
- package/src/graph/functions/create-graph-from-data.ts +2 -2
- package/src/graph/graph-normalization.ts +8 -2
- package/src/graph-data/arrow-graph-data-builder.ts +6 -3
- package/src/graph-data/graph-data-builder.ts +1 -1
- package/src/graph-data/plain-graph-data-builder.ts +1 -1
- package/src/index.ts +33 -16
- package/src/layers/common-layers/grid-layer/grid-layer.ts +26 -19
- package/src/layers/edge-attachment-helper.ts +53 -41
- package/src/layers/edge-layer.ts +4 -4
- package/src/layers/edge-layers/arrow-2d-geometry.ts +1 -8
- package/src/layers/graph-layer.ts +86 -82
- package/src/layouts/d3-dag/collapsable-d3-dag-layout.ts +14 -7
- package/src/layouts/d3-dag/d3-dag-layout.ts +31 -19
- package/src/layouts/experimental/radial-layout.ts +4 -1
- package/src/layouts/simple-layout.ts +6 -4
- package/src/loaders/dot-graph-loader.ts +19 -7
- package/src/loaders/json-graph-loader.ts +3 -5
- package/src/loaders/parsers/parse-json-graph.ts +2 -1
- package/src/style/graph-layer-stylesheet.ts +15 -15
- package/src/style/graph-style-engine.ts +9 -4
- package/src/style/graph-stylesheet-schema.ts +32 -80
- package/src/style/style-property.ts +26 -11
- package/src/style/stylesheet-engine.ts +44 -29
- package/src/utils/collapsed-chains.ts +6 -2
- package/src/utils/node-boundary.ts +2 -3
- package/src/utils/rank-grid.ts +31 -17
package/src/index.ts
CHANGED
|
@@ -4,14 +4,19 @@
|
|
|
4
4
|
|
|
5
5
|
// Graph Data - output from loaders, input to writers
|
|
6
6
|
|
|
7
|
-
export type {
|
|
8
|
-
|
|
7
|
+
export type {
|
|
8
|
+
GraphData,
|
|
9
|
+
PlainGraphData,
|
|
10
|
+
ArrowGraphData /* , GraphNodeData, GraphEdgeData */
|
|
11
|
+
} from './graph-data/graph-data';
|
|
12
|
+
export type {
|
|
13
|
+
GraphDataBuilder /* , GraphDataBuilderOptions */
|
|
14
|
+
} from './graph-data/graph-data-builder';
|
|
9
15
|
export {
|
|
10
16
|
ArrowGraphDataBuilder,
|
|
11
17
|
type ArrowGraphDataBuilderOptions
|
|
12
18
|
} from './graph-data/arrow-graph-data-builder';
|
|
13
19
|
|
|
14
|
-
|
|
15
20
|
// core - Graph representation and layout
|
|
16
21
|
export type {Graph, NodeInterface, EdgeInterface} from './graph/graph';
|
|
17
22
|
export {Node} from './graph/node';
|
|
@@ -36,11 +41,7 @@ export {ArrowGraph} from './graph/arrow-graph';
|
|
|
36
41
|
export {GraphEngine} from './core/graph-engine';
|
|
37
42
|
|
|
38
43
|
// graph-layers layouts
|
|
39
|
-
export type {
|
|
40
|
-
GraphLayoutProps,
|
|
41
|
-
GraphLayoutState,
|
|
42
|
-
GraphLayoutEventDetail
|
|
43
|
-
} from './core/graph-layout';
|
|
44
|
+
export type {GraphLayoutProps, GraphLayoutState, GraphLayoutEventDetail} from './core/graph-layout';
|
|
44
45
|
export {GraphLayout} from './core/graph-layout';
|
|
45
46
|
|
|
46
47
|
export {SimpleLayout} from './layouts/simple-layout';
|
|
@@ -52,13 +53,24 @@ export {RadialLayout} from './layouts/experimental/radial-layout';
|
|
|
52
53
|
export {ForceMultiGraphLayout} from './layouts/experimental/force-multi-graph-layout';
|
|
53
54
|
export {HivePlotLayout} from './layouts/experimental/hive-plot-layout';
|
|
54
55
|
|
|
55
|
-
export type {
|
|
56
|
+
export type {
|
|
57
|
+
Marker,
|
|
58
|
+
NodeState,
|
|
59
|
+
NodeType,
|
|
60
|
+
EdgeType,
|
|
61
|
+
EdgeDecoratorType,
|
|
62
|
+
LayoutState
|
|
63
|
+
} from './core/constants';
|
|
56
64
|
|
|
57
65
|
// deck.gl components
|
|
58
66
|
export {GraphLayer} from './layers/graph-layer';
|
|
59
67
|
export type {RankGridConfig} from './layers/graph-layer';
|
|
60
68
|
export {EdgeLayer} from './layers/edge-layer';
|
|
61
|
-
export {
|
|
69
|
+
export {
|
|
70
|
+
GridLayer,
|
|
71
|
+
type GridLayerProps,
|
|
72
|
+
type GridLineDatum
|
|
73
|
+
} from './layers/common-layers/grid-layer/grid-layer';
|
|
62
74
|
export {StylesheetEngine} from './style/stylesheet-engine';
|
|
63
75
|
export {GraphStylesheetEngine, GraphStyleEngine} from './style/graph-style-engine';
|
|
64
76
|
export type {
|
|
@@ -93,16 +105,21 @@ export {
|
|
|
93
105
|
} from './utils/rank-grid';
|
|
94
106
|
|
|
95
107
|
// graph format loaders
|
|
96
|
-
export {
|
|
97
|
-
JSONGraphLoader,
|
|
98
|
-
type JSONGraphLoaderOptions,
|
|
99
|
-
} from './loaders/json-graph-loader';
|
|
108
|
+
export {JSONGraphLoader, type JSONGraphLoaderOptions} from './loaders/json-graph-loader';
|
|
100
109
|
|
|
101
110
|
export {
|
|
102
111
|
DOTGraphLoader,
|
|
103
112
|
type DOTGraphLoaderOptions,
|
|
104
|
-
type DOTGraphLoaderMetadata
|
|
113
|
+
type DOTGraphLoaderMetadata
|
|
105
114
|
} from './loaders/dot-graph-loader';
|
|
106
115
|
|
|
107
116
|
// Deprecated exports
|
|
108
|
-
export {
|
|
117
|
+
export {
|
|
118
|
+
MARKER_TYPE,
|
|
119
|
+
NODE_STATE,
|
|
120
|
+
EDGE_STATE,
|
|
121
|
+
NODE_TYPE,
|
|
122
|
+
EDGE_TYPE,
|
|
123
|
+
EDGE_DECORATOR_TYPE,
|
|
124
|
+
LAYOUT_STATE
|
|
125
|
+
} from './_deprecated/old-constants';
|
|
@@ -49,10 +49,25 @@ const DEFAULT_OFFSET: [number, number] = [8, 0];
|
|
|
49
49
|
const DEFAULT_MIN = -1e6;
|
|
50
50
|
const DEFAULT_MAX = 1e6;
|
|
51
51
|
|
|
52
|
-
export class GridLayer<DatumT extends GridLineDatum = GridLineDatum> extends CompositeLayer<
|
|
52
|
+
export class GridLayer<DatumT extends GridLineDatum = GridLineDatum> extends CompositeLayer<
|
|
53
|
+
GridLayerProps<DatumT>
|
|
54
|
+
> {
|
|
53
55
|
static override layerName = 'GridLayer';
|
|
54
56
|
|
|
55
|
-
static override defaultProps: Required<
|
|
57
|
+
static override defaultProps: Required<
|
|
58
|
+
Pick<
|
|
59
|
+
GridLayerProps<GridLineDatum>,
|
|
60
|
+
| 'direction'
|
|
61
|
+
| 'width'
|
|
62
|
+
| 'color'
|
|
63
|
+
| 'xMin'
|
|
64
|
+
| 'xMax'
|
|
65
|
+
| 'yMin'
|
|
66
|
+
| 'yMax'
|
|
67
|
+
| 'showLabels'
|
|
68
|
+
| 'labelOffset'
|
|
69
|
+
>
|
|
70
|
+
> = {
|
|
56
71
|
direction: 'horizontal',
|
|
57
72
|
width: DEFAULT_WIDTH,
|
|
58
73
|
color: DEFAULT_COLOR,
|
|
@@ -66,7 +81,9 @@ export class GridLayer<DatumT extends GridLineDatum = GridLineDatum> extends Com
|
|
|
66
81
|
|
|
67
82
|
override shouldUpdateState(params: UpdateParameters<this>): boolean {
|
|
68
83
|
const {changeFlags} = params;
|
|
69
|
-
return Boolean(
|
|
84
|
+
return Boolean(
|
|
85
|
+
changeFlags.dataChanged || changeFlags.propsChanged || changeFlags.viewportChanged
|
|
86
|
+
);
|
|
70
87
|
}
|
|
71
88
|
|
|
72
89
|
override renderLayers() {
|
|
@@ -151,21 +168,13 @@ export class GridLayer<DatumT extends GridLineDatum = GridLineDatum> extends Com
|
|
|
151
168
|
|
|
152
169
|
const [bxMin, byMin, bxMax, byMax] = viewportBounds;
|
|
153
170
|
const minX =
|
|
154
|
-
Number.isFinite(bxMin) && Number.isFinite(bxMax)
|
|
155
|
-
? Math.min(bounds.xMin, bxMin)
|
|
156
|
-
: bounds.xMin;
|
|
171
|
+
Number.isFinite(bxMin) && Number.isFinite(bxMax) ? Math.min(bounds.xMin, bxMin) : bounds.xMin;
|
|
157
172
|
const maxX =
|
|
158
|
-
Number.isFinite(bxMin) && Number.isFinite(bxMax)
|
|
159
|
-
? Math.max(bounds.xMax, bxMax)
|
|
160
|
-
: bounds.xMax;
|
|
173
|
+
Number.isFinite(bxMin) && Number.isFinite(bxMax) ? Math.max(bounds.xMax, bxMax) : bounds.xMax;
|
|
161
174
|
const minY =
|
|
162
|
-
Number.isFinite(byMin) && Number.isFinite(byMax)
|
|
163
|
-
? Math.min(bounds.yMin, byMin)
|
|
164
|
-
: bounds.yMin;
|
|
175
|
+
Number.isFinite(byMin) && Number.isFinite(byMax) ? Math.min(bounds.yMin, byMin) : bounds.yMin;
|
|
165
176
|
const maxY =
|
|
166
|
-
Number.isFinite(byMin) && Number.isFinite(byMax)
|
|
167
|
-
? Math.max(bounds.yMax, byMax)
|
|
168
|
-
: bounds.yMax;
|
|
177
|
+
Number.isFinite(byMin) && Number.isFinite(byMax) ? Math.max(bounds.yMax, byMax) : bounds.yMax;
|
|
169
178
|
|
|
170
179
|
return {minX, maxX, minY, maxY};
|
|
171
180
|
}
|
|
@@ -222,12 +231,10 @@ export class GridLayer<DatumT extends GridLineDatum = GridLineDatum> extends Com
|
|
|
222
231
|
const isHorizontal = direction === 'horizontal';
|
|
223
232
|
|
|
224
233
|
for (const {datum, sourcePosition} of lines) {
|
|
225
|
-
const rawLabel = getLabel ? getLabel(datum) : datum.label ?? null;
|
|
234
|
+
const rawLabel = getLabel ? getLabel(datum) : (datum.label ?? null);
|
|
226
235
|
if (rawLabel !== null && rawLabel !== undefined && rawLabel !== '') {
|
|
227
236
|
const [sx, sy] = sourcePosition;
|
|
228
|
-
const position: [number, number] = isHorizontal
|
|
229
|
-
? [bounds.minX, sy]
|
|
230
|
-
: [sx, bounds.minY];
|
|
237
|
+
const position: [number, number] = isHorizontal ? [bounds.minX, sy] : [sx, bounds.minY];
|
|
231
238
|
labels.push({position, text: String(rawLabel), datum});
|
|
232
239
|
}
|
|
233
240
|
}
|
|
@@ -8,7 +8,11 @@ import type {NodeInterface} from '../graph/graph';
|
|
|
8
8
|
|
|
9
9
|
import {GraphStylesheetEngine, type GraphStyleRule} from '../style/graph-style-engine';
|
|
10
10
|
import type {GraphLayerNodeStyle} from '../style/graph-layer-stylesheet';
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
getNodeBoundaryIntersection,
|
|
13
|
+
type GeometryNodeType,
|
|
14
|
+
type NodeGeometry
|
|
15
|
+
} from '../utils/node-boundary';
|
|
12
16
|
import {warn} from '../utils/log';
|
|
13
17
|
|
|
14
18
|
type NumericAccessor = ((node: NodeInterface) => number) | number | null | undefined;
|
|
@@ -36,7 +40,10 @@ const GEOMETRY_NODE_TYPES: GeometryNodeType[] = [
|
|
|
36
40
|
'marker'
|
|
37
41
|
];
|
|
38
42
|
|
|
39
|
-
function evaluateNumericAccessor(
|
|
43
|
+
function evaluateNumericAccessor(
|
|
44
|
+
accessor: NumericAccessor,
|
|
45
|
+
node: NodeInterface
|
|
46
|
+
): number | undefined {
|
|
40
47
|
if (typeof accessor === 'function') {
|
|
41
48
|
const value = accessor(node);
|
|
42
49
|
return typeof value === 'number' && Number.isFinite(value) ? value : undefined;
|
|
@@ -127,12 +134,20 @@ const GEOMETRY_APPLIERS: Record<
|
|
|
127
134
|
},
|
|
128
135
|
'rounded-rectangle': (node, accessors, geometry) => {
|
|
129
136
|
assignRectangleDimensions(node, accessors, geometry);
|
|
130
|
-
assignDimension(
|
|
137
|
+
assignDimension(
|
|
138
|
+
geometry,
|
|
139
|
+
'cornerRadius',
|
|
140
|
+
resolveAccessorValue(accessors.getCornerRadius, node)
|
|
141
|
+
);
|
|
131
142
|
assignDimension(geometry, 'radius', resolveAccessorValue(accessors.getRadius, node));
|
|
132
143
|
},
|
|
133
144
|
'path-rounded-rectangle': (node, accessors, geometry) => {
|
|
134
145
|
assignRectangleDimensions(node, accessors, geometry);
|
|
135
|
-
assignDimension(
|
|
146
|
+
assignDimension(
|
|
147
|
+
geometry,
|
|
148
|
+
'cornerRadius',
|
|
149
|
+
resolveAccessorValue(accessors.getCornerRadius, node)
|
|
150
|
+
);
|
|
136
151
|
}
|
|
137
152
|
};
|
|
138
153
|
|
|
@@ -163,8 +178,7 @@ export class EdgeAttachmentHelper {
|
|
|
163
178
|
new Map<string | number, NodeInterface>()
|
|
164
179
|
);
|
|
165
180
|
|
|
166
|
-
return (edge: any) =>
|
|
167
|
-
this._getAdjustedEdgeLayout(engine, nodeAccessorMap, nodeMap, edge);
|
|
181
|
+
return (edge: any) => this._getAdjustedEdgeLayout(engine, nodeAccessorMap, nodeMap, edge);
|
|
168
182
|
}
|
|
169
183
|
|
|
170
184
|
private _buildNodeStyleAccessorMap({
|
|
@@ -184,45 +198,43 @@ export class EdgeAttachmentHelper {
|
|
|
184
198
|
|
|
185
199
|
const styles = Array.isArray(nodeStyle) ? nodeStyle : [nodeStyle];
|
|
186
200
|
|
|
187
|
-
styles
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
const {data = (nodes) => nodes, ...restStyle} = style;
|
|
191
|
-
const type = restStyle.type;
|
|
192
|
-
|
|
193
|
-
if (!type || !GEOMETRY_NODE_TYPES.includes(type as GeometryNodeType)) {
|
|
194
|
-
return;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
let stylesheet: GraphStylesheetEngine | null = null;
|
|
198
|
-
try {
|
|
199
|
-
stylesheet = engine.createStylesheetEngine(restStyle as GraphStyleRule, {
|
|
200
|
-
stateUpdateTrigger: (interactionManager as any).getLastInteraction()
|
|
201
|
-
});
|
|
202
|
-
} catch (error) {
|
|
203
|
-
warn(
|
|
204
|
-
`GraphLayer: Failed to evaluate node stylesheet for edge attachment (${String(
|
|
205
|
-
(error as Error).message ?? error
|
|
206
|
-
)}).`
|
|
207
|
-
);
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
const nodes = data(engine.getNodes());
|
|
212
|
-
if (!Array.isArray(nodes)) {
|
|
213
|
-
return;
|
|
214
|
-
}
|
|
201
|
+
styles.filter(Boolean).forEach((style) => {
|
|
202
|
+
const {data = (nodes) => nodes, ...restStyle} = style;
|
|
203
|
+
const type = restStyle.type;
|
|
215
204
|
|
|
216
|
-
|
|
217
|
-
|
|
205
|
+
if (!type || !GEOMETRY_NODE_TYPES.includes(type as GeometryNodeType)) {
|
|
206
|
+
return;
|
|
207
|
+
}
|
|
218
208
|
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
}
|
|
209
|
+
let stylesheet: GraphStylesheetEngine | null = null;
|
|
210
|
+
try {
|
|
211
|
+
stylesheet = engine.createStylesheetEngine(restStyle as GraphStyleRule, {
|
|
212
|
+
stateUpdateTrigger: (interactionManager as any).getLastInteraction()
|
|
224
213
|
});
|
|
214
|
+
} catch (error) {
|
|
215
|
+
warn(
|
|
216
|
+
`GraphLayer: Failed to evaluate node stylesheet for edge attachment (${String(
|
|
217
|
+
(error as Error).message ?? error
|
|
218
|
+
)}).`
|
|
219
|
+
);
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
const nodes = data(engine.getNodes());
|
|
224
|
+
if (!Array.isArray(nodes)) {
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
const geometryType = type as GeometryNodeType;
|
|
229
|
+
const accessors = this._createAccessorsForType(geometryType, stylesheet);
|
|
230
|
+
|
|
231
|
+
nodes.forEach((node: NodeInterface) => {
|
|
232
|
+
const id = node.getId();
|
|
233
|
+
if (!nodeAccessorMap.has(id)) {
|
|
234
|
+
nodeAccessorMap.set(id, accessors);
|
|
235
|
+
}
|
|
225
236
|
});
|
|
237
|
+
});
|
|
226
238
|
|
|
227
239
|
return nodeAccessorMap;
|
|
228
240
|
}
|
package/src/layers/edge-layer.ts
CHANGED
|
@@ -9,8 +9,8 @@ import {PathEdgeLayer} from './edge-layers/path-edge-layer';
|
|
|
9
9
|
import {CurvedEdgeLayer} from './edge-layers/curved-edge-layer';
|
|
10
10
|
|
|
11
11
|
const EDGE_LAYER_MAP = {
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
line: StraightLineEdgeLayer,
|
|
13
|
+
path: PathEdgeLayer,
|
|
14
14
|
'spline-curve': CurvedEdgeLayer
|
|
15
15
|
};
|
|
16
16
|
|
|
@@ -46,8 +46,8 @@ export class EdgeLayer extends CompositeLayer {
|
|
|
46
46
|
return res;
|
|
47
47
|
},
|
|
48
48
|
{
|
|
49
|
-
|
|
50
|
-
|
|
49
|
+
line: [],
|
|
50
|
+
path: [],
|
|
51
51
|
'spline-curve': []
|
|
52
52
|
}
|
|
53
53
|
);
|
|
@@ -34,14 +34,7 @@ function getArrowAttributes({length = 1, headWidth = 1}) {
|
|
|
34
34
|
|
|
35
35
|
const normals = new Float32Array([0, 0, 1, 0, 0, 1, 0, 0, 1]);
|
|
36
36
|
|
|
37
|
-
const texCoords = new Float32Array([
|
|
38
|
-
0.5,
|
|
39
|
-
1,
|
|
40
|
-
0,
|
|
41
|
-
0,
|
|
42
|
-
1,
|
|
43
|
-
0
|
|
44
|
-
]);
|
|
37
|
+
const texCoords = new Float32Array([0.5, 1, 0, 0, 1, 0]);
|
|
45
38
|
|
|
46
39
|
return {
|
|
47
40
|
positions: {size: 3, value: positions},
|
|
@@ -58,19 +58,19 @@ import {createGraphFromData} from '../graph/functions/create-graph-from-data';
|
|
|
58
58
|
import {warn} from '../utils/log';
|
|
59
59
|
|
|
60
60
|
const NODE_LAYER_MAP = {
|
|
61
|
-
|
|
61
|
+
rectangle: RectangleLayer,
|
|
62
62
|
'rounded-rectangle': RoundedRectangleLayer,
|
|
63
63
|
'path-rounded-rectangle': PathBasedRoundedRectangleLayer,
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
icon: ImageLayer,
|
|
65
|
+
circle: CircleLayer,
|
|
66
|
+
label: LabelLayer,
|
|
67
|
+
marker: ZoomableMarkerLayer
|
|
68
68
|
};
|
|
69
69
|
|
|
70
70
|
const EDGE_DECORATOR_LAYER_MAP = {
|
|
71
71
|
'edge-label': EdgeLabelLayer,
|
|
72
|
-
|
|
73
|
-
|
|
72
|
+
flow: FlowLayer,
|
|
73
|
+
arrow: EdgeArrowLayer
|
|
74
74
|
};
|
|
75
75
|
|
|
76
76
|
type GridLayerOverrides = Partial<Omit<GridLayerProps, 'id' | 'data' | 'direction'>>;
|
|
@@ -569,9 +569,7 @@ export class GraphLayer extends CompositeLayer<GraphLayerProps> {
|
|
|
569
569
|
}
|
|
570
570
|
|
|
571
571
|
const candidate = value as Graph;
|
|
572
|
-
return
|
|
573
|
-
typeof candidate.getNodes === 'function' && typeof candidate.getEdges === 'function'
|
|
574
|
-
);
|
|
572
|
+
return typeof candidate.getNodes === 'function' && typeof candidate.getEdges === 'function';
|
|
575
573
|
}
|
|
576
574
|
|
|
577
575
|
private _coerceGraph(value: unknown): Graph | null {
|
|
@@ -596,7 +594,10 @@ export class GraphLayer extends CompositeLayer<GraphLayerProps> {
|
|
|
596
594
|
try {
|
|
597
595
|
return candidate.toClassicGraph() ?? null;
|
|
598
596
|
} catch (error) {
|
|
599
|
-
warn(
|
|
597
|
+
warn(
|
|
598
|
+
'GraphLayer: failed to convert graph to ClassicGraph for layout compatibility.',
|
|
599
|
+
error
|
|
600
|
+
);
|
|
600
601
|
}
|
|
601
602
|
}
|
|
602
603
|
|
|
@@ -725,9 +726,10 @@ export class GraphLayer extends CompositeLayer<GraphLayerProps> {
|
|
|
725
726
|
});
|
|
726
727
|
}
|
|
727
728
|
|
|
728
|
-
private _normalizeRankGridConfig(
|
|
729
|
-
|
|
730
|
-
|
|
729
|
+
private _normalizeRankGridConfig(value: GraphLayerProps['rankGrid']): {
|
|
730
|
+
enabled: boolean;
|
|
731
|
+
config?: RankGridConfig;
|
|
732
|
+
} {
|
|
731
733
|
if (typeof value === 'boolean') {
|
|
732
734
|
return {enabled: value};
|
|
733
735
|
}
|
|
@@ -739,9 +741,9 @@ export class GraphLayer extends CompositeLayer<GraphLayerProps> {
|
|
|
739
741
|
return {enabled: false};
|
|
740
742
|
}
|
|
741
743
|
|
|
742
|
-
private _resolveRankGridBounds(
|
|
743
|
-
|
|
744
|
-
|
|
744
|
+
private _resolveRankGridBounds(
|
|
745
|
+
engine: GraphEngine
|
|
746
|
+
): {xMin: number; xMax: number; yMin: number; yMax: number} | null {
|
|
745
747
|
const bounds = engine.getLayoutBounds();
|
|
746
748
|
if (!bounds) {
|
|
747
749
|
return null;
|
|
@@ -765,7 +767,12 @@ export class GraphLayer extends CompositeLayer<GraphLayerProps> {
|
|
|
765
767
|
engine: GraphEngine,
|
|
766
768
|
config: RankGridConfig | undefined,
|
|
767
769
|
bounds: {yMin: number; yMax: number}
|
|
768
|
-
): Array<{
|
|
770
|
+
): Array<{
|
|
771
|
+
label: string;
|
|
772
|
+
rank: number;
|
|
773
|
+
originalLabel?: string | number;
|
|
774
|
+
yPosition: number;
|
|
775
|
+
}> | null {
|
|
769
776
|
const rankLabelPrefix = this._resolveRankFieldLabel(config?.rankAccessor);
|
|
770
777
|
// @ts-ignore iterator type
|
|
771
778
|
const rankPositions = mapRanksToYPositions(engine.getNodes(), engine.getNodePosition, {
|
|
@@ -876,66 +883,64 @@ export class GraphLayer extends CompositeLayer<GraphLayerProps> {
|
|
|
876
883
|
nodeStyle: nodeStyles
|
|
877
884
|
});
|
|
878
885
|
|
|
879
|
-
return edgeStyleArray
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
return [];
|
|
892
|
-
}
|
|
886
|
+
return edgeStyleArray.filter(Boolean).flatMap((style, idx) => {
|
|
887
|
+
const {decorators, data = (edges) => edges, visible = true, ...restEdgeStyle} = style;
|
|
888
|
+
const stylesheet = this._createStylesheetEngine(
|
|
889
|
+
{
|
|
890
|
+
type: 'edge',
|
|
891
|
+
...restEdgeStyle
|
|
892
|
+
} as GraphStyleRule,
|
|
893
|
+
'edge stylesheet'
|
|
894
|
+
);
|
|
895
|
+
if (!stylesheet) {
|
|
896
|
+
return [];
|
|
897
|
+
}
|
|
893
898
|
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
899
|
+
const edgeLayer = new EdgeLayer({
|
|
900
|
+
...SHARED_LAYER_PROPS,
|
|
901
|
+
id: `edge-layer-${idx}`,
|
|
902
|
+
data: data(engine.getEdges()),
|
|
903
|
+
getLayoutInfo,
|
|
904
|
+
pickable: true,
|
|
905
|
+
positionUpdateTrigger: [engine.getLayoutLastUpdate(), engine.getLayoutState()].join(),
|
|
906
|
+
stylesheet,
|
|
907
|
+
visible
|
|
908
|
+
} as any);
|
|
909
|
+
|
|
910
|
+
if (!decorators || !Array.isArray(decorators) || decorators.length === 0) {
|
|
911
|
+
return [edgeLayer];
|
|
912
|
+
}
|
|
904
913
|
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
914
|
+
const decoratorLayers = decorators
|
|
915
|
+
.filter(Boolean)
|
|
916
|
+
// @ts-ignore eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
917
|
+
.map((decoratorStyle, idx2) => {
|
|
918
|
+
const DecoratorLayer = EDGE_DECORATOR_LAYER_MAP[decoratorStyle.type];
|
|
919
|
+
if (!DecoratorLayer) {
|
|
920
|
+
warn(`GraphLayer: Invalid edge decorator type "${decoratorStyle.type}".`);
|
|
921
|
+
return null;
|
|
922
|
+
}
|
|
923
|
+
const decoratorStylesheet = this._createStylesheetEngine(
|
|
924
|
+
decoratorStyle as unknown as GraphStyleRule,
|
|
925
|
+
`edge decorator stylesheet "${decoratorStyle.type}"`
|
|
926
|
+
);
|
|
927
|
+
if (!decoratorStylesheet) {
|
|
928
|
+
return null;
|
|
929
|
+
}
|
|
930
|
+
return new DecoratorLayer({
|
|
931
|
+
...SHARED_LAYER_PROPS,
|
|
932
|
+
id: `edge-decorator-${idx2}`,
|
|
933
|
+
data: data(engine.getEdges()),
|
|
934
|
+
getLayoutInfo,
|
|
935
|
+
pickable: true,
|
|
936
|
+
positionUpdateTrigger: [engine.getLayoutLastUpdate(), engine.getLayoutState()].join(),
|
|
937
|
+
stylesheet: decoratorStylesheet
|
|
938
|
+
} as any);
|
|
939
|
+
})
|
|
940
|
+
.filter(Boolean);
|
|
908
941
|
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
// @ts-ignore eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
912
|
-
.map((decoratorStyle, idx2) => {
|
|
913
|
-
const DecoratorLayer = EDGE_DECORATOR_LAYER_MAP[decoratorStyle.type];
|
|
914
|
-
if (!DecoratorLayer) {
|
|
915
|
-
warn(`GraphLayer: Invalid edge decorator type "${decoratorStyle.type}".`);
|
|
916
|
-
return null;
|
|
917
|
-
}
|
|
918
|
-
const decoratorStylesheet = this._createStylesheetEngine(
|
|
919
|
-
decoratorStyle as unknown as GraphStyleRule,
|
|
920
|
-
`edge decorator stylesheet "${decoratorStyle.type}"`
|
|
921
|
-
);
|
|
922
|
-
if (!decoratorStylesheet) {
|
|
923
|
-
return null;
|
|
924
|
-
}
|
|
925
|
-
return new DecoratorLayer({
|
|
926
|
-
...SHARED_LAYER_PROPS,
|
|
927
|
-
id: `edge-decorator-${idx2}`,
|
|
928
|
-
data: data(engine.getEdges()),
|
|
929
|
-
getLayoutInfo,
|
|
930
|
-
pickable: true,
|
|
931
|
-
positionUpdateTrigger: [engine.getLayoutLastUpdate(), engine.getLayoutState()].join(),
|
|
932
|
-
stylesheet: decoratorStylesheet
|
|
933
|
-
} as any);
|
|
934
|
-
})
|
|
935
|
-
.filter(Boolean);
|
|
936
|
-
|
|
937
|
-
return [edgeLayer, ...decoratorLayers];
|
|
938
|
-
});
|
|
942
|
+
return [edgeLayer, ...decoratorLayers];
|
|
943
|
+
});
|
|
939
944
|
}
|
|
940
945
|
|
|
941
946
|
onClick(info, event): boolean {
|
|
@@ -1105,12 +1110,11 @@ export class GraphLayer extends CompositeLayer<GraphLayerProps> {
|
|
|
1105
1110
|
}
|
|
1106
1111
|
}
|
|
1107
1112
|
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
}
|
|
1112
|
-
|
|
1113
|
-
const prototype = Object.getPrototypeOf(value);
|
|
1114
|
-
return prototype === Object.prototype || prototype === null;
|
|
1113
|
+
function isPlainObject(value: unknown): value is Record<string | number | symbol, unknown> {
|
|
1114
|
+
if (!value || typeof value !== 'object') {
|
|
1115
|
+
return false;
|
|
1115
1116
|
}
|
|
1116
1117
|
|
|
1118
|
+
const prototype = Object.getPrototypeOf(value);
|
|
1119
|
+
return prototype === Object.prototype || prototype === null;
|
|
1120
|
+
}
|
|
@@ -19,13 +19,13 @@ type CollapsedChainDescriptor = {
|
|
|
19
19
|
export type CollapsableD3DagLayoutProps = D3DagLayoutProps & {
|
|
20
20
|
/** Whether to collapse linear chains of nodes into a single representative. */
|
|
21
21
|
collapseLinearChains?: boolean;
|
|
22
|
-
}
|
|
22
|
+
};
|
|
23
23
|
|
|
24
24
|
export class CollapsableD3DagLayout extends D3DagLayout<CollapsableD3DagLayoutProps> {
|
|
25
25
|
static override defaultProps: Required<CollapsableD3DagLayoutProps> = {
|
|
26
26
|
...D3DagLayout.defaultProps,
|
|
27
27
|
collapseLinearChains: false
|
|
28
|
-
}
|
|
28
|
+
};
|
|
29
29
|
|
|
30
30
|
private _chainDescriptors = new Map<string, CollapsedChainDescriptor>();
|
|
31
31
|
private _nodeToChainId = new Map<string | number, string>();
|
|
@@ -61,7 +61,10 @@ export class CollapsableD3DagLayout extends D3DagLayout<CollapsableD3DagLayoutPr
|
|
|
61
61
|
}
|
|
62
62
|
|
|
63
63
|
if (!this._chainDescriptors.has(chainId)) {
|
|
64
|
-
log.log(
|
|
64
|
+
log.log(
|
|
65
|
+
1,
|
|
66
|
+
`CollapsableD3DagLayout: toggleCollapsedChain(${chainId}) skipped (unknown chain)`
|
|
67
|
+
);
|
|
65
68
|
return;
|
|
66
69
|
}
|
|
67
70
|
|
|
@@ -102,9 +105,14 @@ export class CollapsableD3DagLayout extends D3DagLayout<CollapsableD3DagLayoutPr
|
|
|
102
105
|
}
|
|
103
106
|
|
|
104
107
|
if (changed) {
|
|
105
|
-
log.log(
|
|
108
|
+
log.log(
|
|
109
|
+
0,
|
|
110
|
+
'CollapsableD3DagLayout: setCollapsedChains -> changes detected, rerunning layout'
|
|
111
|
+
);
|
|
106
112
|
// eslint-disable-next-line no-console
|
|
107
|
-
console.log(
|
|
113
|
+
console.log(
|
|
114
|
+
'CollapsableD3DagLayout: setCollapsedChains -> changes detected, rerunning layout'
|
|
115
|
+
);
|
|
108
116
|
this._runLayout();
|
|
109
117
|
} else {
|
|
110
118
|
log.log(1, 'CollapsableD3DagLayout: setCollapsedChains -> no changes');
|
|
@@ -138,8 +146,7 @@ export class CollapsableD3DagLayout extends D3DagLayout<CollapsableD3DagLayoutPr
|
|
|
138
146
|
`CollapsableD3DagLayout: refreshing collapsed chains (previous=${previousChainCount})`
|
|
139
147
|
);
|
|
140
148
|
|
|
141
|
-
const collapseDefault =
|
|
142
|
-
this.props.collapseLinearChains;
|
|
149
|
+
const collapseDefault = this.props.collapseLinearChains;
|
|
143
150
|
|
|
144
151
|
const previousStates = new Map(this._collapsedChainState);
|
|
145
152
|
|