@orbcharts/plugins-basic 3.0.0-beta.8 → 3.0.0-beta.9
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/orbcharts-plugins-basic/lib/plugins-basic-types.d.ts +1 -1
- package/dist/orbcharts-plugins-basic/src/grid/plugins/Bars.d.ts +1 -1
- package/dist/orbcharts-plugins-basic/src/grid/plugins/BarsPN.d.ts +1 -1
- package/dist/orbcharts-plugins-basic/src/grid/plugins/BarsTriangle.d.ts +1 -1
- package/dist/orbcharts-plugins-basic/src/grid/plugins/Dots.d.ts +1 -1
- package/dist/orbcharts-plugins-basic/src/grid/plugins/GridLegend.d.ts +1 -1
- package/dist/orbcharts-plugins-basic/src/grid/plugins/GridTooltip.d.ts +1 -1
- package/dist/orbcharts-plugins-basic/src/grid/plugins/GridZoom.d.ts +1 -1
- package/dist/orbcharts-plugins-basic/src/grid/plugins/GroupAux.d.ts +1 -1
- package/dist/orbcharts-plugins-basic/src/grid/plugins/GroupAxis.d.ts +1 -1
- package/dist/orbcharts-plugins-basic/src/grid/plugins/LineAreas.d.ts +1 -1
- package/dist/orbcharts-plugins-basic/src/grid/plugins/Lines.d.ts +1 -1
- package/dist/orbcharts-plugins-basic/src/grid/plugins/StackedBar.d.ts +1 -1
- package/dist/orbcharts-plugins-basic/src/grid/plugins/StackedValueAxis.d.ts +1 -1
- package/dist/orbcharts-plugins-basic/src/grid/plugins/ValueAxis.d.ts +1 -1
- package/dist/orbcharts-plugins-basic/src/multiGrid/plugins/MultiBars.d.ts +1 -1
- package/dist/orbcharts-plugins-basic/src/multiGrid/plugins/MultiBarsTriangle.d.ts +1 -1
- package/dist/orbcharts-plugins-basic/src/multiGrid/plugins/MultiDots.d.ts +1 -1
- package/dist/orbcharts-plugins-basic/src/multiGrid/plugins/MultiGridLegend.d.ts +1 -1
- package/dist/orbcharts-plugins-basic/src/multiGrid/plugins/MultiGridTooltip.d.ts +1 -1
- package/dist/orbcharts-plugins-basic/src/multiGrid/plugins/MultiGroupAxis.d.ts +1 -1
- package/dist/orbcharts-plugins-basic/src/multiGrid/plugins/MultiLineAreas.d.ts +1 -1
- package/dist/orbcharts-plugins-basic/src/multiGrid/plugins/MultiLines.d.ts +1 -1
- package/dist/orbcharts-plugins-basic/src/multiGrid/plugins/MultiStackedBar.d.ts +1 -1
- package/dist/orbcharts-plugins-basic/src/multiGrid/plugins/MultiStackedValueAxis.d.ts +1 -1
- package/dist/orbcharts-plugins-basic/src/multiGrid/plugins/MultiValueAxis.d.ts +1 -1
- package/dist/orbcharts-plugins-basic/src/multiGrid/plugins/OverlappingStackedValueAxes.d.ts +1 -1
- package/dist/orbcharts-plugins-basic/src/multiGrid/plugins/OverlappingValueAxes.d.ts +1 -1
- package/dist/orbcharts-plugins-basic/src/multiValue/plugins/MultiValueLegend.d.ts +1 -1
- package/dist/orbcharts-plugins-basic/src/multiValue/plugins/MultiValueTooltip.d.ts +1 -1
- package/dist/orbcharts-plugins-basic/src/multiValue/plugins/Scatter.d.ts +1 -1
- package/dist/orbcharts-plugins-basic/src/multiValue/plugins/ScatterBubbles.d.ts +1 -1
- package/dist/orbcharts-plugins-basic/src/multiValue/plugins/XYAux.d.ts +1 -1
- package/dist/orbcharts-plugins-basic/src/multiValue/plugins/XYAxes.d.ts +1 -1
- package/dist/orbcharts-plugins-basic/src/multiValue/plugins/XYZoom.d.ts +1 -1
- package/dist/orbcharts-plugins-basic/src/relationship/defaults.d.ts +2 -1
- package/dist/orbcharts-plugins-basic/src/relationship/index.d.ts +1 -0
- package/dist/orbcharts-plugins-basic/src/relationship/plugins/ForceDirected.d.ts +1 -1
- package/dist/orbcharts-plugins-basic/src/relationship/plugins/ForceDirectedBubbles.d.ts +3 -0
- package/dist/orbcharts-plugins-basic/src/relationship/plugins/RelationshipLegend.d.ts +1 -1
- package/dist/orbcharts-plugins-basic/src/relationship/plugins/RelationshipTooltip.d.ts +1 -1
- package/dist/orbcharts-plugins-basic/src/series/plugins/Bubbles.d.ts +1 -1
- package/dist/orbcharts-plugins-basic/src/series/plugins/Pie.d.ts +1 -1
- package/dist/orbcharts-plugins-basic/src/series/plugins/PieEventTexts.d.ts +1 -1
- package/dist/orbcharts-plugins-basic/src/series/plugins/PieLabels.d.ts +1 -1
- package/dist/orbcharts-plugins-basic/src/series/plugins/Rose.d.ts +1 -1
- package/dist/orbcharts-plugins-basic/src/series/plugins/RoseLabels.d.ts +1 -1
- package/dist/orbcharts-plugins-basic/src/series/plugins/SeriesLegend.d.ts +1 -1
- package/dist/orbcharts-plugins-basic/src/series/plugins/SeriesTooltip.d.ts +1 -1
- package/dist/orbcharts-plugins-basic/src/tree/plugins/TreeLegend.d.ts +1 -1
- package/dist/orbcharts-plugins-basic/src/tree/plugins/TreeMap.d.ts +1 -1
- package/dist/orbcharts-plugins-basic/src/tree/plugins/TreeTooltip.d.ts +1 -1
- package/dist/orbcharts-plugins-basic.es.js +8148 -7484
- package/dist/orbcharts-plugins-basic.umd.js +63 -58
- package/lib/plugins-basic-types.ts +2 -2
- package/package.json +3 -3
- package/src/relationship/defaults.ts +101 -18
- package/src/relationship/index.ts +1 -0
- package/src/relationship/plugins/ForceDirected.ts +87 -68
- package/src/relationship/plugins/ForceDirectedBubbles.ts +1391 -0
- package/src/series/defaults.ts +1 -1
- package/src/series/plugins/Bubbles.ts +4 -2
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@orbcharts/plugins-basic",
|
3
|
-
"version": "3.0.0-beta.
|
3
|
+
"version": "3.0.0-beta.9",
|
4
4
|
"description": "plugins for OrbCharts",
|
5
5
|
"author": "Blue Planet Inc.",
|
6
6
|
"license": "Apache-2.0",
|
@@ -35,9 +35,9 @@
|
|
35
35
|
"vite-plugin-dts": "^3.7.3"
|
36
36
|
},
|
37
37
|
"dependencies": {
|
38
|
-
"@orbcharts/core": "^3.0.0-beta.
|
38
|
+
"@orbcharts/core": "^3.0.0-beta.7",
|
39
39
|
"@orbcharts/core-types": "^3.0.0-beta.5",
|
40
|
-
"@orbcharts/plugins-basic-types": "^3.0.0-beta.
|
40
|
+
"@orbcharts/plugins-basic-types": "^3.0.0-beta.9",
|
41
41
|
"d3": "^7.8.5",
|
42
42
|
"rxjs": "^7.8.1"
|
43
43
|
}
|
@@ -1,30 +1,55 @@
|
|
1
1
|
import type {
|
2
2
|
ForceDirectedParams,
|
3
|
+
ForceDirectedBubblesParams,
|
3
4
|
RelationshipLegendParams,
|
4
5
|
RelationshipTooltipParams
|
5
6
|
} from '../../lib/plugins-basic-types'
|
6
7
|
|
7
8
|
|
8
9
|
export const DEFAULT_FORCE_DIRECTED_PARAMS: ForceDirectedParams = {
|
9
|
-
node: {
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
10
|
+
// node: {
|
11
|
+
// dotRadius: 10,
|
12
|
+
// dotFillColorType: 'label',
|
13
|
+
// dotStrokeColorType: 'label',
|
14
|
+
// dotStrokeWidth: 1,
|
15
|
+
// dotStyleFn: (node) => '',
|
16
|
+
// labelColorType: 'primary',
|
17
|
+
// labelSizeFixed: false,
|
18
|
+
// labelStyleFn: (node) => 'text-shadow:0 1px 0 #fff, 1px 0 0 #fff, 0 -1px 0 #fff, -1px 0 0 #fff'
|
19
|
+
// },
|
20
|
+
// edge: {
|
21
|
+
// arrowColorType: 'primary',
|
22
|
+
// arrowStrokeWidth: 1.5,
|
23
|
+
// arrowWidth: 5,
|
24
|
+
// arrowHeight: 5,
|
25
|
+
// arrowStyleFn: (node) => '',
|
26
|
+
// labelColorType: 'secondary',
|
27
|
+
// labelSizeFixed: false,
|
28
|
+
// labelStyleFn: (node) => ''
|
29
|
+
// },
|
30
|
+
dot: {
|
31
|
+
radius: 10,
|
32
|
+
fillColorType: 'label',
|
33
|
+
strokeColorType: 'label',
|
34
|
+
strokeWidth: 1,
|
35
|
+
styleFn: (node) => '',
|
18
36
|
},
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
37
|
+
dotLabel: {
|
38
|
+
colorType: 'primary',
|
39
|
+
sizeFixed: false,
|
40
|
+
styleFn: (node) => 'text-shadow:0 1px 0 #fff, 1px 0 0 #fff, 0 -1px 0 #fff, -1px 0 0 #fff'
|
41
|
+
},
|
42
|
+
arrow: {
|
43
|
+
colorType: 'primary',
|
44
|
+
strokeWidth: 1.5,
|
45
|
+
pointerWidth: 5,
|
46
|
+
pointerHeight: 5,
|
47
|
+
styleFn: (node) => '',
|
48
|
+
},
|
49
|
+
arrowLabel: {
|
50
|
+
colorType: 'secondary',
|
51
|
+
sizeFixed: false,
|
52
|
+
styleFn: (node) => ''
|
28
53
|
},
|
29
54
|
force: {
|
30
55
|
nodeStrength: -500, // 泡泡引力
|
@@ -44,6 +69,64 @@ export const DEFAULT_FORCE_DIRECTED_PARAMS: ForceDirectedParams = {
|
|
44
69
|
max: Infinity
|
45
70
|
}
|
46
71
|
}
|
72
|
+
DEFAULT_FORCE_DIRECTED_PARAMS.dot.styleFn.toString = () => `(node) => ''`
|
73
|
+
DEFAULT_FORCE_DIRECTED_PARAMS.dotLabel.styleFn.toString = () => `(node) => 'text-shadow:0 1px 0 #fff, 1px 0 0 #fff, 0 -1px 0 #fff, -1px 0 0 #fff'`
|
74
|
+
DEFAULT_FORCE_DIRECTED_PARAMS.arrow.styleFn.toString = () => `(node) => ''`
|
75
|
+
DEFAULT_FORCE_DIRECTED_PARAMS.arrowLabel.styleFn.toString = () => `(node) => ''`
|
76
|
+
|
77
|
+
export const DEFAULT_FORCE_DIRECTED_BUBBLES_PARAMS: ForceDirectedBubblesParams = {
|
78
|
+
bubble: {
|
79
|
+
radiusMin: 30,
|
80
|
+
radiusMax: 60,
|
81
|
+
arcScaleType: 'area',
|
82
|
+
fillColorType: 'label',
|
83
|
+
strokeColorType: 'label',
|
84
|
+
strokeWidth: 1,
|
85
|
+
styleFn: (node) => '',
|
86
|
+
},
|
87
|
+
bubbleLabel: {
|
88
|
+
fillRate: 0.8,
|
89
|
+
lineHeight: 1,
|
90
|
+
lineLengthMin: 4,
|
91
|
+
colorType: 'primary',
|
92
|
+
styleFn: (node) => ''
|
93
|
+
},
|
94
|
+
arrow: {
|
95
|
+
colorType: 'primary',
|
96
|
+
strokeWidthMin: 1.5,
|
97
|
+
strokeWidthMax: 4.5,
|
98
|
+
pointerWidth: 5,
|
99
|
+
pointerHeight: 5,
|
100
|
+
styleFn: (node) => '',
|
101
|
+
},
|
102
|
+
arrowLabel: {
|
103
|
+
colorType: 'secondary',
|
104
|
+
sizeFixed: false,
|
105
|
+
styleFn: (node) => ''
|
106
|
+
},
|
107
|
+
force: {
|
108
|
+
nodeStrength: -500, // 泡泡引力
|
109
|
+
linkDistance: 200, // 連結長度
|
110
|
+
velocityDecay: 0.1, // 衰減數
|
111
|
+
alphaDecay: 0.05
|
112
|
+
// collisionSpacing: 2 // 泡泡間距
|
113
|
+
},
|
114
|
+
zoomable: true,
|
115
|
+
transform: {
|
116
|
+
x: 0,
|
117
|
+
y: 0,
|
118
|
+
k: 1
|
119
|
+
},
|
120
|
+
scaleExtent: {
|
121
|
+
min: 0,
|
122
|
+
max: Infinity
|
123
|
+
}
|
124
|
+
}
|
125
|
+
DEFAULT_FORCE_DIRECTED_BUBBLES_PARAMS.bubble.styleFn.toString = () => `(node) => ''`
|
126
|
+
DEFAULT_FORCE_DIRECTED_BUBBLES_PARAMS.bubbleLabel.styleFn.toString = () => `(node) => ''`
|
127
|
+
DEFAULT_FORCE_DIRECTED_BUBBLES_PARAMS.arrow.styleFn.toString = () => `(node) => ''`
|
128
|
+
DEFAULT_FORCE_DIRECTED_BUBBLES_PARAMS.arrowLabel.styleFn.toString = () => `(node) => ''`
|
129
|
+
|
47
130
|
|
48
131
|
export const DEFAULT_RELATIONSHIP_LEGEND_PARAMS: RelationshipLegendParams = {
|
49
132
|
placement: 'right-end',
|
@@ -1,4 +1,5 @@
|
|
1
1
|
export * from './defaults'
|
2
2
|
export { ForceDirected } from './plugins/ForceDirected'
|
3
|
+
export { ForceDirectedBubbles } from './plugins/ForceDirectedBubbles'
|
3
4
|
export { RelationshipLegend } from './plugins/RelationshipLegend'
|
4
5
|
export { RelationshipTooltip } from './plugins/RelationshipTooltip'
|
@@ -109,10 +109,16 @@ const pluginConfig: DefinePluginConfig<typeof pluginName, typeof DEFAULT_FORCE_D
|
|
109
109
|
layerIndex: LAYER_INDEX_OF_GRAPHIC,
|
110
110
|
validator: (params, { validateColumns }) => {
|
111
111
|
const result = validateColumns(params, {
|
112
|
-
|
112
|
+
dot: {
|
113
113
|
toBeTypes: ['object']
|
114
114
|
},
|
115
|
-
|
115
|
+
dotLabel: {
|
116
|
+
toBeTypes: ['object']
|
117
|
+
},
|
118
|
+
arrow: {
|
119
|
+
toBeTypes: ['object']
|
120
|
+
},
|
121
|
+
arrowLabel: {
|
116
122
|
toBeTypes: ['object']
|
117
123
|
},
|
118
124
|
force: {
|
@@ -128,66 +134,80 @@ const pluginConfig: DefinePluginConfig<typeof pluginName, typeof DEFAULT_FORCE_D
|
|
128
134
|
toBeTypes: ['object']
|
129
135
|
}
|
130
136
|
})
|
131
|
-
if (params.
|
132
|
-
const
|
133
|
-
|
137
|
+
if (params.dot) {
|
138
|
+
const dotResult = validateColumns(params.dot, {
|
139
|
+
radius: {
|
134
140
|
toBeTypes: ['number']
|
135
141
|
},
|
136
|
-
|
142
|
+
fillColorType: {
|
137
143
|
toBeOption: 'ColorType'
|
138
144
|
},
|
139
|
-
|
145
|
+
strokeColorType: {
|
140
146
|
toBeOption: 'ColorType'
|
141
147
|
},
|
142
|
-
|
148
|
+
strokeWidth: {
|
143
149
|
toBeTypes: ['number']
|
144
150
|
},
|
145
|
-
|
151
|
+
styleFn: {
|
146
152
|
toBeTypes: ['Function']
|
147
153
|
},
|
148
|
-
|
154
|
+
})
|
155
|
+
if (dotResult.status === 'error') {
|
156
|
+
return dotResult
|
157
|
+
}
|
158
|
+
}
|
159
|
+
if (params.dotLabel) {
|
160
|
+
const dotLabelResult = validateColumns(params.dotLabel, {
|
161
|
+
colorType: {
|
149
162
|
toBeOption: 'ColorType'
|
150
163
|
},
|
151
|
-
|
164
|
+
sizeFixed: {
|
152
165
|
toBeTypes: ['boolean']
|
153
166
|
},
|
154
|
-
|
167
|
+
styleFn: {
|
155
168
|
toBeTypes: ['Function']
|
156
169
|
},
|
157
170
|
})
|
158
|
-
if (
|
159
|
-
return
|
171
|
+
if (dotLabelResult.status === 'error') {
|
172
|
+
return dotLabelResult
|
160
173
|
}
|
161
174
|
}
|
162
|
-
if (params.
|
163
|
-
const
|
164
|
-
|
175
|
+
if (params.arrow) {
|
176
|
+
const arrowResult = validateColumns(params.arrow, {
|
177
|
+
colorType: {
|
165
178
|
toBeOption: 'ColorType'
|
166
179
|
},
|
167
|
-
|
180
|
+
strokeWidth: {
|
168
181
|
toBeTypes: ['number']
|
169
182
|
},
|
170
|
-
|
183
|
+
pointerWidth: {
|
171
184
|
toBeTypes: ['number']
|
172
185
|
},
|
173
|
-
|
186
|
+
pointerHeight: {
|
174
187
|
toBeTypes: ['number']
|
175
188
|
},
|
176
|
-
|
189
|
+
styleFn: {
|
177
190
|
toBeTypes: ['Function']
|
178
191
|
},
|
179
|
-
|
192
|
+
})
|
193
|
+
if (arrowResult.status === 'error') {
|
194
|
+
return arrowResult
|
195
|
+
}
|
196
|
+
}
|
197
|
+
if (params.arrowLabel) {
|
198
|
+
const arrowLabelResult = validateColumns(params.arrowLabel, {
|
199
|
+
colorType: {
|
180
200
|
toBeOption: 'ColorType'
|
181
201
|
},
|
182
|
-
|
202
|
+
sizeFixed: {
|
183
203
|
toBeTypes: ['boolean']
|
184
204
|
},
|
185
|
-
|
205
|
+
styleFn: {
|
186
206
|
toBeTypes: ['Function']
|
187
207
|
},
|
188
208
|
})
|
189
|
-
if (
|
190
|
-
return
|
209
|
+
if (arrowLabelResult.status === 'error') {
|
210
|
+
return arrowLabelResult
|
191
211
|
}
|
192
212
|
}
|
193
213
|
if (params.force) {
|
@@ -263,7 +283,7 @@ function createSimulation (layout: Layout, fullParams: ForceDirectedParams) {
|
|
263
283
|
})
|
264
284
|
)
|
265
285
|
.force("charge", d3.forceManyBody().strength(fullParams.force.nodeStrength))
|
266
|
-
.force("collision", d3.forceCollide(fullParams.
|
286
|
+
.force("collision", d3.forceCollide(fullParams.dot.radius).strength(1))
|
267
287
|
.force("center", d3.forceCenter(layout.width / 2, layout.height / 2))
|
268
288
|
|
269
289
|
}
|
@@ -307,14 +327,10 @@ function renderArrowMarker (defsSelection: d3.Selection<SVGDefsElement, any, any
|
|
307
327
|
.append("marker")
|
308
328
|
.classed(defsArrowMarkerClassName, true)
|
309
329
|
.attr('id', defsArrowMarkerId)
|
310
|
-
|
311
|
-
// .attr("viewBox", d => `0 -${d.edge.arrowHeight / 2} ${d.edge.arrowWidth} ${d.edge.arrowHeight}`)
|
312
|
-
.attr("viewBox", d => `-${d.edge.arrowWidth} -${d.edge.arrowHeight / 2} ${d.edge.arrowWidth} ${d.edge.arrowHeight}`)
|
330
|
+
.attr("viewBox", d => `-${d.arrow.pointerWidth} -${d.arrow.pointerHeight / 2} ${d.arrow.pointerWidth} ${d.arrow.pointerHeight}`)
|
313
331
|
.attr("orient", "auto")
|
314
332
|
enterSelection.append("path")
|
315
|
-
|
316
|
-
// .attr("d", d => `M0,${-d.edge.arrowHeight / 2}L${d.edge.arrowWidth},0L0,${d.edge.arrowHeight / 2}`)
|
317
|
-
.attr("d", d => `M${-d.edge.arrowWidth},${-d.edge.arrowHeight / 2}L0,0L${-d.edge.arrowWidth},${d.edge.arrowHeight / 2}`)
|
333
|
+
.attr("d", d => `M${-d.arrow.pointerWidth},${-d.arrow.pointerHeight / 2}L0,0L${-d.arrow.pointerWidth},${d.arrow.pointerHeight / 2}`) // 箭頭的尖端為(0,0)
|
318
334
|
return enterSelection
|
319
335
|
},
|
320
336
|
update => {
|
@@ -324,16 +340,16 @@ function renderArrowMarker (defsSelection: d3.Selection<SVGDefsElement, any, any
|
|
324
340
|
return exit.remove()
|
325
341
|
}
|
326
342
|
)
|
327
|
-
.attr("markerWidth", d => d.
|
328
|
-
.attr("markerHeight", d => d.
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
343
|
+
.attr("markerWidth", d => d.arrow.pointerWidth)
|
344
|
+
.attr("markerHeight", d => d.arrow.pointerHeight)
|
345
|
+
/* refX:修正marker位置(計算出和circle半徑相等的寬度)
|
346
|
+
(1)circle半徑需加上 strokeWidth/2 是因為框線是以 circle 的邊緣往內及往外擴展,所以 stroke 多出來的寬度是一半而已
|
347
|
+
(2)circle半徑需除以 path 寬度是因為「marker 的位置會受到 path 的stroke-width影響」,所以要進行修正
|
348
|
+
(3)- 1 是要修正奇怪的誤差(不知原因)
|
349
|
+
*/
|
350
|
+
.attr('refX', d => ((d.dot.radius + (fullParams.dot.strokeWidth / 2)) / d.arrow.strokeWidth) - 1)
|
334
351
|
.attr("refY", 0)
|
335
352
|
|
336
|
-
|
337
353
|
}
|
338
354
|
|
339
355
|
// function drag (): d3.DragBehavior<Element, unknown, unknown> {
|
@@ -447,9 +463,8 @@ function renderNodeG ({ nodeListGSelection, nodes }: {
|
|
447
463
|
)
|
448
464
|
}
|
449
465
|
|
450
|
-
function renderNodeCircle ({ nodeGSelection,
|
451
|
-
nodeGSelection: d3.Selection<SVGGElement,
|
452
|
-
nodes: RenderNode[]
|
466
|
+
function renderNodeCircle ({ nodeGSelection, fullParams, fullChartParams }: {
|
467
|
+
nodeGSelection: d3.Selection<SVGGElement, RenderNode, any, unknown>
|
453
468
|
fullParams: ForceDirectedParams
|
454
469
|
fullChartParams: ChartParams
|
455
470
|
}) {
|
@@ -472,18 +487,19 @@ function renderNodeCircle ({ nodeGSelection, nodes, fullParams, fullChartParams
|
|
472
487
|
return exit.remove()
|
473
488
|
}
|
474
489
|
)
|
475
|
-
.attr('r', fullParams.
|
476
|
-
.attr('fill', d => getDatumColor({ datum: d, colorType: fullParams.
|
477
|
-
.attr('stroke', d => getDatumColor({ datum: d, colorType: fullParams.
|
478
|
-
.attr('stroke-width', fullParams.
|
479
|
-
.attr('style', d => fullParams.
|
490
|
+
.attr('r', fullParams.dot.radius)
|
491
|
+
.attr('fill', d => getDatumColor({ datum: d, colorType: fullParams.dot.fillColorType, fullChartParams }))
|
492
|
+
.attr('stroke', d => getDatumColor({ datum: d, colorType: fullParams.dot.strokeColorType, fullChartParams }))
|
493
|
+
.attr('stroke-width', fullParams.dot.strokeWidth)
|
494
|
+
.attr('style', d => fullParams.dot.styleFn(d))
|
480
495
|
})
|
481
496
|
|
482
497
|
return nodeGSelection.select<SVGCircleElement>(`circle.${nodeCircleClassName}`)
|
483
498
|
}
|
484
499
|
|
485
|
-
function renderNodeLabelG ({ nodeGSelection }: {
|
500
|
+
function renderNodeLabelG ({ nodeGSelection, fullParams }: {
|
486
501
|
nodeGSelection: d3.Selection<SVGGElement, any, any, unknown>
|
502
|
+
fullParams: ForceDirectedParams
|
487
503
|
}) {
|
488
504
|
nodeGSelection.each((data,i,g) => {
|
489
505
|
const gSelection = d3.select(g[i])
|
@@ -504,6 +520,7 @@ function renderNodeLabelG ({ nodeGSelection }: {
|
|
504
520
|
return exit.remove()
|
505
521
|
}
|
506
522
|
)
|
523
|
+
.attr('transform', `translate(0, ${- fullParams.dot.radius - 10})`)
|
507
524
|
})
|
508
525
|
|
509
526
|
return nodeGSelection.select<SVGTextElement>(`g.${nodeLabelGClassName}`)
|
@@ -536,9 +553,9 @@ function renderNodeLabel ({ nodeLabelGSelection, fullParams, fullChartParams }:
|
|
536
553
|
}
|
537
554
|
)
|
538
555
|
.text(d => d.label)
|
539
|
-
.attr('fill', d => getDatumColor({ datum: d, colorType: fullParams.
|
556
|
+
.attr('fill', d => getDatumColor({ datum: d, colorType: fullParams.dotLabel.colorType, fullChartParams }))
|
540
557
|
.attr('font-size', fullChartParams.styles.textSize)
|
541
|
-
.attr('style', d => fullParams.
|
558
|
+
.attr('style', d => fullParams.dotLabel.styleFn(d))
|
542
559
|
})
|
543
560
|
|
544
561
|
return nodeLabelGSelection.select<SVGTextElement>(`text.${nodeLabelClassName}`)
|
@@ -568,7 +585,7 @@ function renderEdgeG ({ edgeListGSelection, edges }: {
|
|
568
585
|
}
|
569
586
|
|
570
587
|
function renderEdgeArrowPath ({ edgeGSelection, fullParams, fullChartParams }: {
|
571
|
-
edgeGSelection: d3.Selection<SVGGElement,
|
588
|
+
edgeGSelection: d3.Selection<SVGGElement, RenderEdge, any, unknown>
|
572
589
|
fullParams: ForceDirectedParams
|
573
590
|
fullChartParams: ChartParams
|
574
591
|
}) {
|
@@ -590,9 +607,9 @@ function renderEdgeArrowPath ({ edgeGSelection, fullParams, fullChartParams }: {
|
|
590
607
|
return exit.remove()
|
591
608
|
}
|
592
609
|
)
|
593
|
-
.attr('stroke', d => getDatumColor({ datum: d.data, colorType: fullParams.
|
594
|
-
.attr('stroke-width', fullParams.
|
595
|
-
.attr('style', d => fullParams.
|
610
|
+
.attr('stroke', d => getDatumColor({ datum: d.data, colorType: fullParams.arrow.colorType, fullChartParams }))
|
611
|
+
.attr('stroke-width', fullParams.arrow.strokeWidth)
|
612
|
+
.attr('style', d => fullParams.arrow.styleFn(d))
|
596
613
|
})
|
597
614
|
|
598
615
|
return edgeGSelection.select<SVGPathElement>(`path.${edgeArrowPathClassName}`)
|
@@ -652,9 +669,9 @@ function renderEdgeLabel ({ edgeLabelGSelection, fullParams, fullChartParams }:
|
|
652
669
|
}
|
653
670
|
)
|
654
671
|
.text(d => d.label)
|
655
|
-
.attr('fill', d => getDatumColor({ datum: d, colorType: fullParams.
|
672
|
+
.attr('fill', d => getDatumColor({ datum: d, colorType: fullParams.arrowLabel.colorType, fullChartParams }))
|
656
673
|
.attr('font-size', fullChartParams.styles.textSize)
|
657
|
-
.attr('style', d => fullParams.
|
674
|
+
.attr('style', d => fullParams.arrowLabel.styleFn(d))
|
658
675
|
})
|
659
676
|
|
660
677
|
return edgeLabelGSelection.select<SVGTextElement>(`text.${edgeLabelClassName}`)
|
@@ -868,7 +885,7 @@ export const ForceDirected = defineRelationshipPlugin(pluginConfig)(({ selection
|
|
868
885
|
const dragStatus$ = new BehaviorSubject<DragStatus>('end') // start, drag, end
|
869
886
|
const mouseEvent$ = new Subject<EventRelationship>()
|
870
887
|
|
871
|
-
//
|
888
|
+
// <marker> marker selection
|
872
889
|
observer.fullParams$.pipe(
|
873
890
|
takeUntil(destroy$),
|
874
891
|
map(fullParams => {
|
@@ -899,11 +916,11 @@ export const ForceDirected = defineRelationshipPlugin(pluginConfig)(({ selection
|
|
899
916
|
${event.transform.k}
|
900
917
|
)`)
|
901
918
|
|
902
|
-
if (data.
|
919
|
+
if (data.dotLabel.sizeFixed && nodeLabelSelection) {
|
903
920
|
// 反向 scale 抵消掉放大縮小
|
904
921
|
nodeLabelSelection.attr('transform', `scale(${1 / event.transform.k})`)
|
905
922
|
}
|
906
|
-
if (data.
|
923
|
+
if (data.arrowLabel.sizeFixed && edgeLabelSelection) {
|
907
924
|
// 反向 scale 抵消掉放大縮小
|
908
925
|
edgeLabelSelection.attr('transform', `scale(${1 / event.transform.k})`)
|
909
926
|
}
|
@@ -946,6 +963,7 @@ export const ForceDirected = defineRelationshipPlugin(pluginConfig)(({ selection
|
|
946
963
|
fullParams: observer.fullParams$
|
947
964
|
}).pipe(
|
948
965
|
takeUntil(destroy$),
|
966
|
+
switchMap(async d => d),
|
949
967
|
map(data => createSimulation(data.layout, data.fullParams)),
|
950
968
|
shareReplay(1)
|
951
969
|
)
|
@@ -962,7 +980,8 @@ export const ForceDirected = defineRelationshipPlugin(pluginConfig)(({ selection
|
|
962
980
|
return d
|
963
981
|
})
|
964
982
|
}
|
965
|
-
})
|
983
|
+
}),
|
984
|
+
shareReplay(1)
|
966
985
|
)
|
967
986
|
|
968
987
|
combineLatest({
|
@@ -984,7 +1003,6 @@ export const ForceDirected = defineRelationshipPlugin(pluginConfig)(({ selection
|
|
984
1003
|
|
985
1004
|
nodeCircleSelection = renderNodeCircle({
|
986
1005
|
nodeGSelection: nodeGSelection,
|
987
|
-
nodes: data.renderData.nodes,
|
988
1006
|
fullParams: data.fullParams,
|
989
1007
|
fullChartParams: data.fullChartParams
|
990
1008
|
})
|
@@ -992,6 +1010,7 @@ export const ForceDirected = defineRelationshipPlugin(pluginConfig)(({ selection
|
|
992
1010
|
|
993
1011
|
nodeLabelGSelection = renderNodeLabelG({
|
994
1012
|
nodeGSelection: nodeGSelection,
|
1013
|
+
fullParams: data.fullParams
|
995
1014
|
})
|
996
1015
|
|
997
1016
|
nodeLabelSelection = renderNodeLabel({
|
@@ -1024,11 +1043,11 @@ export const ForceDirected = defineRelationshipPlugin(pluginConfig)(({ selection
|
|
1024
1043
|
data.simulation.nodes(data.renderData.nodes)
|
1025
1044
|
.on('tick', () => {
|
1026
1045
|
edgeArrowSelection.attr('d', linkArcFn)
|
1027
|
-
|
1028
|
-
nodeLabelGSelection.attr('transform', d => translateFn({
|
1029
|
-
|
1030
|
-
|
1031
|
-
}))
|
1046
|
+
nodeGSelection.attr('transform', translateFn)
|
1047
|
+
// nodeLabelGSelection.attr('transform', d => translateFn({
|
1048
|
+
// x: d.x,
|
1049
|
+
// y: d.y - data.fullParams.dot.radius - 10
|
1050
|
+
// }))
|
1032
1051
|
edgeLabelGSelection.attr('transform', d => translateCenterFn(d))
|
1033
1052
|
})
|
1034
1053
|
;(data.simulation.force("link") as any).links(data.renderData.edges)
|