@orbcharts/plugins-basic 3.0.0-alpha.69 → 3.0.0-alpha.71

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 (121) hide show
  1. package/dist/lib/core-types.d.ts +1 -0
  2. package/dist/lib/core.d.ts +1 -0
  3. package/dist/orbcharts-plugins-basic.es.js +8861 -7395
  4. package/dist/orbcharts-plugins-basic.umd.js +19 -15
  5. package/dist/src/base/BaseBarStack.d.ts +1 -1
  6. package/dist/src/base/BaseBars.d.ts +1 -1
  7. package/dist/src/base/BaseBarsTriangle.d.ts +1 -1
  8. package/dist/src/base/BaseDots.d.ts +1 -1
  9. package/dist/src/base/BaseGroupAxis.d.ts +1 -1
  10. package/dist/src/base/BaseLegend.d.ts +1 -1
  11. package/dist/src/base/BaseLineAreas.d.ts +1 -1
  12. package/dist/src/base/BaseLines.d.ts +1 -1
  13. package/dist/src/base/BaseValueAxis.d.ts +1 -1
  14. package/dist/src/const.d.ts +10 -0
  15. package/dist/src/grid/gridObservables.d.ts +1 -1
  16. package/dist/src/grid/plugins/BarStack.d.ts +1 -1
  17. package/dist/src/grid/plugins/Bars.d.ts +1 -1
  18. package/dist/src/grid/plugins/BarsPN.d.ts +1 -1
  19. package/dist/src/grid/plugins/BarsTriangle.d.ts +1 -1
  20. package/dist/src/grid/plugins/Dots.d.ts +1 -1
  21. package/dist/src/grid/plugins/GridLegend.d.ts +1 -1
  22. package/dist/src/grid/plugins/GroupAux.d.ts +1 -1
  23. package/dist/src/grid/plugins/GroupAxis.d.ts +1 -1
  24. package/dist/src/grid/plugins/LineAreas.d.ts +1 -1
  25. package/dist/src/grid/plugins/Lines.d.ts +1 -1
  26. package/dist/src/grid/plugins/ScalingArea.d.ts +1 -1
  27. package/dist/src/grid/plugins/ValueAxis.d.ts +1 -1
  28. package/dist/src/grid/plugins/ValueStackAxis.d.ts +1 -1
  29. package/dist/src/grid/types.d.ts +1 -1
  30. package/dist/src/multiGrid/multiGridObservables.d.ts +1 -1
  31. package/dist/src/multiGrid/plugins/MultiBarStack.d.ts +1 -1
  32. package/dist/src/multiGrid/plugins/MultiBars.d.ts +1 -1
  33. package/dist/src/multiGrid/plugins/MultiBarsTriangle.d.ts +1 -1
  34. package/dist/src/multiGrid/plugins/MultiDots.d.ts +1 -1
  35. package/dist/src/multiGrid/plugins/MultiGridLegend.d.ts +1 -1
  36. package/dist/src/multiGrid/plugins/MultiGroupAxis.d.ts +1 -1
  37. package/dist/src/multiGrid/plugins/MultiLineAreas.d.ts +1 -1
  38. package/dist/src/multiGrid/plugins/MultiLines.d.ts +1 -1
  39. package/dist/src/multiGrid/plugins/MultiValueAxis.d.ts +1 -1
  40. package/dist/src/multiGrid/plugins/MultiValueStackAxis.d.ts +1 -1
  41. package/dist/src/multiGrid/plugins/OverlappingValueAxes.d.ts +1 -1
  42. package/dist/src/multiGrid/plugins/OverlappingValueStackAxes.d.ts +1 -1
  43. package/dist/src/multiGrid/types.d.ts +1 -1
  44. package/dist/src/noneData/plugins/Container.d.ts +1 -1
  45. package/dist/src/noneData/plugins/Tooltip.d.ts +2 -2
  46. package/dist/src/noneData/types.d.ts +1 -1
  47. package/dist/src/series/plugins/Bubbles.d.ts +1 -1
  48. package/dist/src/series/plugins/Pie.d.ts +1 -1
  49. package/dist/src/series/plugins/PieEventTexts.d.ts +1 -1
  50. package/dist/src/series/plugins/PieLabels.d.ts +1 -1
  51. package/dist/src/series/plugins/Rose.d.ts +2 -2
  52. package/dist/src/series/plugins/RoseLabels.d.ts +1 -1
  53. package/dist/src/series/plugins/SeriesLegend.d.ts +1 -1
  54. package/dist/src/series/seriesObservables.d.ts +1 -1
  55. package/dist/src/series/seriesUtils.d.ts +1 -1
  56. package/dist/src/series/types.d.ts +1 -1
  57. package/dist/src/tree/plugins/TreeLegend.d.ts +1 -1
  58. package/dist/src/tree/plugins/TreeMap.d.ts +1 -1
  59. package/dist/src/tree/types.d.ts +1 -1
  60. package/dist/src/utils/orbchartsUtils.d.ts +1 -1
  61. package/lib/core-types.ts +7 -0
  62. package/lib/core.ts +6 -0
  63. package/package.json +3 -2
  64. package/src/base/BaseBarStack.ts +1 -1
  65. package/src/base/BaseBars.ts +1 -1
  66. package/src/base/BaseBarsTriangle.ts +1 -1
  67. package/src/base/BaseDots.ts +1 -1
  68. package/src/base/BaseGroupAxis.ts +7 -4
  69. package/src/base/BaseLegend.ts +1 -1
  70. package/src/base/BaseLineAreas.ts +1 -2
  71. package/src/base/BaseLines.ts +1 -1
  72. package/src/base/BaseValueAxis.ts +2 -2
  73. package/src/const.ts +30 -0
  74. package/src/grid/gridObservables.ts +5 -3
  75. package/src/grid/plugins/BarStack.ts +23 -2
  76. package/src/grid/plugins/Bars.ts +27 -2
  77. package/src/grid/plugins/BarsPN.ts +27 -2
  78. package/src/grid/plugins/BarsTriangle.ts +33 -2
  79. package/src/grid/plugins/Dots.ts +33 -2
  80. package/src/grid/plugins/GridLegend.ts +39 -2
  81. package/src/grid/plugins/GroupAux.ts +115 -31
  82. package/src/grid/plugins/GroupAxis.ts +63 -2
  83. package/src/grid/plugins/LineAreas.ts +27 -2
  84. package/src/grid/plugins/Lines.ts +21 -2
  85. package/src/grid/plugins/ScalingArea.ts +105 -61
  86. package/src/grid/plugins/ValueAxis.ts +60 -3
  87. package/src/grid/plugins/ValueStackAxis.ts +60 -3
  88. package/src/grid/types.ts +1 -1
  89. package/src/multiGrid/multiGridObservables.ts +1 -1
  90. package/src/multiGrid/plugins/MultiBarStack.ts +30 -2
  91. package/src/multiGrid/plugins/MultiBars.ts +33 -2
  92. package/src/multiGrid/plugins/MultiBarsTriangle.ts +39 -2
  93. package/src/multiGrid/plugins/MultiDots.ts +39 -2
  94. package/src/multiGrid/plugins/MultiGridLegend.ts +61 -2
  95. package/src/multiGrid/plugins/MultiGroupAxis.ts +69 -2
  96. package/src/multiGrid/plugins/MultiLineAreas.ts +33 -3
  97. package/src/multiGrid/plugins/MultiLines.ts +27 -3
  98. package/src/multiGrid/plugins/MultiValueAxis.ts +66 -2
  99. package/src/multiGrid/plugins/MultiValueStackAxis.ts +66 -2
  100. package/src/multiGrid/plugins/OverlappingValueAxes.ts +133 -4
  101. package/src/multiGrid/plugins/OverlappingValueStackAxes.ts +133 -4
  102. package/src/multiGrid/types.ts +1 -1
  103. package/src/noneData/defaults.ts +8 -8
  104. package/src/noneData/plugins/Container.ts +19 -2
  105. package/src/noneData/plugins/Tooltip.ts +46 -4
  106. package/src/noneData/types.ts +1 -1
  107. package/src/series/defaults.ts +1 -1
  108. package/src/series/plugins/Bubbles.ts +61 -3
  109. package/src/series/plugins/Pie.ts +43 -4
  110. package/src/series/plugins/PieEventTexts.ts +25 -4
  111. package/src/series/plugins/PieLabels.ts +39 -3
  112. package/src/series/plugins/Rose.ts +38 -3
  113. package/src/series/plugins/RoseLabels.ts +32 -3
  114. package/src/series/plugins/SeriesLegend.ts +39 -2
  115. package/src/series/seriesObservables.ts +1 -1
  116. package/src/series/seriesUtils.ts +1 -1
  117. package/src/series/types.ts +1 -1
  118. package/src/tree/plugins/TreeLegend.ts +39 -2
  119. package/src/tree/plugins/TreeMap.ts +31 -3
  120. package/src/tree/types.ts +1 -1
  121. package/src/utils/orbchartsUtils.ts +1 -1
