@orbcharts/plugins-basic 3.0.0-beta.8 → 3.0.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/dist/orbcharts-plugins-basic.es.js +13170 -10984
- package/dist/orbcharts-plugins-basic.umd.js +266 -98
- package/dist/{orbcharts-plugins-basic/src → src}/base/BaseBars.d.ts +3 -3
- package/dist/{orbcharts-plugins-basic/src → src}/base/BaseBarsTriangle.d.ts +3 -3
- package/dist/{orbcharts-plugins-basic/src → src}/base/BaseDots.d.ts +3 -3
- package/dist/{orbcharts-plugins-basic/src → src}/base/BaseLineAreas.d.ts +3 -3
- package/dist/{orbcharts-plugins-basic/src → src}/base/BaseLines.d.ts +3 -3
- package/dist/src/base/BaseRacingBars.d.ts +23 -0
- package/dist/src/base/BaseRacingLabels.d.ts +20 -0
- package/dist/src/base/BaseRacingValueLabels.d.ts +20 -0
- package/dist/{orbcharts-plugins-basic/src/base/BaseStackedBar.d.ts → src/base/BaseStackedBars.d.ts} +7 -7
- package/dist/{orbcharts-plugins-basic/src → src}/base/BaseValueAxis.d.ts +4 -7
- package/dist/src/base/BaseXAxis.d.ts +20 -0
- package/dist/src/base/BaseYAxis.d.ts +18 -0
- package/dist/{orbcharts-plugins-basic/src → src}/grid/defaults.d.ts +3 -3
- package/dist/{orbcharts-plugins-basic/src → src}/grid/gridObservables.d.ts +8 -1
- package/dist/{orbcharts-plugins-basic/src → src}/grid/index.d.ts +2 -2
- package/dist/src/grid/plugins/GroupZoom.d.ts +1 -0
- package/dist/src/grid/plugins/StackedBars.d.ts +1 -0
- package/dist/src/index.d.ts +7 -1
- package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/defaults.d.ts +2 -2
- package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/index.d.ts +1 -1
- package/dist/src/multiGrid/plugins/MultiStackedBars.d.ts +1 -0
- package/dist/src/multiValue/defaults.d.ts +13 -0
- package/dist/{orbcharts-plugins-basic/src → src}/multiValue/index.d.ts +5 -1
- package/dist/src/multiValue/multiValueObservables.d.ts +56 -0
- package/dist/src/multiValue/plugins/RacingBars.d.ts +1 -0
- package/dist/src/multiValue/plugins/RacingCounterTexts.d.ts +3 -0
- package/dist/src/multiValue/plugins/RacingValueAxis.d.ts +1 -0
- package/dist/src/multiValue/plugins/XAxis.d.ts +1 -0
- package/dist/src/multiValue/plugins/XYAxes.d.ts +1 -0
- package/dist/src/multiValue/plugins/XZoom.d.ts +1 -0
- package/dist/{orbcharts-plugins-basic/src → src}/relationship/defaults.d.ts +2 -1
- package/dist/{orbcharts-plugins-basic/src → src}/relationship/index.d.ts +1 -0
- package/dist/src/relationship/plugins/ForceDirectedBubbles.d.ts +3 -0
- package/dist/{orbcharts-plugins-basic/src → src}/utils/commonUtils.d.ts +1 -0
- package/dist/{orbcharts-plugins-basic/src → src}/utils/d3Graphics.d.ts +2 -1
- package/dist/{orbcharts-plugins-basic/src → src}/utils/d3Utils.d.ts +1 -0
- package/lib/core.ts +1 -1
- package/package.json +4 -4
- package/src/base/BaseBars.ts +15 -15
- package/src/base/BaseBarsTriangle.ts +15 -15
- package/src/base/BaseDots.ts +14 -14
- package/src/base/BaseGroupAxis.ts +18 -6
- package/src/base/BaseLineAreas.ts +12 -12
- package/src/base/BaseLines.ts +11 -11
- package/src/base/BaseRacingBars.ts +552 -0
- package/src/base/BaseRacingLabels.ts +396 -0
- package/src/base/BaseRacingValueLabels.ts +403 -0
- package/src/base/{BaseStackedBar.ts → BaseStackedBars.ts} +26 -26
- package/src/base/BaseTooltip.ts +2 -1
- package/src/base/BaseValueAxis.ts +70 -53
- package/src/base/BaseXAxis.ts +427 -0
- package/src/base/BaseYAxis.ts +389 -0
- package/src/grid/defaults.ts +44 -77
- package/src/grid/gridObservables.ts +58 -0
- package/src/grid/index.ts +2 -2
- package/src/grid/plugins/Bars.ts +2 -2
- package/src/grid/plugins/BarsPN.ts +2 -2
- package/src/grid/plugins/BarsTriangle.ts +2 -2
- package/src/grid/plugins/Dots.ts +2 -2
- package/src/grid/plugins/GridLegend.ts +7 -7
- package/src/grid/plugins/GroupAux.ts +41 -24
- package/src/grid/plugins/GroupAxis.ts +0 -24
- package/src/grid/plugins/{GridZoom.ts → GroupZoom.ts} +5 -5
- package/src/grid/plugins/LineAreas.ts +2 -2
- package/src/grid/plugins/Lines.ts +2 -2
- package/src/grid/plugins/{StackedBar.ts → StackedBars.ts} +9 -9
- package/src/multiGrid/defaults.ts +44 -24
- package/src/multiGrid/index.ts +1 -1
- package/src/multiGrid/multiGridObservables.ts +1 -0
- package/src/multiGrid/plugins/MultiBars.ts +3 -3
- package/src/multiGrid/plugins/MultiBarsTriangle.ts +3 -3
- package/src/multiGrid/plugins/MultiDots.ts +3 -3
- package/src/multiGrid/plugins/MultiGridLegend.ts +20 -10
- package/src/multiGrid/plugins/MultiLineAreas.ts +3 -3
- package/src/multiGrid/plugins/MultiLines.ts +3 -3
- package/src/multiGrid/plugins/{MultiStackedBar.ts → MultiStackedBars.ts} +10 -10
- package/src/multiGrid/plugins/OverlappingStackedValueAxes.ts +1 -0
- package/src/multiValue/defaults.ts +277 -12
- package/src/multiValue/index.ts +5 -1
- package/src/multiValue/multiValueObservables.ts +414 -44
- package/src/multiValue/plugins/OrdinalXAxis.ts +0 -0
- package/src/multiValue/plugins/RacingBars.ts +373 -0
- package/src/multiValue/plugins/RacingCounterAxis.ts +0 -0
- package/src/multiValue/plugins/RacingCounterTexts.ts +300 -0
- package/src/multiValue/plugins/RacingValueAxis.ts +115 -0
- package/src/multiValue/plugins/RankingAxis_legacy.ts +109 -0
- package/src/multiValue/plugins/Scatter.ts +13 -13
- package/src/multiValue/plugins/ScatterBubbles.ts +13 -13
- package/src/multiValue/plugins/XAxis.ts +108 -0
- package/src/multiValue/plugins/XYAux.ts +15 -14
- package/src/multiValue/plugins/XYAxes.ts +38 -528
- package/src/multiValue/plugins/XYAxes_legacy.ts +684 -0
- package/src/multiValue/plugins/{XYZoom.ts → XZoom.ts} +17 -17
- package/src/relationship/defaults.ts +129 -20
- package/src/relationship/index.ts +1 -0
- package/src/relationship/plugins/ForceDirected.ts +113 -87
- package/src/relationship/plugins/ForceDirectedBubbles.ts +1412 -0
- package/src/series/defaults.ts +52 -37
- package/src/series/plugins/Bubbles.ts +71 -39
- package/src/series/plugins/Pie.ts +5 -5
- package/src/series/plugins/PieEventTexts.ts +3 -3
- package/src/series/plugins/PieLabels.ts +5 -5
- package/src/series/plugins/Rose.ts +11 -11
- package/src/series/plugins/RoseLabels.ts +9 -9
- package/src/tree/defaults.ts +46 -22
- package/src/tree/plugins/TreeMap.ts +11 -3
- package/src/utils/commonUtils.ts +10 -1
- package/src/utils/d3Graphics.ts +4 -2
- package/src/utils/d3Utils.ts +18 -0
- package/src/utils/orbchartsUtils.ts +30 -16
- package/dist/orbcharts-plugins-basic/src/grid/plugins/GridZoom.d.ts +0 -1
- package/dist/orbcharts-plugins-basic/src/grid/plugins/StackedBar.d.ts +0 -1
- package/dist/orbcharts-plugins-basic/src/index.d.ts +0 -7
- package/dist/orbcharts-plugins-basic/src/multiGrid/plugins/MultiStackedBar.d.ts +0 -1
- package/dist/orbcharts-plugins-basic/src/multiValue/defaults.d.ts +0 -9
- package/dist/orbcharts-plugins-basic/src/multiValue/multiValueObservables.d.ts +0 -33
- package/dist/orbcharts-plugins-basic/src/multiValue/plugins/XYZoom.d.ts +0 -1
- /package/dist/{orbcharts-plugins-basic/lib → lib}/core-types.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/lib → lib}/core.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/lib → lib}/plugins-basic-types.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/base/BaseGroupAxis.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/base/BaseLegend.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/base/BaseTooltip.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/base/types.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/const.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/Bars.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/BarsPN.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/BarsTriangle.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/Dots.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/GridLegend.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/GridTooltip.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/GroupAux.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/GroupAxis.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/LineAreas.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/Lines.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/StackedValueAxis.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/ValueAxis.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/multiGridObservables.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/MultiBars.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/MultiBarsTriangle.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/MultiDots.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/MultiGridLegend.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/MultiGridTooltip.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/MultiGroupAxis.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/MultiLineAreas.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/MultiLines.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/MultiStackedValueAxis.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/MultiValueAxis.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/OverlappingStackedValueAxes.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/OverlappingValueAxes.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiValue/plugins/MultiValueLegend.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiValue/plugins/MultiValueTooltip.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src/multiValue/plugins/Ranking.d.ts → src/multiValue/plugins/OrdinalBubbles.d.ts} +0 -0
- /package/dist/{orbcharts-plugins-basic/src/multiValue/plugins/RankingAxis.d.ts → src/multiValue/plugins/OrdinalXAxis.d.ts} +0 -0
- /package/dist/{orbcharts-plugins-basic/src/noneData/plugins/Container.d.ts → src/multiValue/plugins/RacingCounterAxis.d.ts} +0 -0
- /package/dist/{orbcharts-plugins-basic/src/noneData/plugins/Tooltip.d.ts → src/multiValue/plugins/RankingAxis_legacy.d.ts} +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiValue/plugins/Scatter.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiValue/plugins/ScatterBubbles.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiValue/plugins/XYAux.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src/multiValue/plugins/XYAxes.d.ts → src/multiValue/plugins/XYAxes_legacy.d.ts} +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/noneData/defaults.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/noneData/index.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src/relationship/plugins/ForceDirectedBubbles.d.ts → src/noneData/plugins/Container.d.ts} +0 -0
- /package/dist/{orbcharts-plugins-basic/src/series/plugins/Waffle.d.ts → src/noneData/plugins/Tooltip.d.ts} +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/relationship/plugins/ForceDirected.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/relationship/plugins/RelationshipLegend.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/relationship/plugins/RelationshipTooltip.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/relationship/relationshipObservables.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/series/defaults.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/series/index.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/series/plugins/Bubbles.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/series/plugins/Pie.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/series/plugins/PieEventTexts.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/series/plugins/PieLabels.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/series/plugins/Rose.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/series/plugins/RoseLabels.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/series/plugins/SeriesLegend.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/series/plugins/SeriesTooltip.d.ts +0 -0
- /package/{src/multiValue/plugins/Ranking.ts → dist/src/series/plugins/Waffle.d.ts} +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/series/seriesObservables.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/series/seriesUtils.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/tree/defaults.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/tree/index.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/tree/plugins/TreeLegend.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/tree/plugins/TreeMap.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/tree/plugins/TreeTooltip.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/utils/observables.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/utils/orbchartsUtils.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/vite.config.d.ts → vite.config.d.ts} +0 -0
- /package/src/multiValue/plugins/{RankingAxis.ts → OrdinalBubbles.ts} +0 -0
@@ -33,7 +33,7 @@ import type {
|
|
33
33
|
import {
|
34
34
|
defineRelationshipPlugin } from '../../../lib/core'
|
35
35
|
import type { BubblesParams, ArcScaleType, ForceDirectedParams } from '../../../lib/plugins-basic-types'
|
36
|
-
import { getDatumColor, getClassName, getUniID } from '../../utils/orbchartsUtils'
|
36
|
+
import { getColor, getDatumColor, getClassName, getUniID } from '../../utils/orbchartsUtils'
|
37
37
|
import { DEFAULT_FORCE_DIRECTED_PARAMS } from '../defaults'
|
38
38
|
// import { renderCircleText } from '../../utils/d3Graphics'
|
39
39
|
import { LAYER_INDEX_OF_GRAPHIC } from '../../const'
|
@@ -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
|
}
|
@@ -283,7 +303,7 @@ function translateCenterFn (d: any): string {
|
|
283
303
|
function linkArcFn (d: RenderEdge): string {
|
284
304
|
// console.log('linkArcFn', d)
|
285
305
|
|
286
|
-
//
|
306
|
+
// const dx = d.target.x - d.source.x,
|
287
307
|
// dy = d.target.y - d.source.y
|
288
308
|
// dr讓方向線變成有弧度的
|
289
309
|
// dr = Math.sqrt(dx * dx + dy * dy);
|
@@ -297,7 +317,7 @@ function linkArcFn (d: RenderEdge): string {
|
|
297
317
|
|
298
318
|
|
299
319
|
|
300
|
-
function renderArrowMarker (defsSelection: d3.Selection<SVGDefsElement, any, any, unknown>, fullParams: ForceDirectedParams) {
|
320
|
+
function renderArrowMarker (defsSelection: d3.Selection<SVGDefsElement, any, any, unknown>, fullParams: ForceDirectedParams, fullChartParams: ChartParams) {
|
301
321
|
return defsSelection
|
302
322
|
.selectAll<SVGMarkerElement, any>(`marker.${defsArrowMarkerClassName}`)
|
303
323
|
.data([fullParams])
|
@@ -307,14 +327,11 @@ function renderArrowMarker (defsSelection: d3.Selection<SVGDefsElement, any, any
|
|
307
327
|
.append("marker")
|
308
328
|
.classed(defsArrowMarkerClassName, true)
|
309
329
|
.attr('id', defsArrowMarkerId)
|
310
|
-
|
311
|
-
|
312
|
-
.attr("viewBox", d => `-${d.edge.arrowWidth} -${d.edge.arrowHeight / 2} ${d.edge.arrowWidth} ${d.edge.arrowHeight}`)
|
330
|
+
.attr('fill', d => getColor(fullParams.arrow.colorType, fullChartParams ))
|
331
|
+
.attr("viewBox", d => `-${d.arrow.pointerWidth} -${d.arrow.pointerHeight / 2} ${d.arrow.pointerWidth} ${d.arrow.pointerHeight}`)
|
313
332
|
.attr("orient", "auto")
|
314
333
|
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}`)
|
334
|
+
.attr("d", d => `M${-d.arrow.pointerWidth},${-d.arrow.pointerHeight / 2}L0,0L${-d.arrow.pointerWidth},${d.arrow.pointerHeight / 2}`) // 箭頭的尖端為(0,0)
|
318
335
|
return enterSelection
|
319
336
|
},
|
320
337
|
update => {
|
@@ -324,16 +341,16 @@ function renderArrowMarker (defsSelection: d3.Selection<SVGDefsElement, any, any
|
|
324
341
|
return exit.remove()
|
325
342
|
}
|
326
343
|
)
|
327
|
-
.attr("markerWidth", d => d.
|
328
|
-
.attr("markerHeight", d => d.
|
329
|
-
|
330
|
-
|
331
|
-
|
332
|
-
|
333
|
-
|
344
|
+
.attr("markerWidth", d => d.arrow.pointerWidth)
|
345
|
+
.attr("markerHeight", d => d.arrow.pointerHeight)
|
346
|
+
/* refX:修正marker位置(計算出和circle半徑相等的寬度)
|
347
|
+
(1)circle半徑需加上 strokeWidth/2 是因為框線是以 circle 的邊緣往內及往外擴展,所以 stroke 多出來的寬度是一半而已
|
348
|
+
(2)circle半徑需除以 path 寬度是因為「marker 的位置會受到 path 的stroke-width影響」,所以要進行修正
|
349
|
+
(3)- 1 是要修正奇怪的誤差(不知原因)
|
350
|
+
*/
|
351
|
+
.attr('refX', d => ((d.dot.radius + (fullParams.dot.strokeWidth / 2)) / d.arrow.strokeWidth) - 1)
|
334
352
|
.attr("refY", 0)
|
335
353
|
|
336
|
-
|
337
354
|
}
|
338
355
|
|
339
356
|
// function drag (): d3.DragBehavior<Element, unknown, unknown> {
|
@@ -395,25 +412,25 @@ function renderArrowMarker (defsSelection: d3.Selection<SVGDefsElement, any, any
|
|
395
412
|
// }
|
396
413
|
|
397
414
|
function drag (simulation: d3.Simulation<d3.SimulationNodeDatum, undefined>, dragStatus$: BehaviorSubject<DragStatus>) {
|
398
|
-
function dragstarted (event: D3DragEvent) {
|
399
|
-
if (!event.active) simulation.alphaTarget(0.3).restart()
|
400
|
-
event.subject.fx = event.
|
401
|
-
event.subject.fy = event.
|
415
|
+
function dragstarted (event: D3DragEvent, node: RenderNode) {
|
416
|
+
if (!event.active) simulation.alphaTarget(0.3).restart()
|
417
|
+
event.subject.fx = event.x
|
418
|
+
event.subject.fy = event.y
|
402
419
|
|
403
420
|
dragStatus$.next('start')
|
404
421
|
}
|
405
422
|
|
406
|
-
function dragged (event: D3DragEvent) {
|
407
|
-
event.subject.fx = event.x
|
408
|
-
event.subject.fy = event.y
|
423
|
+
function dragged (event: D3DragEvent, node: RenderNode) {
|
424
|
+
event.subject.fx = event.x
|
425
|
+
event.subject.fy = event.y
|
409
426
|
|
410
427
|
dragStatus$.next('drag')
|
411
428
|
}
|
412
429
|
|
413
|
-
function dragended (event: D3DragEvent) {
|
430
|
+
function dragended (event: D3DragEvent, node: RenderNode) {
|
414
431
|
if (!event.active) simulation.alphaTarget(0);
|
415
|
-
event.subject.fx = null
|
416
|
-
event.subject.fy = null
|
432
|
+
event.subject.fx = null
|
433
|
+
event.subject.fy = null
|
417
434
|
|
418
435
|
dragStatus$.next('end')
|
419
436
|
}
|
@@ -421,7 +438,7 @@ function drag (simulation: d3.Simulation<d3.SimulationNodeDatum, undefined>, dra
|
|
421
438
|
return d3.drag()
|
422
439
|
.on("start", dragstarted)
|
423
440
|
.on("drag", dragged)
|
424
|
-
.on("end", dragended)
|
441
|
+
.on("end", dragended)
|
425
442
|
}
|
426
443
|
|
427
444
|
function renderNodeG ({ nodeListGSelection, nodes }: {
|
@@ -447,9 +464,8 @@ function renderNodeG ({ nodeListGSelection, nodes }: {
|
|
447
464
|
)
|
448
465
|
}
|
449
466
|
|
450
|
-
function renderNodeCircle ({ nodeGSelection,
|
451
|
-
nodeGSelection: d3.Selection<SVGGElement,
|
452
|
-
nodes: RenderNode[]
|
467
|
+
function renderNodeCircle ({ nodeGSelection, fullParams, fullChartParams }: {
|
468
|
+
nodeGSelection: d3.Selection<SVGGElement, RenderNode, any, unknown>
|
453
469
|
fullParams: ForceDirectedParams
|
454
470
|
fullChartParams: ChartParams
|
455
471
|
}) {
|
@@ -472,18 +488,19 @@ function renderNodeCircle ({ nodeGSelection, nodes, fullParams, fullChartParams
|
|
472
488
|
return exit.remove()
|
473
489
|
}
|
474
490
|
)
|
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.
|
491
|
+
.attr('r', fullParams.dot.radius)
|
492
|
+
.attr('fill', d => getDatumColor({ datum: d, colorType: fullParams.dot.fillColorType, fullChartParams }))
|
493
|
+
.attr('stroke', d => getDatumColor({ datum: d, colorType: fullParams.dot.strokeColorType, fullChartParams }))
|
494
|
+
.attr('stroke-width', fullParams.dot.strokeWidth)
|
495
|
+
.attr('style', d => fullParams.dot.styleFn(d))
|
480
496
|
})
|
481
497
|
|
482
498
|
return nodeGSelection.select<SVGCircleElement>(`circle.${nodeCircleClassName}`)
|
483
499
|
}
|
484
500
|
|
485
|
-
function renderNodeLabelG ({ nodeGSelection }: {
|
501
|
+
function renderNodeLabelG ({ nodeGSelection, fullParams }: {
|
486
502
|
nodeGSelection: d3.Selection<SVGGElement, any, any, unknown>
|
503
|
+
fullParams: ForceDirectedParams
|
487
504
|
}) {
|
488
505
|
nodeGSelection.each((data,i,g) => {
|
489
506
|
const gSelection = d3.select(g[i])
|
@@ -504,6 +521,7 @@ function renderNodeLabelG ({ nodeGSelection }: {
|
|
504
521
|
return exit.remove()
|
505
522
|
}
|
506
523
|
)
|
524
|
+
.attr('transform', `translate(0, ${- fullParams.dot.radius - 10})`)
|
507
525
|
})
|
508
526
|
|
509
527
|
return nodeGSelection.select<SVGTextElement>(`g.${nodeLabelGClassName}`)
|
@@ -536,9 +554,9 @@ function renderNodeLabel ({ nodeLabelGSelection, fullParams, fullChartParams }:
|
|
536
554
|
}
|
537
555
|
)
|
538
556
|
.text(d => d.label)
|
539
|
-
.attr('fill', d => getDatumColor({ datum: d, colorType: fullParams.
|
557
|
+
.attr('fill', d => getDatumColor({ datum: d, colorType: fullParams.dotLabel.colorType, fullChartParams }))
|
540
558
|
.attr('font-size', fullChartParams.styles.textSize)
|
541
|
-
.attr('style', d => fullParams.
|
559
|
+
.attr('style', d => fullParams.dotLabel.styleFn(d))
|
542
560
|
})
|
543
561
|
|
544
562
|
return nodeLabelGSelection.select<SVGTextElement>(`text.${nodeLabelClassName}`)
|
@@ -568,7 +586,7 @@ function renderEdgeG ({ edgeListGSelection, edges }: {
|
|
568
586
|
}
|
569
587
|
|
570
588
|
function renderEdgeArrowPath ({ edgeGSelection, fullParams, fullChartParams }: {
|
571
|
-
edgeGSelection: d3.Selection<SVGGElement,
|
589
|
+
edgeGSelection: d3.Selection<SVGGElement, RenderEdge, any, unknown>
|
572
590
|
fullParams: ForceDirectedParams
|
573
591
|
fullChartParams: ChartParams
|
574
592
|
}) {
|
@@ -590,9 +608,9 @@ function renderEdgeArrowPath ({ edgeGSelection, fullParams, fullChartParams }: {
|
|
590
608
|
return exit.remove()
|
591
609
|
}
|
592
610
|
)
|
593
|
-
.attr('stroke', d => getDatumColor({ datum: d.data, colorType: fullParams.
|
594
|
-
.attr('stroke-width', fullParams.
|
595
|
-
.attr('style', d => fullParams.
|
611
|
+
.attr('stroke', d => getDatumColor({ datum: d.data, colorType: fullParams.arrow.colorType, fullChartParams }))
|
612
|
+
.attr('stroke-width', fullParams.arrow.strokeWidth)
|
613
|
+
.attr('style', d => fullParams.arrow.styleFn(d))
|
596
614
|
})
|
597
615
|
|
598
616
|
return edgeGSelection.select<SVGPathElement>(`path.${edgeArrowPathClassName}`)
|
@@ -652,9 +670,9 @@ function renderEdgeLabel ({ edgeLabelGSelection, fullParams, fullChartParams }:
|
|
652
670
|
}
|
653
671
|
)
|
654
672
|
.text(d => d.label)
|
655
|
-
.attr('fill', d => getDatumColor({ datum: d, colorType: fullParams.
|
673
|
+
.attr('fill', d => getDatumColor({ datum: d, colorType: fullParams.arrowLabel.colorType, fullChartParams }))
|
656
674
|
.attr('font-size', fullChartParams.styles.textSize)
|
657
|
-
.attr('style', d => fullParams.
|
675
|
+
.attr('style', d => fullParams.arrowLabel.styleFn(d))
|
658
676
|
})
|
659
677
|
|
660
678
|
return edgeLabelGSelection.select<SVGTextElement>(`text.${edgeLabelClassName}`)
|
@@ -719,7 +737,7 @@ function renderEdgeLabel ({ edgeLabelGSelection, fullParams, fullChartParams }:
|
|
719
737
|
// .each((d,i,g) => {
|
720
738
|
// const gSelection = d3.select(g[i])
|
721
739
|
// let breakAll = true
|
722
|
-
// if (d[textDataColumn].length <= fullParams.label.
|
740
|
+
// if (d[textDataColumn].length <= fullParams.label.maxLineLength) {
|
723
741
|
// breakAll = false
|
724
742
|
// }
|
725
743
|
// gSelection.call(renderCircleText, {
|
@@ -784,6 +802,7 @@ function highlightNodes ({ nodeGSelection, edgeGSelection, highlightIds, fullCha
|
|
784
802
|
highlightIds: string[]
|
785
803
|
}) {
|
786
804
|
nodeGSelection.interrupt('highlight')
|
805
|
+
edgeGSelection.interrupt('highlight')
|
787
806
|
// console.log(highlightIds)
|
788
807
|
if (!highlightIds.length) {
|
789
808
|
nodeGSelection
|
@@ -868,11 +887,15 @@ export const ForceDirected = defineRelationshipPlugin(pluginConfig)(({ selection
|
|
868
887
|
const dragStatus$ = new BehaviorSubject<DragStatus>('end') // start, drag, end
|
869
888
|
const mouseEvent$ = new Subject<EventRelationship>()
|
870
889
|
|
871
|
-
//
|
872
|
-
|
890
|
+
// <marker> marker selection
|
891
|
+
combineLatest({
|
892
|
+
fullParams: observer.fullParams$,
|
893
|
+
fullChartParams: observer.fullChartParams$
|
894
|
+
}).pipe(
|
873
895
|
takeUntil(destroy$),
|
874
|
-
|
875
|
-
|
896
|
+
switchMap(async d => d),
|
897
|
+
map(({ fullParams, fullChartParams }) => {
|
898
|
+
return renderArrowMarker(defsSelection, fullParams, fullChartParams)
|
876
899
|
})
|
877
900
|
).subscribe()
|
878
901
|
|
@@ -899,11 +922,11 @@ export const ForceDirected = defineRelationshipPlugin(pluginConfig)(({ selection
|
|
899
922
|
${event.transform.k}
|
900
923
|
)`)
|
901
924
|
|
902
|
-
if (data.
|
925
|
+
if (data.dotLabel.sizeFixed && nodeLabelSelection) {
|
903
926
|
// 反向 scale 抵消掉放大縮小
|
904
927
|
nodeLabelSelection.attr('transform', `scale(${1 / event.transform.k})`)
|
905
928
|
}
|
906
|
-
if (data.
|
929
|
+
if (data.arrowLabel.sizeFixed && edgeLabelSelection) {
|
907
930
|
// 反向 scale 抵消掉放大縮小
|
908
931
|
edgeLabelSelection.attr('transform', `scale(${1 / event.transform.k})`)
|
909
932
|
}
|
@@ -946,6 +969,7 @@ export const ForceDirected = defineRelationshipPlugin(pluginConfig)(({ selection
|
|
946
969
|
fullParams: observer.fullParams$
|
947
970
|
}).pipe(
|
948
971
|
takeUntil(destroy$),
|
972
|
+
switchMap(async d => d),
|
949
973
|
map(data => createSimulation(data.layout, data.fullParams)),
|
950
974
|
shareReplay(1)
|
951
975
|
)
|
@@ -962,7 +986,8 @@ export const ForceDirected = defineRelationshipPlugin(pluginConfig)(({ selection
|
|
962
986
|
return d
|
963
987
|
})
|
964
988
|
}
|
965
|
-
})
|
989
|
+
}),
|
990
|
+
shareReplay(1)
|
966
991
|
)
|
967
992
|
|
968
993
|
combineLatest({
|
@@ -984,14 +1009,14 @@ export const ForceDirected = defineRelationshipPlugin(pluginConfig)(({ selection
|
|
984
1009
|
|
985
1010
|
nodeCircleSelection = renderNodeCircle({
|
986
1011
|
nodeGSelection: nodeGSelection,
|
987
|
-
nodes: data.renderData.nodes,
|
988
1012
|
fullParams: data.fullParams,
|
989
1013
|
fullChartParams: data.fullChartParams
|
990
1014
|
})
|
991
|
-
|
1015
|
+
nodeGSelection.call(drag(data.simulation, dragStatus$))
|
992
1016
|
|
993
1017
|
nodeLabelGSelection = renderNodeLabelG({
|
994
1018
|
nodeGSelection: nodeGSelection,
|
1019
|
+
fullParams: data.fullParams
|
995
1020
|
})
|
996
1021
|
|
997
1022
|
nodeLabelSelection = renderNodeLabel({
|
@@ -1024,11 +1049,11 @@ export const ForceDirected = defineRelationshipPlugin(pluginConfig)(({ selection
|
|
1024
1049
|
data.simulation.nodes(data.renderData.nodes)
|
1025
1050
|
.on('tick', () => {
|
1026
1051
|
edgeArrowSelection.attr('d', linkArcFn)
|
1027
|
-
|
1028
|
-
nodeLabelGSelection.attr('transform', d => translateFn({
|
1029
|
-
|
1030
|
-
|
1031
|
-
}))
|
1052
|
+
nodeGSelection.attr('transform', translateFn)
|
1053
|
+
// nodeLabelGSelection.attr('transform', d => translateFn({
|
1054
|
+
// x: d.x,
|
1055
|
+
// y: d.y - data.fullParams.dot.radius - 10
|
1056
|
+
// }))
|
1032
1057
|
edgeLabelGSelection.attr('transform', d => translateCenterFn(d))
|
1033
1058
|
})
|
1034
1059
|
;(data.simulation.force("link") as any).links(data.renderData.edges)
|
@@ -1103,6 +1128,7 @@ export const ForceDirected = defineRelationshipPlugin(pluginConfig)(({ selection
|
|
1103
1128
|
})
|
1104
1129
|
|
1105
1130
|
dragStatus$.pipe(
|
1131
|
+
distinctUntilChanged((a, b) => a === b),
|
1106
1132
|
// 只有沒有托曳時才執行
|
1107
1133
|
switchMap(d => iif(() => d === 'end', mouseEvent$, EMPTY))
|
1108
1134
|
).subscribe(data => {
|