@orbcharts/plugins-basic 3.0.0-beta.1 → 3.0.0-beta.11

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.
Files changed (181) hide show
  1. package/dist/{src → orbcharts-plugins-basic/src}/base/BaseBars.d.ts +2 -2
  2. package/dist/{src → orbcharts-plugins-basic/src}/base/BaseBarsTriangle.d.ts +2 -2
  3. package/dist/{src → orbcharts-plugins-basic/src}/base/BaseDots.d.ts +2 -2
  4. package/dist/{src → orbcharts-plugins-basic/src}/base/BaseGroupAxis.d.ts +2 -2
  5. package/dist/{src → orbcharts-plugins-basic/src}/base/BaseLegend.d.ts +1 -1
  6. package/dist/{src → orbcharts-plugins-basic/src}/base/BaseLineAreas.d.ts +3 -3
  7. package/dist/{src → orbcharts-plugins-basic/src}/base/BaseLines.d.ts +3 -3
  8. package/dist/{src/base/BaseBarStack.d.ts → orbcharts-plugins-basic/src/base/BaseStackedBar.d.ts} +6 -6
  9. package/dist/{src → orbcharts-plugins-basic/src}/base/BaseValueAxis.d.ts +3 -2
  10. package/dist/{src → orbcharts-plugins-basic/src}/grid/defaults.d.ts +4 -4
  11. package/dist/{src → orbcharts-plugins-basic/src}/grid/gridObservables.d.ts +5 -5
  12. package/dist/{src → orbcharts-plugins-basic/src}/grid/index.d.ts +2 -2
  13. package/dist/orbcharts-plugins-basic/src/grid/plugins/StackedBar.d.ts +1 -0
  14. package/dist/orbcharts-plugins-basic/src/grid/plugins/StackedValueAxis.d.ts +1 -0
  15. package/dist/orbcharts-plugins-basic/src/index.d.ts +7 -0
  16. package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/defaults.d.ts +4 -4
  17. package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/index.d.ts +3 -3
  18. package/dist/orbcharts-plugins-basic/src/multiGrid/plugins/MultiStackedBar.d.ts +1 -0
  19. package/dist/orbcharts-plugins-basic/src/multiGrid/plugins/MultiStackedValueAxis.d.ts +1 -0
  20. package/dist/orbcharts-plugins-basic/src/multiGrid/plugins/OverlappingStackedValueAxes.d.ts +1 -0
  21. package/dist/orbcharts-plugins-basic/src/multiValue/defaults.d.ts +9 -0
  22. package/dist/orbcharts-plugins-basic/src/multiValue/index.d.ts +8 -0
  23. package/dist/orbcharts-plugins-basic/src/multiValue/multiValueObservables.d.ts +33 -0
  24. package/dist/orbcharts-plugins-basic/src/multiValue/plugins/MultiValueLegend.d.ts +1 -0
  25. package/dist/orbcharts-plugins-basic/src/multiValue/plugins/MultiValueTooltip.d.ts +1 -0
  26. package/dist/orbcharts-plugins-basic/src/multiValue/plugins/Scatter.d.ts +3 -0
  27. package/dist/orbcharts-plugins-basic/src/multiValue/plugins/ScatterBubbles.d.ts +3 -0
  28. package/dist/orbcharts-plugins-basic/src/multiValue/plugins/XYAux.d.ts +3 -0
  29. package/dist/orbcharts-plugins-basic/src/multiValue/plugins/XYAxes.d.ts +3 -0
  30. package/dist/orbcharts-plugins-basic/src/multiValue/plugins/XYZoom.d.ts +1 -0
  31. package/dist/orbcharts-plugins-basic/src/relationship/defaults.d.ts +6 -0
  32. package/dist/orbcharts-plugins-basic/src/relationship/index.d.ts +5 -0
  33. package/dist/orbcharts-plugins-basic/src/relationship/plugins/ForceDirected.d.ts +3 -0
  34. package/dist/orbcharts-plugins-basic/src/relationship/plugins/ForceDirectedBubbles.d.ts +3 -0
  35. package/dist/orbcharts-plugins-basic/src/relationship/plugins/RelationshipLegend.d.ts +1 -0
  36. package/dist/orbcharts-plugins-basic/src/relationship/plugins/RelationshipTooltip.d.ts +1 -0
  37. package/dist/orbcharts-plugins-basic/src/relationship/relationshipObservables.d.ts +1 -0
  38. package/dist/{src → orbcharts-plugins-basic/src}/series/seriesObservables.d.ts +3 -3
  39. package/dist/{src → orbcharts-plugins-basic/src}/utils/commonUtils.d.ts +1 -1
  40. package/dist/{src → orbcharts-plugins-basic/src}/utils/d3Utils.d.ts +2 -2
  41. package/dist/{src → orbcharts-plugins-basic/src}/utils/observables.d.ts +1 -1
  42. package/dist/{src → orbcharts-plugins-basic/src}/utils/orbchartsUtils.d.ts +3 -3
  43. package/dist/orbcharts-plugins-basic.es.js +13327 -10361
  44. package/dist/orbcharts-plugins-basic.umd.js +99 -49
  45. package/dist/src/index.d.ts +1 -5
  46. package/package.json +4 -4
  47. package/src/base/BaseBars.ts +5 -5
  48. package/src/base/BaseBarsTriangle.ts +6 -4
  49. package/src/base/BaseDots.ts +3 -54
  50. package/src/base/BaseGroupAxis.ts +50 -50
  51. package/src/base/BaseLegend.ts +25 -21
  52. package/src/base/BaseLineAreas.ts +4 -4
  53. package/src/base/BaseLines.ts +3 -3
  54. package/src/base/{BaseBarStack.ts → BaseStackedBar.ts} +22 -20
  55. package/src/base/BaseTooltip.ts +5 -2
  56. package/src/base/BaseValueAxis.ts +84 -81
  57. package/src/grid/defaults.ts +15 -13
  58. package/src/grid/gridObservables.ts +56 -47
  59. package/src/grid/index.ts +2 -2
  60. package/src/grid/plugins/GridLegend.ts +2 -2
  61. package/src/grid/plugins/GridZoom.ts +20 -20
  62. package/src/grid/plugins/GroupAux.ts +216 -211
  63. package/src/grid/plugins/{BarStack.ts → StackedBar.ts} +7 -7
  64. package/src/grid/plugins/{ValueStackAxis.ts → StackedValueAxis.ts} +6 -5
  65. package/src/grid/plugins/ValueAxis.ts +1 -0
  66. package/src/index.ts +2 -5
  67. package/src/multiGrid/defaults.ts +11 -11
  68. package/src/multiGrid/index.ts +3 -3
  69. package/src/multiGrid/plugins/MultiBars.ts +1 -1
  70. package/src/multiGrid/plugins/MultiBarsTriangle.ts +1 -1
  71. package/src/multiGrid/plugins/MultiGridLegend.ts +2 -2
  72. package/src/multiGrid/plugins/MultiGroupAxis.ts +1 -1
  73. package/src/multiGrid/plugins/{MultiBarStack.ts → MultiStackedBar.ts} +8 -8
  74. package/src/multiGrid/plugins/{MultiValueStackAxis.ts → MultiStackedValueAxis.ts} +4 -3
  75. package/src/multiGrid/plugins/MultiValueAxis.ts +2 -1
  76. package/src/multiGrid/plugins/{OverlappingValueStackAxes.ts → OverlappingStackedValueAxes.ts} +9 -8
  77. package/src/multiGrid/plugins/OverlappingValueAxes.ts +4 -3
  78. package/src/multiValue/defaults.ts +167 -0
  79. package/src/multiValue/index.ts +9 -0
  80. package/src/multiValue/multiValueObservables.ts +297 -0
  81. package/src/multiValue/plugins/MultiValueLegend.ts +107 -0
  82. package/src/multiValue/plugins/MultiValueTooltip.ts +66 -0
  83. package/src/multiValue/plugins/Scatter.ts +426 -0
  84. package/src/multiValue/plugins/ScatterBubbles.ts +554 -0
  85. package/src/multiValue/plugins/XYAux.ts +682 -0
  86. package/src/multiValue/plugins/XYAxes.ts +685 -0
  87. package/src/multiValue/plugins/XYZoom.ts +300 -0
  88. package/src/noneData/plugins/Container.ts +23 -23
  89. package/src/noneData/plugins/Tooltip.ts +365 -365
  90. package/src/relationship/defaults.ts +197 -0
  91. package/src/relationship/index.ts +5 -0
  92. package/src/relationship/plugins/ForceDirected.ts +1169 -0
  93. package/src/relationship/plugins/ForceDirectedBubbles.ts +1394 -0
  94. package/src/relationship/plugins/RelationshipLegend.ts +100 -0
  95. package/src/relationship/plugins/RelationshipTooltip.ts +66 -0
  96. package/src/relationship/relationshipObservables.ts +50 -0
  97. package/src/series/defaults.ts +13 -12
  98. package/src/series/plugins/Bubbles.ts +22 -22
  99. package/src/series/plugins/Pie.ts +2 -2
  100. package/src/series/plugins/PieEventTexts.ts +22 -21
  101. package/src/series/plugins/PieLabels.ts +2 -2
  102. package/src/series/plugins/Rose.ts +2 -2
  103. package/src/series/plugins/RoseLabels.ts +2 -2
  104. package/src/series/plugins/SeriesLegend.ts +4 -4
  105. package/src/series/seriesObservables.ts +3 -3
  106. package/src/tree/defaults.ts +3 -3
  107. package/src/tree/plugins/TreeLegend.ts +3 -10
  108. package/src/utils/commonUtils.ts +5 -5
  109. package/src/utils/d3Utils.ts +4 -3
  110. package/src/utils/observables.ts +2 -2
  111. package/src/utils/orbchartsUtils.ts +28 -12
  112. package/dist/src/grid/plugins/BarStack.d.ts +0 -1
  113. package/dist/src/grid/plugins/ValueStackAxis.d.ts +0 -1
  114. package/dist/src/multiGrid/plugins/MultiBarStack.d.ts +0 -1
  115. package/dist/src/multiGrid/plugins/MultiValueStackAxis.d.ts +0 -1
  116. package/dist/src/multiGrid/plugins/OverlappingValueStackAxes.d.ts +0 -1
  117. package/dist/src/multiValue/plugins/Scatter.d.ts +0 -0
  118. package/dist/src/multiValue/plugins/ScatterAxes.d.ts +0 -0
  119. package/dist/src/noneData/plugins/Container.d.ts +0 -1
  120. package/dist/src/noneData/plugins/Tooltip.d.ts +0 -3
  121. package/dist/src/relationship/index.d.ts +0 -0
  122. package/dist/src/relationship/plugins/Relationship.d.ts +0 -0
  123. package/src/base/BaseGroupArea.ts +0 -0
  124. package/src/multiValue/plugins/ScatterAxes.ts +0 -0
  125. package/src/relationship/plugins/Relationship.ts +0 -0
  126. /package/dist/{lib → orbcharts-plugins-basic/lib}/core-types.d.ts +0 -0
  127. /package/dist/{lib → orbcharts-plugins-basic/lib}/core.d.ts +0 -0
  128. /package/dist/{lib → orbcharts-plugins-basic/lib}/plugins-basic-types.d.ts +0 -0
  129. /package/dist/{src → orbcharts-plugins-basic/src}/base/BaseTooltip.d.ts +0 -0
  130. /package/dist/{src → orbcharts-plugins-basic/src}/base/types.d.ts +0 -0
  131. /package/dist/{src → orbcharts-plugins-basic/src}/const.d.ts +0 -0
  132. /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/Bars.d.ts +0 -0
  133. /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/BarsPN.d.ts +0 -0
  134. /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/BarsTriangle.d.ts +0 -0
  135. /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/Dots.d.ts +0 -0
  136. /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/GridLegend.d.ts +0 -0
  137. /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/GridTooltip.d.ts +0 -0
  138. /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/GridZoom.d.ts +0 -0
  139. /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/GroupAux.d.ts +0 -0
  140. /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/GroupAxis.d.ts +0 -0
  141. /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/LineAreas.d.ts +0 -0
  142. /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/Lines.d.ts +0 -0
  143. /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/ValueAxis.d.ts +0 -0
  144. /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/multiGridObservables.d.ts +0 -0
  145. /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/plugins/MultiBars.d.ts +0 -0
  146. /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/plugins/MultiBarsTriangle.d.ts +0 -0
  147. /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/plugins/MultiDots.d.ts +0 -0
  148. /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/plugins/MultiGridLegend.d.ts +0 -0
  149. /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/plugins/MultiGridTooltip.d.ts +0 -0
  150. /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/plugins/MultiGroupAxis.d.ts +0 -0
  151. /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/plugins/MultiLineAreas.d.ts +0 -0
  152. /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/plugins/MultiLines.d.ts +0 -0
  153. /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/plugins/MultiValueAxis.d.ts +0 -0
  154. /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/plugins/OverlappingValueAxes.d.ts +0 -0
  155. /package/dist/{src/grid → orbcharts-plugins-basic/src/multiValue}/plugins/Ranking.d.ts +0 -0
  156. /package/dist/{src/grid → orbcharts-plugins-basic/src/multiValue}/plugins/RankingAxis.d.ts +0 -0
  157. /package/dist/{src → orbcharts-plugins-basic/src}/noneData/defaults.d.ts +0 -0
  158. /package/dist/{src → orbcharts-plugins-basic/src}/noneData/index.d.ts +0 -0
  159. /package/dist/{src/base/BaseGroupArea.d.ts → orbcharts-plugins-basic/src/noneData/plugins/Container.d.ts} +0 -0
  160. /package/dist/{src/multiValue/index.d.ts → orbcharts-plugins-basic/src/noneData/plugins/Tooltip.d.ts} +0 -0
  161. /package/dist/{src → orbcharts-plugins-basic/src}/series/defaults.d.ts +0 -0
  162. /package/dist/{src → orbcharts-plugins-basic/src}/series/index.d.ts +0 -0
  163. /package/dist/{src → orbcharts-plugins-basic/src}/series/plugins/Bubbles.d.ts +0 -0
  164. /package/dist/{src → orbcharts-plugins-basic/src}/series/plugins/Pie.d.ts +0 -0
  165. /package/dist/{src → orbcharts-plugins-basic/src}/series/plugins/PieEventTexts.d.ts +0 -0
  166. /package/dist/{src → orbcharts-plugins-basic/src}/series/plugins/PieLabels.d.ts +0 -0
  167. /package/dist/{src → orbcharts-plugins-basic/src}/series/plugins/Rose.d.ts +0 -0
  168. /package/dist/{src → orbcharts-plugins-basic/src}/series/plugins/RoseLabels.d.ts +0 -0
  169. /package/dist/{src → orbcharts-plugins-basic/src}/series/plugins/SeriesLegend.d.ts +0 -0
  170. /package/dist/{src → orbcharts-plugins-basic/src}/series/plugins/SeriesTooltip.d.ts +0 -0
  171. /package/dist/{src → orbcharts-plugins-basic/src}/series/plugins/Waffle.d.ts +0 -0
  172. /package/dist/{src → orbcharts-plugins-basic/src}/series/seriesUtils.d.ts +0 -0
  173. /package/dist/{src → orbcharts-plugins-basic/src}/tree/defaults.d.ts +0 -0
  174. /package/dist/{src → orbcharts-plugins-basic/src}/tree/index.d.ts +0 -0
  175. /package/dist/{src → orbcharts-plugins-basic/src}/tree/plugins/TreeLegend.d.ts +0 -0
  176. /package/dist/{src → orbcharts-plugins-basic/src}/tree/plugins/TreeMap.d.ts +0 -0
  177. /package/dist/{src → orbcharts-plugins-basic/src}/tree/plugins/TreeTooltip.d.ts +0 -0
  178. /package/dist/{src → orbcharts-plugins-basic/src}/utils/d3Graphics.d.ts +0 -0
  179. /package/dist/{vite.config.d.ts → orbcharts-plugins-basic/vite.config.d.ts} +0 -0
  180. /package/src/{grid → multiValue}/plugins/Ranking.ts +0 -0
  181. /package/src/{grid → multiValue}/plugins/RankingAxis.ts +0 -0