@@ -10,21 +10,150 @@ import {
10
10
  iif,
11
11
  Observable,
12
12
  Subject } from 'rxjs'
13
- import type { ContextObserverMultiGrid, DataFormatterGrid, DataFormatterTypeMap, Layout } from '@orbcharts/core'
13
+ import type { DefinePluginConfig } from '../../../lib/core-types'
14
+ import type { ContextObserverMultiGrid, DataFormatterGrid, DataFormatterTypeMap, Layout } from '../../../lib/core-types'
14
15
  import {
15
- defineMultiGridPlugin } from '@orbcharts/core'
16
+ defineMultiGridPlugin } from '../../../lib/core'
16
17
  import { DEFAULT_OVERLAPPING_VALUE_STACK_AXES_PARAMS } from '../defaults'
17
18
  import { createBaseValueAxis } from '../../base/BaseValueAxis'
18
19
  import { multiGridPluginDetailObservables } from '../multiGridObservables'
19
20
  import { getClassName, getUniID } from '../../utils/orbchartsUtils'
20
- import { gridAxesTransformObservable, gridAxesReverseTransformObservable, gridContainerPositionObservable } from '@orbcharts/core/src/grid/gridObservables'
21
+ import { gridAxesTransformObservable, gridAxesReverseTransformObservable, gridContainerPositionObservable } from '../../../lib/core'
22
+ import { LAYER_INDEX_OF_AXIS } from '../../const'
21
23
 