@@ -0,0 +1,100 @@
1
+ import * as d3 from 'd3'
2
+ import {
3
+ combineLatest,
4
+ map,
5
+ switchMap,
6
+ takeUntil,
7
+ Observable,
8
+ Subject } from 'rxjs'
9
+ import type { DefinePluginConfig } from '../../../lib/core-types'
10
+ import {
11
+ defineRelationshipPlugin } from '../../../lib/core'
12
+ import { DEFAULT_RELATIONSHIP_LEGEND_PARAMS } from '../defaults'
13
+ import { createBaseLegend } from '../../base/BaseLegend'
14
+ import { LAYER_INDEX_OF_INFO } from '../../const'
15
+
16
+ const pluginName = 'RelationshipLegend'
17
+
18
+ const pluginConfig: DefinePluginConfig<typeof pluginName, typeof DEFAULT_RELATIONSHIP_LEGEND_PARAMS> = {
19
+ name: pluginName,
20
+ defaultParams: DEFAULT_RELATIONSHIP_LEGEND_PARAMS,
21
+ layerIndex: LAYER_INDEX_OF_INFO,
22
+ validator: (params, { validateColumns }) => {
23
+ const result = validateColumns(params, {
24
+ placement: {
25
+ toBe: '"top" | "top-start" | "top-end" | "bottom" | "bottom-start" | "bottom-end" | "left" | "left-start" | "left-end" | "right" | "right-start" | "right-end"',
26
+ test: (value) => {
27
+ return [
28
+ 'top', 'top-start', 'top-end',
29
+ 'bottom', 'bottom-start', 'bottom-end',
30
+ 'left', 'left-start', 'left-end',
31
+ 'right', 'right-start', 'right-end'
32
+ ].includes(value)
33
+ }
34
+ },
35
+ padding: {
36
+ toBeTypes: ['number']
37
+ },
38
+ backgroundFill: {
39
+ toBeOption: 'ColorType',
40
+ },
41
+ backgroundStroke: {
42
+ toBeOption: 'ColorType',
43
+ },
44
+ gap: {
45
+ toBeTypes: ['number']
46
+ },
47
+ listRectWidth: {
48
+ toBeTypes: ['number']
49
+ },
50
+ listRectHeight: {
51
+ toBeTypes: ['number']
52
+ },
53
+ listRectRadius: {
54
+ toBeTypes: ['number']
55
+ },
56
+ textColorType: {
57
+ toBeOption: 'ColorType',
58
+ }
59
+ })
60
+ return result
61
+ }
62
+ }
63
+
64
+ export const RelationshipLegend = defineRelationshipPlugin(pluginConfig)(({ selection, rootSelection, observer, subject }) => {
65
+
66
+ const destroy$ = new Subject()
67
+
68
+ // 全部列點矩型使用相同樣式參數
69
+ const fullParams$ = observer.fullParams$.pipe(
70
+ takeUntil(destroy$),
71
+ map(d => {
72
+ const labelList = [
73
+ {
74
+ listRectWidth: d.listRectWidth,
75
+ listRectHeight: d.listRectHeight,
76
+ listRectRadius: d.listRectRadius,
77
+ }
78
+ ]
79
+ return {
80
+ ...d,
81
+ labelList
82
+ }
83
+ })
84
+ )
85
+
86
+ const unsubscribeBaseLegend = createBaseLegend(pluginName, {
87
+ rootSelection,
88
+ legendLabels$: observer.categoryLabels$,
89
+ fullParams$,
90
+ layout$: observer.layout$,
91
+ fullChartParams$: observer.fullChartParams$,
92
+ textSizePx$: observer.textSizePx$
93
+ })
94
+
95
+ return () => {
96
+ destroy$.next(undefined)
97
+ unsubscribeBaseLegend()
98
+ }
99
+ })
100
+
@@ -0,0 +1,66 @@
1
+ import {
2
+ Subject,
3
+ } from 'rxjs'
4
+ import type { DefinePluginConfig } from '../../../lib/core-types'
5
+ import {
6
+ defineRelationshipPlugin } from '../../../lib/core'
7
+ import { DEFAULT_RELATIONSHIP_TOOLTIP_PARAMS } from '../defaults'
8
+ import { LAYER_INDEX_OF_TOOLTIP } from '../../const'
9
+ import { createBaseTooltip } from '../../base/BaseTooltip'
10
+
11
+ const pluginName = 'RelationshipTooltip'
12
+
13
+ const pluginConfig: DefinePluginConfig<typeof pluginName, typeof DEFAULT_RELATIONSHIP_TOOLTIP_PARAMS> = {
14
+ name: pluginName,
15
+ defaultParams: DEFAULT_RELATIONSHIP_TOOLTIP_PARAMS,
16
+ layerIndex: LAYER_INDEX_OF_TOOLTIP,
17
+ validator: (params, { validateColumns }) => {
18
+ const result = validateColumns(params, {
19
+ backgroundColorType: {
20
+ toBeOption: 'ColorType',
21
+ },
22
+ backgroundOpacity: {
23
+ toBeTypes: ['number']
24
+ },
25
+ strokeColorType: {
26
+ toBeOption: 'ColorType',
27
+ },
28
+ offset: {
29
+ toBe: '[number, number]',
30
+ test: (value: any) => {
31
+ return Array.isArray(value)
32
+ && value.length === 2
33
+ && typeof value[0] === 'number'
34
+ && typeof value[1] === 'number'
35
+ }
36
+ },
37
+ padding: {
38
+ toBeTypes: ['number']
39
+ },
40
+ textColorType: {
41
+ toBeOption: 'ColorType',
42
+ },
43
+ renderFn: {
44
+ toBeTypes: ['Function']
45
+ },
46
+ })
47
+ return result
48
+ }
49
+ }
50
+
51
+ export const RelationshipTooltip = defineRelationshipPlugin(pluginConfig)(({ selection, rootSelection, name, subject, observer }) => {
52
+ const destroy$ = new Subject()
53
+
54
+ const unsubscribeTooltip = createBaseTooltip(pluginName, {
55
+ rootSelection,
56
+ fullParams$: observer.fullParams$,
57
+ fullChartParams$: observer.fullChartParams$,
58
+ layout$: observer.layout$,
59
+ event$: subject.event$,
60
+ })
61
+
62
+ return () => {
63
+ destroy$.next(undefined)
64
+ unsubscribeTooltip()
65
+ }
66
+ })
@@ -0,0 +1,50 @@
1
+ import * as d3 from 'd3'
2
+ import {
3
+ Observable,
4
+ Subject,
5
+ of,
6
+ takeUntil,
7
+ filter,
8
+ first,
9
+ map,
10
+ switchMap,
11
+ combineLatest,
12
+ merge,
13
+ shareReplay,
14
+ distinctUntilChanged
15
+ } from 'rxjs'
16
+ import type {
17
+ ContainerPosition } from '../../lib/core-types'
18
+ import { getClassName, getUniID } from '../utils/orbchartsUtils'
19
+
20
+ // function createRelationshipSelection ({ selection, pluginName, separateSeries$, seriesLabels$ }: {
21
+ // selection: d3.Selection<any, unknown, any, unknown>
22
+ // pluginName: string
23
+ // separateSeries$: Observable<boolean>
24
+ // seriesLabels$: Observable<string[]>
25
+ // }) {
26
+ // const seriesClassName = getClassName(pluginName, 'series')
27
+
28
+ // return combineLatest({
29
+ // seriesLabels: seriesLabels$,
30
+ // separateSeries: separateSeries$
31
+ // }).pipe(
32
+ // switchMap(async d => d),
33
+ // map((data, i) => {
34
+ // const selectionData = data.separateSeries ? data.seriesLabels : [data.seriesLabels.join('')]
35
+ // return selection
36
+ // .selectAll<SVGGElement, string>(`g.${seriesClassName}`)
37
+ // .data(selectionData, d => d)
38
+ // .join(
39
+ // enter => {
40
+ // return enter
41
+ // .append('g')
42
+ // .classed(seriesClassName, true)
43
+ // },
44
+ // update => update,
45
+ // exit => exit.remove()
46
+ // )
47
+ // }),
48
+ // shareReplay(1)
49
+ // )
50
+ // }
@@ -17,10 +17,11 @@ export const DEFAULT_BUBBLES_PARAMS: BubblesParams = {
17
17
  velocityDecay: 0.3, // 衰減數
18
18
  collisionSpacing: 2 // 泡泡間距
19
19
  },