22
24
  const pluginName = 'OverlappingValueStackAxes'
23
25
 
24
26
  const gridClassName = getClassName(pluginName, 'grid')
25
27
 
28
+ const pluginConfig: DefinePluginConfig<typeof pluginName, typeof DEFAULT_OVERLAPPING_VALUE_STACK_AXES_PARAMS> = {
29
+ name: pluginName,
30
+ defaultParams: DEFAULT_OVERLAPPING_VALUE_STACK_AXES_PARAMS,
31
+ layerIndex: LAYER_INDEX_OF_AXIS,
32
+ validator: (params, { validateColumns }) => {
33
+ const result = validateColumns(params, {
34
+ firstAxis: {
35
+ toBeTypes: ['object']
36
+ },
37
+ secondAxis: {
38
+ toBeTypes: ['object']
39
+ },
40
+ gridIndexes: {
41
+ toBe: '[number, number]',
42
+ test: (value: any) => {
43
+ return Array.isArray(value) && value.length === 2
44
+ }
45
+ }
46
+ })
47
+ if (params.firstAxis) {
48
+ const firstAxisResult = validateColumns(params.firstAxis, {
49
+ labelOffset: {
50
+ toBe: '[number, number]',
51
+ test: (value: any) => {
52
+ return Array.isArray(value)
53
+ && value.length === 2
54
+ && typeof value[0] === 'number'
55
+ && typeof value[1] === 'number'
56
+ }
57
+ },
58
+ labelColorType: {
59
+ toBeOption: 'ColorType',
60
+ },
61
+ axisLineVisible: {
62
+ toBeTypes: ['boolean']
63
+ },
64
+ axisLineColorType: {
65
+ toBeOption: 'ColorType',
66
+ },
67
+ ticks: {
68
+ toBeTypes: ['number']
69
+ },
70
+ tickFormat: {
71
+ toBeTypes: ['string', 'Function']
72
+ },
73
+ tickLineVisible: {
74
+ toBeTypes: ['boolean']
75
+ },
76
+ tickPadding: {
77
+ toBeTypes: ['number']
78
+ },
79
+ tickFullLine: {
80
+ toBeTypes: ['boolean']
81
+ },
82
+ tickFullLineDasharray: {
83
+ toBeTypes: ['string']
84
+ },
85
+ tickColorType: {
86
+ toBeOption: 'ColorType',
87
+ },
88
+ tickTextRotate: {
89
+ toBeTypes: ['number']
90
+ },
91
+ tickTextColorType: {
92
+ toBeOption: 'ColorType',
93
+ }
94
+ })
95
+ if (firstAxisResult.status === 'error') {
96
+ return firstAxisResult
97
+ }
98
+ }
99
+ if (params.secondAxis) {
100
+ const secondAxisResult = validateColumns(params.secondAxis, {
101
+ labelOffset: {
102
+ toBe: '[number, number]',
103
+ test: (value: any) => {
104
+ return Array.isArray(value)
105
+ && value.length === 2
106
+ && typeof value[0] === 'number'
107
+ && typeof value[1] === 'number'
108
+ }
109
+ },
110
+ labelColorType: {
111
+ toBeOption: 'ColorType',
112
+ },
113
+ axisLineVisible: {
114
+ toBeTypes: ['boolean']
115
+ },
116
+ axisLineColorType: {
117
+ toBeOption: 'ColorType',
118
+ },
119
+ ticks: {
120
+ toBeTypes: ['number']
121
+ },
122
+ tickFormat: {
123
+ toBeTypes: ['string', 'Function']
124
+ },
125
+ tickLineVisible: {
126
+ toBeTypes: ['boolean']
127
+ },
128
+ tickPadding: {
129
+ toBeTypes: ['number']
130
+ },
131
+ tickFullLine: {
132
+ toBeTypes: ['boolean']
133
+ },
134
+ tickFullLineDasharray: {
135
+ toBeTypes: ['string']
136
+ },
137
+ tickColorType: {
138
+ toBeOption: 'ColorType',
139
+ },
140
+ tickTextRotate: {
141
+ toBeTypes: ['number']
142
+ },
143
+ tickTextColorType: {
144
+ toBeOption: 'ColorType',
145
+ }
146
+ })
147
+ if (secondAxisResult.status === 'error') {
148
+ return secondAxisResult
149
+ }
150
+ }
151
+ return result
152
+ }
153
+ }
154
+
26
155
  // 第一個圖軸使用堆疊的資料,第二個圖軸使用原始資料