20
- bubbleText: {
20
+ bubbleLabel: {
21
21
  fillRate: 0.6,
22
- lineHeight: 12,
23
- lineLengthMin: 4
22
+ lineHeight: 1,
23
+ maxLineLength: 6,
24
+ wordBreakAll: true,
24
25
  },
25
26
  // highlightRIncrease: 0,
26
27
  arcScaleType: 'area'
@@ -51,8 +52,8 @@ export const DEFAULT_PIE_PARAMS: PieParams = {
51
52
  }
52
53
 
53
54
  export const DEFAULT_PIE_EVENT_TEXTS_PARAMS: PieEventTextsParams = {
54
- eventFn: (eventData: EventSeries, eventName: EventName, t: number) => {
55
- if (eventName === 'mouseover' || eventName === 'mousemove') {
55
+ renderFn: (eventData: EventSeries) => {
56
+ if (eventData.eventName === 'mouseover' || eventData.eventName === 'mousemove') {
56
57
  return [String(eventData.datum!.value)]
57
58
  }
58
59
  return [
@@ -62,7 +63,7 @@ export const DEFAULT_PIE_EVENT_TEXTS_PARAMS: PieEventTextsParams = {
62
63
  return acc + seriesData.reduce((_acc, data) => {
63
64
  return _acc + (data.value ?? 0)
64
65
  }, 0)
65
- }, 0) * t
66
+ }, 0) * (eventData.tween ?? 1)
66
67
  )
67
68
  )
68
69
  ]
@@ -83,9 +84,9 @@ export const DEFAULT_PIE_EVENT_TEXTS_PARAMS: PieEventTextsParams = {
83
84
  }
84
85
  ]
85
86
  }
86
- DEFAULT_PIE_EVENT_TEXTS_PARAMS.eventFn.toString = () => `(eventData: EventSeries, eventName: EventName, t: number) => {
87
- if (eventName === 'mouseover' || eventName === 'mousemove') {
88
- return [String(eventData.datum!.value)]
87
+ DEFAULT_PIE_EVENT_TEXTS_PARAMS.renderFn.toString = () => `(eventData) => {
88
+ if (eventData.eventName === 'mouseover' || eventData.eventName === 'mousemove') {
89
+ return [String(eventData.datum.value)]
89
90
  }
90
91
  return [
91
92
  String(
@@ -94,7 +95,7 @@ DEFAULT_PIE_EVENT_TEXTS_PARAMS.eventFn.toString = () => `(eventData: EventSeries
94
95
  return acc + seriesData.reduce((_acc, data) => {
95
96
  return _acc + (data.value ?? 0)
96
97
  }, 0)
97
- }, 0) * t
98
+ }, 0) * (eventData.tween ?? 1)
98
99
  )
99
100
  )
100
101
  ]
@@ -158,7 +159,7 @@ export const DEFAULT_SERIES_TOOLTIP_PARAMS: SeriesTooltipParams = {
158
159
  textColorType: 'primary',
159
160
  offset: [20, 5],
160
161
  padding: 10,
161
- renderFn: (eventData, { styles }) => {
162
+ renderFn: (eventData, { styles, utils }) => {
162
163
  const hasSeriesLabel = eventData.seriesLabel.slice(0, 7) === 'series_' ? false : true
163
164
  const hasDatumLabel = eventData.datum.label.slice(0, 7) === 'series_' ? false : true
164
165
  const bulletWidth = styles.textSizePx * 0.7
@@ -182,7 +183,7 @@ export const DEFAULT_SERIES_TOOLTIP_PARAMS: SeriesTooltipParams = {
182
183
  </g>`
183
184
  },
184
185
  }
185
- DEFAULT_SERIES_TOOLTIP_PARAMS.renderFn.toString = () => `(eventData, { styles }) => {
186
+ DEFAULT_SERIES_TOOLTIP_PARAMS.renderFn.toString = () => `(eventData, { styles, utils }) => {
186
187
  const hasSeriesLabel = eventData.seriesLabel.slice(0, 7) === 'series_' ? false : true
187
188
  const hasDatumLabel = eventData.datum.label.slice(0, 7) === 'series_' ? false : true
188
189
  const bulletWidth = styles.textSizePx * 0.7
@@ -17,7 +17,7 @@ import type {
17
17
  EventName,
18
18
  ComputedDataSeries,
19
19
  ComputedDatumSeries,
20
- SeriesContainerPosition } from '../../../lib/core-types'
20
+ ContainerPosition } from '../../../lib/core-types'
21
21
  import {
22
22
  defineSeriesPlugin } from '../../../lib/core'
23
23
  import type { BubblesParams, ArcScaleType } from '../../../lib/plugins-basic-types'
@@ -36,6 +36,8 @@ type BubblesSimulationDatum = BubblesDatum & d3.SimulationNodeDatum
36
36
 
37
37
  const pluginName = 'Bubbles'
38
38
 
39
+ const baseLineHeight = 12 // 未變形前的字體大小(代入計算用而已,數字多少都不會有影響)
40
+
39
41
  const pluginConfig: DefinePluginConfig<typeof pluginName, typeof DEFAULT_BUBBLES_PARAMS> = {
40
42
  name: pluginName,
41
43
  defaultParams: DEFAULT_BUBBLES_PARAMS,
@@ -45,7 +47,7 @@ const pluginConfig: DefinePluginConfig<typeof pluginName, typeof DEFAULT_BUBBLES
45
47
  force: {
46
48
  toBeTypes: ['object']
47
49
  },
48
- bubbleText: {
50
+ bubbleLabel: {
49
51
  toBeTypes: ['object']
50
52
  },
51
53
  arcScaleType: {
@@ -69,20 +71,20 @@ const pluginConfig: DefinePluginConfig<typeof pluginName, typeof DEFAULT_BUBBLES
69
71
  return forceResult
70
72
  }
71
73
  }
72
- if (params.bubbleText) {
73
- const bubbleTextResult = validateColumns(params.bubbleText, {
74
+ if (params.bubbleLabel) {
75
+ const bubbleLabelResult = validateColumns(params.bubbleLabel, {
74
76
  fillRate: {
75
77
  toBeTypes: ['number']
76
78
  },
77
79
  lineHeight: {
78
80
  toBeTypes: ['number']
79
81
  },
80
- lineLengthMin: {
82
+ maxLineLength: {
81
83
  toBeTypes: ['number']
82
84
  },
83
85
  })
84
- if (bubbleTextResult.status === 'error') {
85
- return bubbleTextResult
86
+ if (bubbleLabelResult.status === 'error') {
87
+ return bubbleLabelResult
86
88
  }
87
89
  }
88
90
  return result
@@ -91,23 +93,23 @@ const pluginConfig: DefinePluginConfig<typeof pluginName, typeof DEFAULT_BUBBLES
91
93
 
92
94
  let force: d3.Simulation<d3.SimulationNodeDatum, undefined> | undefined
93
95
 
94
- function makeForce (bubblesSelection: d3.Selection<SVGGElement, any, any, any>, fullParams: BubblesParams) {
96
+ function makeForce (bubblesSelection: d3.Selection<SVGGElement, BubblesDatum, any, any>, fullParams: BubblesParams) {
95
97
  return d3.forceSimulation()
96
98
  .velocityDecay(fullParams.force!.velocityDecay!)
97
99
  // .alphaDecay(0.2)
98
100
  .force(
99
101
  "collision",
100
102
  d3.forceCollide()
101
- .radius(d => {
102
- // @ts-ignore
103
+ .radius((d: d3.SimulationNodeDatum & BubblesDatum) => {
103
104
  return d.r + fullParams.force!.collisionSpacing
104
105
  })
105
106
  // .strength(0.01)
106
107
  )
107
- .force("charge", d3.forceManyBody().strength((d) => {
108
- // @ts-ignore
108
+ .force("charge", d3.forceManyBody().strength((d: d3.SimulationNodeDatum & BubblesDatum) => {
109
109
  return - Math.pow(d.r, 2.0) * fullParams.force!.strength
110
110
  }))
111
+ // .force("charge", d3.forceManyBody().strength(-2000))
112
+ // .force("collision", d3.forceCollide(60).strength(1)) // @Q@ 60為泡泡的R,暫時是先寫死的
111
113
  // .force("x", d3.forceX().strength(forceStrength).x(this.graphicWidth / 2))
112
114
  // .force("y", d3.forceY().strength(forceStrength).y(this.graphicHeight / 2))
113
115
  .on("tick", () => {
@@ -121,6 +123,7 @@ function makeForce (bubblesSelection: d3.Selection<SVGGElement, any, any, any>,
121
123
  // .attr("cx", (d) => d.x)
122
124
  // .attr("cy", (d) => d.y)
123
125
  })
126
+
124
127
  }
125
128
 
126
129
 
@@ -147,7 +150,7 @@ function createBubblesData ({ visibleComputedLayoutData, LastBubbleDataMap, grap
147
150
  LastBubbleDataMap: Map<string, BubblesDatum>
148
151
  graphicWidth: number
149
152
  graphicHeight: number
150
- SeriesContainerPositionMap: Map<string, SeriesContainerPosition>
153
+ SeriesContainerPositionMap: Map<string, ContainerPosition>
151
154
  scaleType: ArcScaleType
152
155
  // highlightIds: string[]
153
156
  }): BubblesDatum[] {
@@ -214,7 +217,7 @@ function renderBubbles ({ selection, bubblesData, fullParams, sumSeries }: {
214
217
  const enterSelection = enter
215
218
  .append('g')
216
219
  .attr('cursor', 'pointer')
217
- .attr('font-size', 12)
220
+ .attr('font-size', baseLineHeight)
218
221
  .style('fill', '#ffffff')
219
222
  .attr("text-anchor", "middle")
220
223
 
@@ -258,15 +261,12 @@ function renderBubbles ({ selection, bubblesData, fullParams, sumSeries }: {
258
261
  bubblesSelection
259
262
  .each((d,i,g) => {
260
263
  const gSelection = d3.select(g[i])
261
- let breakAll = true
262
- if (d[textDataColumn].length <= fullParams.bubbleText.lineLengthMin) {
263
- breakAll = false
264
- }
264
+
265
265
  gSelection.call(renderCircleText, {
266
266
  text: d[textDataColumn],
267
- radius: d.r * fullParams.bubbleText.fillRate,
268
- lineHeight: fullParams.bubbleText.lineHeight,
269
- isBreakAll: breakAll
267
+ radius: d.r * fullParams.bubbleLabel.fillRate,
268
+ lineHeight: baseLineHeight * fullParams.bubbleLabel.lineHeight,
269
+ isBreakAll: fullParams.bubbleLabel.wordBreakAll
270
270
  })
271
271
 
272
272
  })
@@ -330,7 +330,7 @@ function groupBubbles ({ fullParams, SeriesContainerPositionMap }: {
330
330
  fullParams: BubblesParams
331
331
  // graphicWidth: number
332
332
  // graphicHeight: number
333
- SeriesContainerPositionMap: Map<string, SeriesContainerPosition>
333
+ SeriesContainerPositionMap: Map<string, ContainerPosition>
334
334
  }) {
335
335
  // console.log('groupBubbles')
336
336
  force!
@@ -12,7 +12,7 @@ import type { DefinePluginConfig } from '../../../lib/core-types'
12
12
  import type {
13
13
  ComputedDataSeries,
14
14
  ComputedDatumSeries,
15
- SeriesContainerPosition,
15
+ ContainerPosition,
16
16
  ChartParams,
17
17
  EventSeries,
18
18
  Layout } from '../../../lib/core-types'
@@ -210,7 +210,7 @@ function createEachPie (pluginName: string, context: {
210
210
  fullParams$: Observable<PieParams>
211
211
  fullChartParams$: Observable<ChartParams>
212
212
  seriesHighlight$: Observable<ComputedDatumSeries[]>
213
- seriesContainerPosition$: Observable<SeriesContainerPosition>
213
+ seriesContainerPosition$: Observable<ContainerPosition>
214
214
  event$: Subject<EventSeries>
215
215
  }) {
216
216
  const destroy$ = new Subject()
@@ -15,7 +15,7 @@ import {
15
15
  import type {
16
16
  ComputedDatumSeries,
17
17
  ChartParams,
18
- SeriesContainerPosition,
18
+ ContainerPosition,
19
19
  EventName,
20
20
  EventSeries } from '../../../lib/core-types'
21
21
  import type { PieEventTextsParams } from '../../../lib/plugins-basic-types'
@@ -40,7 +40,7 @@ const pluginConfig: DefinePluginConfig<typeof pluginName, typeof DEFAULT_PIE_EVE
40
40
  layerIndex: LAYER_INDEX_OF_LABEL,
41
41
  validator: (params, { validateColumns }) => {
42
42
  const result = validateColumns(params, {
43
- eventFn: {
43
+ renderFn: {
44
44
  toBeTypes: ['Function'],
45
45
  },
46
46
  textAttrs: {
@@ -84,16 +84,16 @@ function renderText (
84
84
  return text
85
85
  }
86
86
 
87
- function makeTextData ({ eventData, eventName, t, eventFn, textAttrs, textStyles }: {
87
+ function createTextData ({ eventData, renderFn, textAttrs, textStyles }: {
88
88
  eventData: EventSeries,
89
- eventName: EventName,
90
- t: number,
91
- eventFn: (d: EventSeries, eventName: EventName, t: number) => string[]
89
+ // t: number,
90
+ renderFn: (d: EventSeries) => string[] | string
92
91
  textAttrs: Array<{ [key:string]: string | number }>
93
92
  textStyles: Array<{ [key:string]: string | number }>
94
93
  }): TextDatum[] {
95
- const callbackText = eventFn(eventData, eventName, t)
96
- return callbackText.map((d, i) => {
94
+ const callbackText = renderFn(eventData)
95
+ const textArr = Array.isArray(callbackText) ? callbackText : [callbackText]
96
+ return textArr.map((d, i) => {
97
97
  return {
98
98
  text: d,
99
99
  attr: textAttrs[i],
@@ -110,7 +110,7 @@ function createEachPieEventTexts (pluginName: string, context: {
110
110
  fullParams$: Observable<PieEventTextsParams>
111
111
  fullChartParams$: Observable<ChartParams>
112
112
  seriesHighlight$: Observable<ComputedDatumSeries[]>
113
- seriesContainerPosition$: Observable<SeriesContainerPosition>
113
+ seriesContainerPosition$: Observable<ContainerPosition>
114
114
  event$: Subject<EventSeries>
115
115
  }) {
116
116
  const destroy$ = new Subject()
@@ -159,12 +159,13 @@ function createEachPieEventTexts (pluginName: string, context: {
159
159
  // .ease(getD3TransitionEase(data.fullChartParams.transitionEase!))
160
160
  .tween('move', (event, datum) => {
161
161
  return (t) => {
162
- const renderData = makeTextData({
162
+ const renderData = createTextData({
163
163
  eventData: {
164
164
  type: 'series',
165
165
  pluginName,
166
166
  eventName: 'transitionMove',
167
167
  event,
168
+ tween: t,
168
169
  highlightTarget: data.highlightTarget,
169
170
  data: data.computedData,
170
171
  series: [],
@@ -172,9 +173,9 @@ function createEachPieEventTexts (pluginName: string, context: {
172
173
  seriesLabel: '',
173
174
  datum: null
174
175
  },
175
- eventName: 'transitionMove',
176
- t,
177
- eventFn: data.fullParams.eventFn!,
176
+ // eventName: 'transitionMove',
177
+ // t,
178
+ renderFn: data.fullParams.renderFn!,
178
179
  textAttrs: data.fullParams.textAttrs!,
179
180
  textStyles: data.fullParams.textStyles!
180
181
  })
@@ -182,12 +183,13 @@ function createEachPieEventTexts (pluginName: string, context: {
182
183
  }
183
184
  })
184
185
  .on('end', (event, datum) => {
185
- const renderData = makeTextData({
186
+ const renderData = createTextData({
186
187
  eventData: {
187
188
  type: 'series',
188
189
  pluginName,
189
190
  eventName: 'transitionEnd',
190
191
  event,
192
+ tween: 1,
191
193
  highlightTarget: data.highlightTarget,
192
194
  data: data.computedData,
193
195
  series: [],
@@ -195,9 +197,9 @@ function createEachPieEventTexts (pluginName: string, context: {
195
197
  seriesLabel: '',
196
198
  datum: null
197
199
  },
198
- eventName: 'transitionMove',
199
- t: 1,
200
- eventFn: data.fullParams.eventFn!,
200
+ // eventName: 'transitionMove',
201
+ // t: 1,
202
+ renderFn: data.fullParams.renderFn!,
201
203
  textAttrs: data.fullParams.textAttrs!,
202
204
  textStyles: data.fullParams.textStyles!
203
205
  })
@@ -208,11 +210,10 @@ function createEachPieEventTexts (pluginName: string, context: {
208
210
  }
209
211
  storeEventSubscription = context.event$
210
212
  .subscribe(eventData => {
211
- const renderData = makeTextData({
213
+ const renderData = createTextData({
212
214
  eventData,
213
- eventName: eventData.eventName,
214
- t: 1,
215
- eventFn: data.fullParams.eventFn!,
215
+ // t: 1,
216
+ renderFn: data.fullParams.renderFn!,
216
217
  textAttrs: data.fullParams.textAttrs!,
217
218
  textStyles: data.fullParams.textStyles!
218
219
  })
@@ -14,7 +14,7 @@ import {
14
14
  defineSeriesPlugin } from '../../../lib/core'
15
15
  import type {
16
16
  ComputedDatumSeries,
17
- SeriesContainerPosition,
17
+ ContainerPosition,
18
18
  EventSeries,
19
19
  ChartParams } from '../../../lib/core-types'
20
20
  import type { PieLabelsParams } from '../../../lib/plugins-basic-types'
@@ -453,7 +453,7 @@ function createEachPieLabel (pluginName: string, context: {
453
453
  fullChartParams$: Observable<ChartParams>
454
454
  textSizePx$: Observable<number>
455
455
  seriesHighlight$: Observable<ComputedDatumSeries[]>
456
- seriesContainerPosition$: Observable<SeriesContainerPosition>
456
+ seriesContainerPosition$: Observable<ContainerPosition>
457
457
  event$: Subject<EventSeries>
458
458
  }) {
459
459
  const destroy$ = new Subject()
@@ -14,7 +14,7 @@ import type { DefinePluginConfig } from '../../../lib/core-types'
14
14
  import type {
15
15
  ComputedDataSeries,
16
16
  ComputedDatumSeries,
17
- SeriesContainerPosition,
17
+ ContainerPosition,
18
18
  ChartParams,
19
19
  EventSeries,
20
20
  Layout } from '../../../lib/core-types'
@@ -219,7 +219,7 @@ function createEachRose (pluginName: string, context: {
219
219
  fullParams$: Observable<RoseParams>
220
220
  fullChartParams$: Observable<ChartParams>
221
221
  seriesHighlight$: Observable<ComputedDatumSeries[]>
222
- seriesContainerPosition$: Observable<SeriesContainerPosition>
222
+ seriesContainerPosition$: Observable<ContainerPosition>
223
223
  event$: Subject<EventSeries>
224
224
  }) {
225
225
  const destroy$ = new Subject()
@@ -14,7 +14,7 @@ import {
14
14
  defineSeriesPlugin } from '../../../lib/core'
15
15
  import type {
16
16
  ComputedDatumSeries,
17
- SeriesContainerPosition,
17
+ ContainerPosition,
18
18
  EventSeries,
19
19
  ChartParams } from '../../../lib/core-types'
20
20
  import type { RoseLabelsParams } from '../../../lib/plugins-basic-types'
@@ -413,7 +413,7 @@ function createEachPieLabel (pluginName: string, context: {
413
413
  fullChartParams$: Observable<ChartParams>
414
414
  textSizePx$: Observable<number>
415
415
  seriesHighlight$: Observable<ComputedDatumSeries[]>
416
- seriesContainerPosition$: Observable<SeriesContainerPosition>
416
+ seriesContainerPosition$: Observable<ContainerPosition>
417
417
  event$: Subject<EventSeries>
418
418
  }) {
419
419
  const destroy$ = new Subject()
@@ -65,7 +65,7 @@ export const SeriesLegend = defineSeriesPlugin(pluginConfig)(({ selection, rootS
65
65
 
66
66
  const destroy$ = new Subject()
67
67
 
68
- const seriesLabels$: Observable<string[]> = observer.SeriesDataMap$.pipe(
68
+ const legendLabels$: Observable<string[]> = observer.SeriesDataMap$.pipe(
69
69
  takeUntil(destroy$),
70
70
  map(data => {
71
71
  return Array.from(data.keys())
@@ -76,7 +76,7 @@ export const SeriesLegend = defineSeriesPlugin(pluginConfig)(({ selection, rootS
76
76
  const fullParams$ = observer.fullParams$.pipe(
77
77
  takeUntil(destroy$),
78
78
  map(d => {
79
- const seriesList = [
79
+ const labelList = [
80
80
  {
81
81
  listRectWidth: d.listRectWidth,
82
82
  listRectHeight: d.listRectHeight,
@@ -85,14 +85,14 @@ export const SeriesLegend = defineSeriesPlugin(pluginConfig)(({ selection, rootS
85
85
  ]
86
86
  return {
87
87
  ...d,
88
- seriesList
88
+ labelList
89
89
  }
90
90
  })
91
91
  )
92
92
 
93
93
  const unsubscribeBaseLegend = createBaseLegend(pluginName, {
94
94
  rootSelection,
95
- seriesLabels$,
95
+ legendLabels$,
96
96
  fullParams$,
97
97
  layout$: observer.layout$,
98
98
  fullChartParams$: observer.fullChartParams$,
@@ -14,7 +14,7 @@ import {
14
14
  distinctUntilChanged
15
15
  } from 'rxjs'
16
16
  import type {
17
- SeriesContainerPosition } from '../../lib/core-types'
17
+ ContainerPosition } from '../../lib/core-types'
18
18
  import { getClassName, getUniID } from '../utils/orbchartsUtils'
19
19
 
20
20
  function createSeriesSelection ({ selection, pluginName, separateSeries$, seriesLabels$ }: {
@@ -55,7 +55,7 @@ export const seriesStartSelectionObservable = ({ selection, pluginName, separate
55
55
  pluginName: string
56
56
  separateSeries$: Observable<boolean>
57
57
  seriesLabels$: Observable<string[]>
58
- seriesContainerPosition$: Observable<SeriesContainerPosition[]>
58
+ seriesContainerPosition$: Observable<ContainerPosition[]>
59
59
  }) => {
60
60
 
61
61
  const seriesStartSelection$ = createSeriesSelection({ selection, pluginName, separateSeries$, seriesLabels$ })
@@ -102,7 +102,7 @@ export const seriesCenterSelectionObservable = ({ selection, pluginName, separat
102
102
  pluginName: string
103
103
  separateSeries$: Observable<boolean>
104
104
  seriesLabels$: Observable<string[]>
105
- seriesContainerPosition$: Observable<SeriesContainerPosition[]>
105
+ seriesContainerPosition$: Observable<ContainerPosition[]>
106
106
  }) => {
107
107
 
108
108
  const seriesCenterSelection$ = createSeriesSelection({ selection, pluginName, separateSeries$, seriesLabels$ })