27
- export const OverlappingValueStackAxes = defineMultiGridPlugin(pluginName, DEFAULT_OVERLAPPING_VALUE_STACK_AXES_PARAMS)(({ selection, name, subject, observer }) => {
156
+ export const OverlappingValueStackAxes = defineMultiGridPlugin(pluginConfig)(({ selection, name, subject, observer }) => {
28
157
  const destroy$ = new Subject()
29
158
 
30
159
  const unsubscribeFnArr: (() => void)[] = []
@@ -7,7 +7,7 @@ import type { BaseDotsParams } from '../base/BaseDots'
7
7
  import type { BaseGroupAxisParams } from '../base/BaseGroupAxis'
8
8
  import type { BaseValueAxisParams } from '../base/BaseValueAxis'
9
9
  import type {
10
- ChartParams, Layout, ColorType } from '@orbcharts/core'
10
+ ChartParams, Layout, ColorType } from '../../lib/core-types'
11
11
 
12
12
  export interface MultiGridLegendParams {
13
13
  position: 'top' | 'bottom' | 'left' | 'right'
@@ -1,5 +1,5 @@
1
1
  import type { ContainerPluginParams, TooltipParams } from './types'
2
- import type { EventBaseSeriesValue, EventBaseGridValue, EventBaseCategoryValue } from '@orbcharts/core'
2
+ import type { EventTypeMap, EventBaseSeriesValue, EventBaseGridValue, EventBaseCategoryValue } from '../../lib/core-types'
3
3
 
4
4
  export const CONTAINER_PLUGIN_PARAMS: ContainerPluginParams = {
5
5
  header: {
@@ -23,10 +23,10 @@ export const TOOLTIP_PARAMS: TooltipParams = {
23
23
  padding: 10,
24
24
  textRenderFn: (eventData) => {
25
25
  if (eventData.highlightTarget === 'datum' && eventData.datum) {
26
- return [`${eventData.datum.label}: ${eventData.datum.value}`]
26
+ return [`${(eventData as EventTypeMap<'series'>).datum.label}: ${(eventData as EventTypeMap<'series'>).datum.value}`]
27
27
  } else if (eventData.highlightTarget === 'series') {
28
- const label = (eventData as EventBaseSeriesValue<any, any>).seriesLabel
29
- const valueArr = (eventData as EventBaseSeriesValue<any, any>).series
28
+ const label = (eventData as EventBaseSeriesValue).seriesLabel
29
+ const valueArr = (eventData as EventBaseSeriesValue).series
30
30
  .filter(d => d.visible == true)
31
31
  .map(d => {
32
32
  return d.value
@@ -36,8 +36,8 @@ export const TOOLTIP_PARAMS: TooltipParams = {
36
36
  : valueArr.join(',')
37
37
  return [label, value]
38
38
  } else if (eventData.highlightTarget === 'group') {
39
- const label = (eventData as EventBaseGridValue<any, any>).groupLabel
40
- const valueArr = (eventData as EventBaseGridValue<any, any>).series
39
+ const label = (eventData as EventBaseGridValue<'grid'>).groupLabel
40
+ const valueArr = (eventData as EventBaseGridValue<'grid'>).series
41
41
  .filter(d => d.visible == true)
42
42
  .map(d => {
43
43
  return d.value
@@ -47,8 +47,8 @@ export const TOOLTIP_PARAMS: TooltipParams = {
47
47
  : valueArr.join(',')
48
48
  return [label, value]
49
49
  } else if (eventData.highlightTarget === 'category') {
50
- const label = (eventData as EventBaseCategoryValue<any, any>).categoryLabel
51
- const valueArr = (eventData as EventBaseCategoryValue<any, any>).category
50
+ const label = (eventData as EventBaseCategoryValue<any>).categoryLabel
51
+ const valueArr = (eventData as EventBaseCategoryValue<'multiValue'>).category
52
52
  .filter(d => d.visible == true)
53
53
  .map(d => {
54
54
  return d.value
@@ -1,9 +1,26 @@
1
1
  import * as d3 from 'd3'
2
+ import type { DefinePluginConfig } from '../../../lib/core-types'
2
3
  import {
3
- defineNoneDataPlugin } from '@orbcharts/core'
4
+ defineNoneDataPlugin } from '../../../lib/core'
4
5
  import { CONTAINER_PLUGIN_PARAMS } from '../defaults'
6
+ import { LAYER_INDEX_OF_BG } from '../../const'
5
7
 
6
- export const Container = defineNoneDataPlugin('Container', CONTAINER_PLUGIN_PARAMS)(({ selection }) => {
8
+ const pluginName = 'Container'
9
+
10
+ const pluginConfig: DefinePluginConfig<typeof pluginName, typeof CONTAINER_PLUGIN_PARAMS> = {
11
+ name: pluginName,
12
+ defaultParams: CONTAINER_PLUGIN_PARAMS,
13
+ layerIndex: LAYER_INDEX_OF_BG,
14
+ validator: (params, { validateColumns }) => {
15
+ return {
16
+ status: 'success',
17
+ columnName: '',
18
+ expectToBe: '',
19
+ }
20
+ }
21
+ }
22
+
23
+ export const Container = defineNoneDataPlugin(pluginConfig)(({ selection }) => {
7
24
 
8
25
  return function unsubscribe () {
9
26
 
@@ -11,13 +11,14 @@ import {
11
11
  Subject,
12
12
  Observable,
13
13
  distinctUntilChanged } from 'rxjs'
14
+ import type { DefinePluginConfig } from '../../../lib/core-types'
14
15
  import type {
15
- EventTypeMap, PluginConstructor, ChartType } from '@orbcharts/core'
16
- import { defineNoneDataPlugin } from '@orbcharts/core'
16
+ EventTypeMap, PluginConstructor, ChartType } from '../../../lib/core-types'
17
+ import { defineNoneDataPlugin, textSizePxObservable } from '../../../lib/core'
17
18
  import { getSvgGElementSize, appendSvg } from '../../utils/d3Utils'
18
19
  import { getColor, getClassName } from '../../utils/orbchartsUtils'
19
20
  import { TOOLTIP_PARAMS } from '../defaults'
20
- import { textSizePxObservable } from '@orbcharts/core'
21
+ import { LAYER_INDEX_OF_TOOLTIP } from '../../const'
21
22
 
22
23
  interface TooltipStyle {
23
24
  backgroundColor: string
@@ -205,7 +206,48 @@ function renderTooltip ({ rootSelection, pluginName, rootWidth, rootHeight, svgS
205
206
 
206
207
  }
207
208
 
208
- export const Tooltip: PluginConstructor<any, string, any> = defineNoneDataPlugin(pluginName, TOOLTIP_PARAMS)(({ selection, rootSelection, name, chartType, observer, subject }) => {
209
+ const pluginConfig: DefinePluginConfig<typeof pluginName, typeof TOOLTIP_PARAMS> = {
210
+ name: pluginName,
211
+ defaultParams: TOOLTIP_PARAMS,
212
+ layerIndex: LAYER_INDEX_OF_TOOLTIP,
213
+ validator: (params, { validateColumns }) => {
214
+ const result = validateColumns(params, {
215
+ backgroundColorType: {
216
+ toBeOption: 'ColorType',
217
+ },
218
+ backgroundOpacity: {
219
+ toBeTypes: ['number']
220
+ },
221
+ strokeColorType: {
222
+ toBeOption: 'ColorType',
223
+ },
224
+ offset: {
225
+ toBe: '[number, number]',
226
+ test: (value: any) => {
227
+ return Array.isArray(value)
228
+ && value.length === 2
229
+ && typeof value[0] === 'number'
230
+ && typeof value[1] === 'number'
231
+ }
232
+ },
233
+ padding: {
234
+ toBeTypes: ['number']
235
+ },
236
+ textColorType: {
237
+ toBeOption: 'ColorType',
238
+ },
239
+ textRenderFn: {
240
+ toBeTypes: ['Function']
241
+ },
242
+ svgRenderFn: {
243
+ toBeTypes: ['Function']
244
+ }
245
+ })
246
+ return result
247
+ }
248
+ }
249
+
250
+ export const Tooltip = defineNoneDataPlugin(pluginConfig)(({ selection, rootSelection, name, chartType, observer, subject }) => {
209
251
  const destroy$ = new Subject()
210
252
 
211
253
  // 事件觸發
@@ -1,4 +1,4 @@
1
- import type { ColorType, ChartType, EventTypeMap, EventBase } from '@orbcharts/core'
1
+ import type { ColorType, ChartType, EventTypeMap, EventBase } from '../../lib/core-types'
2
2
 
3
3
  export interface ContainerPluginParams {
4
4
  header: {
@@ -1,4 +1,4 @@
1
- import type { ComputedDatumSeries, EventSeries, EventName, ColorType } from '@orbcharts/core'
1
+ import type { ComputedDatumSeries, EventSeries, EventName, ColorType } from '../../lib/core-types'
2
2
  import type {
3
3
  BubblesParams,
4
4
  PieParams,
@@ -9,6 +9,7 @@ import {
9
9
  Observable,
10
10
  distinctUntilChanged,
11
11
  shareReplay} from 'rxjs'
12
+ import type { DefinePluginConfig } from '../../../lib/core-types'
12
13
  import type {
13
14
  ChartParams,
14
15
  DatumValue,
@@ -16,12 +17,13 @@ import type {
16
17
  EventName,
17
18
  ComputedDataSeries,
18
19
  ComputedDatumSeries,
19
- SeriesContainerPosition } from '@orbcharts/core'
20
+ SeriesContainerPosition } from '../../../lib/core-types'
20
21
  import {
21
- defineSeriesPlugin } from '@orbcharts/core'
22
+ defineSeriesPlugin } from '../../../lib/core'
22
23
  import type { BubblesParams, ArcScaleType } from '../types'
23
24
  import { DEFAULT_BUBBLES_PARAMS } from '../defaults'
24
25
  import { renderCircleText } from '../../utils/d3Graphics'
26
+ import { LAYER_INDEX_OF_GRAPHIC } from '../../const'
25
27
 
26
28
  interface BubblesDatum extends ComputedDatumSeries {
27
29
  x: number
@@ -32,6 +34,61 @@ interface BubblesDatum extends ComputedDatumSeries {
32
34
 
33
35
  type BubblesSimulationDatum = BubblesDatum & d3.SimulationNodeDatum
34
36
 
37
+ const pluginName = 'Bubbles'
38
+
39
+ const pluginConfig: DefinePluginConfig<typeof pluginName, typeof DEFAULT_BUBBLES_PARAMS> = {
40
+ name: pluginName,
41
+ defaultParams: DEFAULT_BUBBLES_PARAMS,
42
+ layerIndex: LAYER_INDEX_OF_GRAPHIC,
43
+ validator: (params, { validateColumns }) => {
44
+ const result = validateColumns(params, {
45
+ force: {
46
+ toBeTypes: ['object']
47
+ },
48
+ bubbleText: {
49
+ toBeTypes: ['object']
50
+ },
51
+ arcScaleType: {
52
+ toBe: '"area" | "radius"',
53
+ test: (value) => value === 'area' || value === 'radius'
54
+ }
55
+ })
56
+ if (params.force) {
57
+ const forceResult = validateColumns(params.force, {
58
+ velocityDecay: {
59
+ toBeTypes: ['number']
60
+ },
61
+ collisionSpacing: {
62
+ toBeTypes: ['number']
63
+ },
64
+ strength: {
65
+ toBeTypes: ['number']
66
+ },
67
+ })
68
+ if (forceResult.status === 'error') {
69
+ return forceResult
70
+ }
71
+ }
72
+ if (params.bubbleText) {
73
+ const bubbleTextResult = validateColumns(params.bubbleText, {
74
+ fillRate: {
75
+ toBeTypes: ['number']
76
+ },
77
+ lineHeight: {
78
+ toBeTypes: ['number']
79
+ },
80
+ lineLengthMin: {
81
+ toBeTypes: ['number']
82
+ },
83
+ })
84
+ if (bubbleTextResult.status === 'error') {
85
+ return bubbleTextResult
86
+ }
87
+ }
88
+ return result
89
+ }
90
+ }
91
+
35
92
  let force: d3.Simulation<d3.SimulationNodeDatum, undefined> | undefined
36
93
 
37
94
  function makeForce (bubblesSelection: d3.Selection<SVGGElement, any, any, any>, fullParams: BubblesParams) {
@@ -320,7 +377,8 @@ function highlight ({ bubblesSelection, highlightIds, fullChartParams }: {
320
377
  })
321
378
  }
322
379
 
323
- export const Bubbles = defineSeriesPlugin('Bubbles', DEFAULT_BUBBLES_PARAMS)(({ selection, name, observer, subject }) => {
380
+
381
+ export const Bubbles = defineSeriesPlugin(pluginConfig)(({ selection, name, observer, subject }) => {
324
382
 
325
383
  const destroy$ = new Subject()
326
384
 
@@ -8,26 +8,65 @@ import {
8
8
  shareReplay,
9
9
  Observable,
10
10
  Subject } from 'rxjs'
11
+ import type { DefinePluginConfig } from '../../../lib/core-types'
11
12
  import type {
12
13
  ComputedDataSeries,
13
14
  ComputedDatumSeries,
14
15
  SeriesContainerPosition,
15
16
  ChartParams,
16
17
  EventSeries,
17
- Layout } from '@orbcharts/core'
18
+ Layout } from '../../../lib/core-types'
18
19
  import type { PieDatum } from '../seriesUtils'
19
20
  import type { PieParams } from '../types'
20
21
  import {
21
- defineSeriesPlugin } from '@orbcharts/core'
22
+ defineSeriesPlugin } from '../../../lib/core'
22
23
  import { DEFAULT_PIE_PARAMS } from '../defaults'
23
24
  import { makePieData } from '../seriesUtils'
24
25
  import { getD3TransitionEase, makeD3Arc } from '../../utils/d3Utils'
25
26
  import { getDatumColor, getClassName } from '../../utils/orbchartsUtils'
26
27
  import { seriesCenterSelectionObservable } from '../seriesObservables'
27
-
28
+ import { LAYER_INDEX_OF_GRAPHIC } from '../../const'
28
29
 
29
30
  const pluginName = 'Pie'
30
31
 
32
+ const pluginConfig: DefinePluginConfig<typeof pluginName, typeof DEFAULT_PIE_PARAMS> = {
33
+ name: pluginName,
34
+ defaultParams: DEFAULT_PIE_PARAMS,
35
+ layerIndex: LAYER_INDEX_OF_GRAPHIC,
36
+ validator: (params, { validateColumns }) => {
37
+ const result = validateColumns(params, {
38
+ outerRadius: {
39
+ toBeTypes: ['number'],
40
+ },
41
+ innerRadius: {
42
+ toBeTypes: ['number'],
43
+ },
44
+ outerRadiusWhileHighlight: {
45
+ toBeTypes: ['number'],
46
+ },
47
+ startAngle: {
48
+ toBeTypes: ['number'],
49
+ },
50
+ endAngle: {
51
+ toBeTypes: ['number'],
52
+ },
53
+ padAngle: {
54
+ toBeTypes: ['number'],
55
+ },
56
+ strokeColorType: {
57
+ toBeTypes: ['string'],
58
+ },
59
+ strokeWidth: {
60
+ toBeTypes: ['number'],
61
+ },
62
+ cornerRadius: {
63
+ toBeTypes: ['number'],
64
+ }
65
+ })
66
+
67
+ return result
68
+ }
69
+ }
31
70
 
32
71
  function makeTweenPieRenderDataFn ({ enter, exit, data, lastTweenData, fullParams }: {
33
72
  enter: d3.Selection<d3.EnterElement, PieDatum, any, any>
@@ -524,7 +563,7 @@ function createEachPie (pluginName: string, context: {
524
563
  }
525
564
  }
526
565
 
527
- export const Pie = defineSeriesPlugin(pluginName, DEFAULT_PIE_PARAMS)(({ selection, name, subject, observer }) => {
566
+ export const Pie = defineSeriesPlugin(pluginConfig)(({ selection, name, subject, observer }) => {
528
567
  const destroy$ = new Subject()
529
568
 
530
569
  const { seriesCenterSelection$ } = seriesCenterSelectionObservable({
@@ -8,21 +8,22 @@ import {
8
8
  distinctUntilChanged,
9
9
  Observable,
10
10
  Subject } from 'rxjs'
11
+ import type { DefinePluginConfig } from '../../../lib/core-types'
11
12
  import type { Subscription } from 'rxjs'
12
13
  import {
13
- defineSeriesPlugin} from '@orbcharts/core'
14
+ defineSeriesPlugin} from '../../../lib/core'
14
15
  import type {
15
16
  ComputedDatumSeries,
16
17
  ChartParams,
17
18
  SeriesContainerPosition,
18
19
  EventName,
19
- EventSeries } from '@orbcharts/core'
20
+ EventSeries } from '../../../lib/core-types'
20
21
  import type { PieEventTextsParams } from '../types'
21
22
  import { DEFAULT_PIE_EVENT_TEXTS_PARAMS } from '../defaults'
22
23
  import { getD3TransitionEase } from '../../utils/d3Utils'
23
24
  import { getClassName } from '../../utils/orbchartsUtils'
24
25
  import { seriesCenterSelectionObservable } from '../seriesObservables'
25
-
26
+ import { LAYER_INDEX_OF_LABEL } from '../../const'
26
27
 
27
28
  type TextDatum = {
28
29
  text: string
@@ -33,6 +34,26 @@ type TextDatum = {
33
34
  const pluginName = 'PieEventTexts'
34
35
  const textClassName = getClassName(pluginName, 'text')
35
36
 
37
+ const pluginConfig: DefinePluginConfig<typeof pluginName, typeof DEFAULT_PIE_EVENT_TEXTS_PARAMS> = {
38
+ name: pluginName,
39
+ defaultParams: DEFAULT_PIE_EVENT_TEXTS_PARAMS,
40
+ layerIndex: LAYER_INDEX_OF_LABEL,
41
+ validator: (params, { validateColumns }) => {
42
+ const result = validateColumns(params, {
43
+ eventFn: {
44
+ toBeTypes: ['Function'],
45
+ },
46
+ textAttrs: {
47
+ toBeTypes: ['object[]'],
48
+ },
49
+ textStyles: {
50
+ toBeTypes: ['object[]'],
51
+ }
52
+ })
53
+ return result
54
+ }
55
+ }
56
+
36
57
  function renderText (
37
58
  selection: d3.Selection<SVGGElement, unknown, any, any>,
38
59
  data: Array<TextDatum>
@@ -205,7 +226,7 @@ function createEachPieEventTexts (pluginName: string, context: {
205
226
  }
206
227
  }
207
228
 
208
- export const PieEventTexts = defineSeriesPlugin(pluginName, DEFAULT_PIE_EVENT_TEXTS_PARAMS)(({ selection, name, observer, subject }) => {
229
+ export const PieEventTexts = defineSeriesPlugin(pluginConfig)(({ selection, name, observer, subject }) => {
209
230
  const destroy$ = new Subject()
210
231
 
211
232
  const { seriesCenterSelection$ } = seriesCenterSelectionObservable({
@@ -9,13 +9,14 @@ import {
9
9
  distinctUntilChanged,
10
10
  Subject,
11
11
  BehaviorSubject } from 'rxjs'
12
+ import type { DefinePluginConfig } from '../../../lib/core-types'
12
13
  import {
13
- defineSeriesPlugin } from '@orbcharts/core'
14
+ defineSeriesPlugin } from '../../../lib/core'
14
15
  import type {
15
16
  ComputedDatumSeries,
16
17
  SeriesContainerPosition,
17
18
  EventSeries,
18
- ChartParams } from '@orbcharts/core'
19
+ ChartParams } from '../../../lib/core-types'
19
20
  import type { PieLabelsParams } from '../types'
20
21
  import type { PieDatum } from '../seriesUtils'
21
22
  import { DEFAULT_PIE_LABELS_PARAMS } from '../defaults'
@@ -24,6 +25,8 @@ import { makeD3Arc } from '../../utils/d3Utils'
24
25
  import { getDatumColor, getClassName } from '../../utils/orbchartsUtils'
25
26
  import { seriesCenterSelectionObservable } from '../seriesObservables'
26
27
  import { renderTspansOnQuadrant } from '../../utils/d3Graphics'
28
+ import { LAYER_INDEX_OF_LABEL } from '../../const'
29
+ import {} from '../../../lib/core'
27
30
 
28
31
  interface RenderDatum {
29
32
  pieDatum: PieDatum
@@ -50,6 +53,39 @@ const textClassName = getClassName(pluginName, 'text')
50
53
 
51
54
  const pieOuterCentroid = 2
52
55
 
56
+ const pluginConfig: DefinePluginConfig<typeof pluginName, typeof DEFAULT_PIE_LABELS_PARAMS> = {
57
+ name: pluginName,
58
+ defaultParams: DEFAULT_PIE_LABELS_PARAMS,
59
+ layerIndex: LAYER_INDEX_OF_LABEL,
60
+ validator: (params, { validateColumns }) => {
61
+ const result = validateColumns(params, {
62
+ outerRadius: {
63
+ toBeTypes: ['number'],
64
+ },
65
+ outerRadiusWhileHighlight: {
66
+ toBeTypes: ['number'],
67
+ },
68
+ startAngle: {
69
+ toBeTypes: ['number'],
70
+ },
71
+ endAngle: {
72
+ toBeTypes: ['number'],
73
+ },
74
+ labelCentroid: {
75
+ toBeTypes: ['number'],
76
+ },
77
+ labelFn: {
78
+ toBeTypes: ['Function'],
79
+ },
80
+ labelColorType: {
81
+ toBeOption: 'ColorType'
82
+ }
83
+ })
84
+ return result
85
+ }
86
+ }
87
+
88
+
53
89
  function makeRenderData ({ pieData, arc, arcMouseover, labelCentroid, lineStartCentroid, fullParams }: {
54
90
  pieData: PieDatum[]
55
91
  arc: d3.Arc<any, d3.DefaultArcObject>
@@ -546,7 +582,7 @@ function createEachPieLabel (pluginName: string, context: {
546
582
  }
547
583
 
548
584
 
549
- export const PieLabels = defineSeriesPlugin(pluginName, DEFAULT_PIE_LABELS_PARAMS)(({ selection, observer, subject }) => {
585
+ export const PieLabels = defineSeriesPlugin(pluginConfig)(({ selection, observer, subject }) => {
550
586
 
551
587
  const destroy$ = new Subject()
552
588