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

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -9,27 +9,38 @@ import {
9
9
  takeUntil,
10
10
  debounceTime,
11
11
  Subject } from 'rxjs'
12
- import type { DataFormatterGrid } from '@orbcharts/core'
12
+ import type { DefinePluginConfig } from '../../../lib/core-types'
13
+ import type { DataFormatterGrid } from '../../../lib/core-types'
13
14
  import {
14
- defineGridPlugin } from '@orbcharts/core'
15
+ defineGridPlugin, createAxisLinearScale } from '../../../lib/core'
15
16
  import { DEFAULT_SCALING_AREA_PARAMS } from '../defaults'
16
17
  import { getClassName, getUniID } from '../../utils/orbchartsUtils'
17
- import { createAxisPointScale, createAxisLinearScale } from '@orbcharts/core'
18
+ import { LAYER_INDEX_OF_ROOT } from '../../const'
18
19
 
19
20
  const pluginName = 'ScalingArea'
20
21
  const rectClassName = getClassName(pluginName, 'rect')
21
22
 
22
- export const ScalingArea = defineGridPlugin(pluginName, DEFAULT_SCALING_AREA_PARAMS)(({ selection, rootSelection, name, observer, subject }) => {
23
+ const pluginConfig: DefinePluginConfig<typeof pluginName, typeof DEFAULT_SCALING_AREA_PARAMS> = {
24
+ name: pluginName,
25
+ defaultParams: DEFAULT_SCALING_AREA_PARAMS,
26
+ layerIndex: LAYER_INDEX_OF_ROOT,
27
+ validator: (params, { validateColumns }) => {
28
+ return {
29
+ status: 'success',
30
+ columnName: '',
31
+ expectToBe: ''
32
+ }
33
+ }
34
+ }
35
+
36
+ export const ScalingArea = defineGridPlugin(pluginConfig)(({ selection, rootSelection, name, observer, subject }) => {
23
37
 
24
38
  const destroy$ = new Subject()
25
39
 
26
- const rootRectSelection: d3.Selection<SVGRectElement, any, any, any> = rootSelection
27
- .insert('rect', 'g')
28
- .classed(rectClassName, true)
29
- .attr('opacity', 0)
30
- // .attr('pointer-events', 'none')
31
- // .attr('clip-path', 'url(#bpcharts__clipPath-box)')
32
- // const dataAreaSelection: d3.Selection<SVGGElement, any, any, any> = axisSelection.append('g')
40
+ // const rootRectSelection: d3.Selection<SVGRectElement, any, any, any> = rootSelection
41
+ // .append('rect')
42
+ // .classed(rectClassName, true)
43
+ // .attr('opacity', 0)
33
44
 
34
45
  // 紀錄zoom最後一次的transform
35
46
  let lastTransform = {
@@ -37,18 +48,19 @@ export const ScalingArea = defineGridPlugin(pluginName, DEFAULT_SCALING_AREA_PAR
37
48
  x: 0,
38
49
  y: 0
39
50
  }
40
-
41
- observer.layout$.pipe(
42
- takeUntil(destroy$),
43
- ).subscribe(d => {
44
- rootRectSelection
45
- .attr('width', d.width)
46
- .attr('height', d.height)
47
- .attr('x', d.left)
48
- .attr('y', d.top)
49
- })
50
-
51
- const groupMaxIndex$ = observer.computedData$.pipe(
51
+ // let lastDomain: [number, number] = [0, 0]
52
+
53
+ // observer.layout$.pipe(
54
+ // takeUntil(destroy$),
55
+ // ).subscribe(d => {
56
+ // rootRectSelection
57
+ // .attr('width', d.width)
58
+ // .attr('height', d.height)
59
+ // .attr('x', d.left)
60
+ // .attr('y', d.top)
61
+ // })
62
+
63
+ const groupMax$ = observer.computedData$.pipe(
52
64
  map(d => d[0] ? d[0].length - 1 : 0),
53
65
  distinctUntilChanged()
54
66
  )
@@ -63,45 +75,56 @@ export const ScalingArea = defineGridPlugin(pluginName, DEFAULT_SCALING_AREA_PAR
63
75
  // store.fullDataFormatter$.next(fullDataFormatter)
64
76
  // })
65
77
 
66
- combineLatest({
67
- initGroupAxis: observer.fullDataFormatter$.pipe(
68
- map(d => d.grid.groupAxis),
69
- // 只用第一次資料來計算scale才不會造成每次變動都受到影響
70
- first()
71
- ),
72
- // fullDataFormatter: fullDataFormatter$.pipe(first()), // 只用第一次資料來計算scale才不會造成每次變動都受到影響
78
+ const initGroupAxis$ = observer.fullDataFormatter$.pipe(
79
+ map(d => d.grid.groupAxis),
80
+ // 只用第一次資料來計算scale才不會造成每次變動都受到影響
81
+ first()
82
+ )
83
+
84
+
85
+ const groupScale$ = combineLatest({
86
+ initGroupAxis: initGroupAxis$,
73
87
  fullDataFormatter: observer.fullDataFormatter$,
74
- groupMaxIndex: groupMaxIndex$,
88
+ groupMax: groupMax$,
75
89
  layout: observer.layout$,
76
90
  axisSize: observer.gridAxesSize$
91
+ }).pipe(
92
+ takeUntil(destroy$),
93
+ switchMap(async (d) => d),
94
+ map(data => {
95
+ // const groupMin = 0
96
+ const groupScaleDomainMin = data.initGroupAxis.scaleDomain[0] - data.initGroupAxis.scalePadding
97
+ const groupScaleDomainMax = data.initGroupAxis.scaleDomain[1] === 'max'
98
+ ? data.groupMax + data.initGroupAxis.scalePadding
99
+ : data.initGroupAxis.scaleDomain[1] as number + data.initGroupAxis.scalePadding
100
+
101
+ const groupScale: d3.ScaleLinear<number, number> = createAxisLinearScale({
102
+ maxValue: data.groupMax,
103
+ minValue: 0,
104
+ axisWidth: data.axisSize.width,
105
+ scaleDomain: [groupScaleDomainMin, groupScaleDomainMax],
106
+ scaleRange: [0, 1]
107
+ })
108
+
109
+ return groupScale
110
+ })
111
+ )
112
+
113
+ combineLatest({
114
+ groupScale: groupScale$,
115
+ // initGroupAxis: initGroupAxis$,
116
+ // fullDataFormatter: fullDataFormatter$.pipe(first()), // 只用第一次資料來計算scale才不會造成每次變動都受到影響
117
+ fullDataFormatter: observer.fullDataFormatter$,
118
+ groupMax: groupMax$,
119
+ // layout: observer.layout$,
120
+ // axisSize: observer.gridAxesSize$
77
121
  }).pipe(
78
122
  takeUntil(destroy$),
79
123
  switchMap(async (d) => d),
80
124
  ).subscribe(data => {
81
125
  const groupMin = 0
82
- const groupMax = data.groupMaxIndex
83
- // const groupScaleDomainMin = data.initGroupAxis.scaleDomain[0] === 'min'
84
- // ? groupMin - data.initGroupAxis.scalePadding
85
- // : data.initGroupAxis.scaleDomain[0] as number - data.initGroupAxis.scalePadding
86
- const groupScaleDomainMin = data.initGroupAxis.scaleDomain[0] - data.initGroupAxis.scalePadding
87
- const groupScaleDomainMax = data.initGroupAxis.scaleDomain[1] === 'max'
88
- ? groupMax + data.initGroupAxis.scalePadding
89
- : data.initGroupAxis.scaleDomain[1] as number + data.initGroupAxis.scalePadding
90
-
91
- // const scaleRange: [number, number] = data.fullDataFormatter.grid.valueAxis.position === 'left' || data.fullDataFormatter.grid.valueAxis.position === 'top'
92
- // ? [0, 1]
93
- // : [1, 0]
94
-
95
- const groupScale: d3.ScaleLinear<number, number> = createAxisLinearScale({
96
- maxValue: data.groupMaxIndex,
97
- minValue: 0,
98
- axisWidth: data.axisSize.width,
99
- scaleDomain: [groupScaleDomainMin, groupScaleDomainMax],
100
- // scaleDomain: [groupMin, groupMax],
101
- scaleRange: [0, 1]
102
- })
103
126
 
104
- const shadowScale = groupScale.copy()
127
+ const shadowScale = data.groupScale.copy()
105
128
 
106
129
  const zoom = d3.zoom()
107
130
  // .scaleExtent([1, data.groupMaxIndex])
@@ -110,11 +133,29 @@ export const ScalingArea = defineGridPlugin(pluginName, DEFAULT_SCALING_AREA_PAR
110
133
  // debugger
111
134
  // console.log('event', event)
112
135
  const t = event.transform;
113
- // console.log('t', t)
136
+
137
+ // if (event.sourceEvent.type === 'mousemove') {
138
+ // // 當進行平移時,反向計算 x 軸
139
+ // const dx = event.transform.x - currentTransform.x; // 本次平移增量
140
+ // const reversedX = currentTransform.x - dx; // 反向累積平移
141
+ // // 更新變換狀態
142
+ // currentTransform = d3.zoomIdentity
143
+ // .translate(reversedX, event.transform.y)
144
+ // .scale(event.transform.k);
145
+ // } else {
146
+ // // 縮放操作:只更新縮放比例
147
+ // currentTransform = d3.zoomIdentity
148
+ // .translate(currentTransform.x, currentTransform.y)
149
+ // .scale(event.transform.k);
150
+ // }
151
+ // console.log('currentTransform', currentTransform)
152
+
153
+ // console.log('t.x', t.x)
114
154
  const mapGroupindex = (d: number) => {
115
155
  const n = Math.round(d)
116
- return Math.min(groupMax, Math.max(groupMin, n));
156
+ return Math.min(data.groupMax, Math.max(groupMin, n));
117
157
  }
158
+
118
159
  const zoomedDomain = data.fullDataFormatter.grid.groupAxis.position === 'bottom' || data.fullDataFormatter.grid.groupAxis.position === 'top'
119
160
  ? t.rescaleX(shadowScale)
120
161
  .domain()
@@ -123,8 +164,9 @@ export const ScalingArea = defineGridPlugin(pluginName, DEFAULT_SCALING_AREA_PAR
123
164
  .domain()
124
165
  .map(mapGroupindex)
125
166
 
167
+
126
168
  // domain超過極限值
127
- if (zoomedDomain[0] <= groupMin && zoomedDomain[1] >= groupMax) {
169
+ if (zoomedDomain[0] <= groupMin && zoomedDomain[1] >= data.groupMax) {
128
170
  // 繼續縮小
129
171
  if (t.k < lastTransform.k) {
130
172
  // 維持前一次的transform
@@ -142,12 +184,12 @@ export const ScalingArea = defineGridPlugin(pluginName, DEFAULT_SCALING_AREA_PAR
142
184
  t.y = lastTransform.y
143
185
  }
144
186
  }
187
+
145
188
  // 紀錄transform
146
189
  lastTransform.k = t.k
147
190
  lastTransform.x = t.x
148
191
  lastTransform.y = t.y
149
- // console.log(String(data.fullDataFormatter.visibleFilter))
150
- // console.log('zoomedDomain', zoomedDomain)
192
+
151
193
 
152
194
  const newDataFormatter: DataFormatterGrid = {
153
195
  ...data.fullDataFormatter,
@@ -157,19 +199,21 @@ export const ScalingArea = defineGridPlugin(pluginName, DEFAULT_SCALING_AREA_PAR
157
199
  ...data.fullDataFormatter.grid.groupAxis,
158
200
  scaleDomain: zoomedDomain
159
201
  }
160
- },
202
+ }
161
203
  }
162
204
  subject.dataFormatter$.next(newDataFormatter)
163
205
  })
164
206
 
165
207
  // 傳入外層selection
166
208
  // subject.selection.call(zoom as any)
167
- rootSelection.call(zoom as any)
209
+ rootSelection.call(zoom)
168
210
 
169
211
  })
170
212
 
171
213
  return () => {
172
214
  destroy$.next(undefined)
173
- rootRectSelection.remove()
215
+ // rootRectSelection.remove()
216
+
217
+ rootSelection.call(d3.zoom().on('zoom', null))
174
218
  }
175
219
  })
@@ -5,15 +5,72 @@ import {
5
5
  distinctUntilChanged,
6
6
  shareReplay
7
7
  } from 'rxjs'
8
+ import type { DefinePluginConfig } from '../../../lib/core-types'
8
9
  import {
9
- defineGridPlugin } from '@orbcharts/core'
10
+ defineGridPlugin } from '../../../lib/core'
10
11
  import { DEFAULT_VALUE_AXIS_PARAMS } from '../defaults'
11
-
12
+ import { LAYER_INDEX_OF_AXIS } from '../../const'
12
13
  import { createBaseValueAxis } from '../../base/BaseValueAxis'
13
14
 
14
15
  const pluginName = 'ValueAxis'
15
16
 
16
- export const ValueAxis = defineGridPlugin(pluginName, DEFAULT_VALUE_AXIS_PARAMS)(({ selection, name, observer, subject }) => {
17
+ const pluginConfig: DefinePluginConfig<typeof pluginName, typeof DEFAULT_VALUE_AXIS_PARAMS> = {
18
+ name: pluginName,
19
+ defaultParams: DEFAULT_VALUE_AXIS_PARAMS,
20
+ layerIndex: LAYER_INDEX_OF_AXIS,
21
+ validator: (params, { validateColumns }) => {
22
+ const result = validateColumns(params, {
23
+ labelOffset: {
24
+ toBe: '[number, number]',
25
+ test: (value: any) => {
26
+ return Array.isArray(value)
27
+ && value.length === 2
28
+ && typeof value[0] === 'number'
29
+ && typeof value[1] === 'number'
30
+ }
31
+ },
32
+ labelColorType: {
33
+ toBeOption: 'ColorType',
34
+ },
35
+ axisLineVisible: {
36
+ toBeTypes: ['boolean']
37
+ },
38
+ axisLineColorType: {
39
+ toBeOption: 'ColorType',
40
+ },
41
+ ticks: {
42
+ toBeTypes: ['number', 'null']
43
+ },
44
+ tickFormat: {
45
+ toBeTypes: ['string', 'Function']
46
+ },
47
+ tickLineVisible: {
48
+ toBeTypes: ['boolean']
49
+ },
50
+ tickPadding: {
51
+ toBeTypes: ['number']
52
+ },
53
+ tickFullLine: {
54
+ toBeTypes: ['boolean']
55
+ },
56
+ tickFullLineDasharray: {
57
+ toBeTypes: ['string']
58
+ },
59
+ tickColorType: {
60
+ toBeOption: 'ColorType',
61
+ },
62
+ tickTextRotate: {
63
+ toBeTypes: ['number']
64
+ },
65
+ tickTextColorType: {
66
+ toBeOption: 'ColorType',
67
+ }
68
+ })
69
+ return result
70
+ }
71
+ }
72
+
73
+ export const ValueAxis = defineGridPlugin(pluginConfig)(({ selection, name, observer, subject }) => {
17
74
 
18
75
  const destroy$ = new Subject()
19
76
 
@@ -7,15 +7,72 @@ import {
7
7
  iif,
8
8
  Observable,
9
9
  Subject } from 'rxjs'
10
- import type { ComputedDataGrid } from '@orbcharts/core'
10
+ import type { DefinePluginConfig } from '../../../lib/core-types'
11
11
  import {
12
- defineGridPlugin } from '@orbcharts/core'
12
+ defineGridPlugin } from '../../../lib/core'
13
13
  import { DEFAULT_VALUE_STACK_AXIS_PARAMS } from '../defaults'
14
+ import { LAYER_INDEX_OF_AXIS } from '../../const'
14
15
  import { createBaseValueAxis } from '../../base/BaseValueAxis'
15
16
 
16
17
  const pluginName = 'ValueStackAxis'
17
18
 
18
- export const ValueStackAxis = defineGridPlugin(pluginName, DEFAULT_VALUE_STACK_AXIS_PARAMS)(({ selection, name, observer, subject }) => {
19
+ const pluginConfig: DefinePluginConfig<typeof pluginName, typeof DEFAULT_VALUE_STACK_AXIS_PARAMS> = {
20
+ name: pluginName,
21
+ defaultParams: DEFAULT_VALUE_STACK_AXIS_PARAMS,
22
+ layerIndex: LAYER_INDEX_OF_AXIS,
23
+ validator: (params, { validateColumns }) => {
24
+ const result = validateColumns(params, {
25
+ labelOffset: {
26
+ toBe: '[number, number]',
27
+ test: (value: any) => {
28
+ return Array.isArray(value)
29
+ && value.length === 2
30
+ && typeof value[0] === 'number'
31
+ && typeof value[1] === 'number'
32
+ }
33
+ },
34
+ labelColorType: {
35
+ toBeOption: 'ColorType',
36
+ },
37
+ axisLineVisible: {
38
+ toBeTypes: ['boolean']
39
+ },
40
+ axisLineColorType: {
41
+ toBeOption: 'ColorType',
42
+ },
43
+ ticks: {
44
+ toBeTypes: ['number', 'null']
45
+ },
46
+ tickFormat: {
47
+ toBeTypes: ['string', 'Function']
48
+ },
49
+ tickLineVisible: {
50
+ toBeTypes: ['boolean']
51
+ },
52
+ tickPadding: {
53
+ toBeTypes: ['number']
54
+ },
55
+ tickFullLine: {
56
+ toBeTypes: ['boolean']
57
+ },
58
+ tickFullLineDasharray: {
59
+ toBeTypes: ['string']
60
+ },
61
+ tickColorType: {
62
+ toBeOption: 'ColorType',
63
+ },
64
+ tickTextRotate: {
65
+ toBeTypes: ['number']
66
+ },
67
+ tickTextColorType: {
68
+ toBeOption: 'ColorType',
69
+ }
70
+ })
71
+ return result
72
+ }
73
+ }
74
+
75
+ export const ValueStackAxis = defineGridPlugin(pluginConfig)(({ selection, name, observer, subject }) => {
19
76
 
20
77
  const destroy$ = new Subject()
21
78
 
package/src/grid/types.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { ColorType } from '@orbcharts/core'
1
+ import type { ColorType } from '../../lib/core-types'
2
2
  // import type { BaseLegendParams } from '../base/BaseLegend'
3
3
 
4
4
  // export type LineType = 'line' | 'area' | 'gradientArea'
@@ -15,7 +15,7 @@ import type {
15
15
  ComputedDataGrid,
16
16
  DataFormatterGrid,
17
17
  ContextObserverGridDetail,
18
- ContextObserverMultiGridDetail } from '@orbcharts/core'
18
+ ContextObserverMultiGridDetail } from '../../lib/core-types'
19
19
 
20
20
  // 可設定多個gridIndex的params
21
21
  interface MultiGridPluginParams {
@@ -6,18 +6,46 @@ import {
6
6
  shareReplay,
7
7
  takeUntil
8
8
  } from 'rxjs'
9
+ import type { DefinePluginConfig } from '../../../lib/core-types'
9
10
  import {
10
- defineMultiGridPlugin } from '@orbcharts/core'
11
+ defineMultiGridPlugin } from '../../../lib/core'
11
12
  import { DEFAULT_MULTI_BAR_STACK_PARAMS } from '../defaults'
12
13
  import { createBaseBarStack } from '../../base/BaseBarStack'
13
14
  import { multiGridPluginDetailObservables } from '../multiGridObservables'
14
15
  import { getClassName, getUniID } from '../../utils/orbchartsUtils'
16
+ import { LAYER_INDEX_OF_GRAPHIC } from '../../const'
15
17
 
16
18
  const pluginName = 'MultiBarStack'
17
19
 
18
20
  const gridClassName = getClassName(pluginName, 'grid')
19
21
 
20
- export const MultiBarStack = defineMultiGridPlugin(pluginName, DEFAULT_MULTI_BAR_STACK_PARAMS)(({ selection, name, subject, observer }) => {
22
+ const pluginConfig: DefinePluginConfig<typeof pluginName, typeof DEFAULT_MULTI_BAR_STACK_PARAMS> = {
23
+ name: pluginName,
24
+ defaultParams: DEFAULT_MULTI_BAR_STACK_PARAMS,
25
+ layerIndex: LAYER_INDEX_OF_GRAPHIC,
26
+ validator: (params, { validateColumns }) => {
27
+ const result = validateColumns(params, {
28
+ gridIndexes: {
29
+ toBe: 'number[] | "all"',
30
+ test: (value: any) => {
31
+ return value === 'all' || (Array.isArray(value) && value.every((v: any) => typeof v === 'number'))
32
+ }
33
+ },
34
+ barWidth: {
35
+ toBeTypes: ['number']
36
+ },
37
+ barGroupPadding: {
38
+ toBeTypes: ['number']
39
+ },
40
+ barRadius: {
41
+ toBeTypes: ['number', 'boolean']
42
+ }
43
+ })
44
+ return result
45
+ }
46
+ }
47
+
48
+ export const MultiBarStack = defineMultiGridPlugin(pluginConfig)(({ selection, name, subject, observer }) => {
21
49
  const destroy$ = new Subject()
22
50
 
23
51
  const unsubscribeFnArr: (() => void)[] = []
@@ -6,18 +6,49 @@ import {
6
6
  shareReplay,
7
7
  takeUntil
8
8
  } from 'rxjs'
9
+ import type { DefinePluginConfig } from '../../../lib/core-types'
9
10
  import {
10
- defineMultiGridPlugin } from '@orbcharts/core'
11
+ defineMultiGridPlugin } from '../../../lib/core'
11
12
  import { DEFAULT_MULTI_BARS_PARAMS } from '../defaults'
12
13
  import { createBaseBars } from '../../base/BaseBars'
13
14
  import { multiGridPluginDetailObservables } from '../multiGridObservables'
14
15
  import { getClassName, getUniID } from '../../utils/orbchartsUtils'
16
+ import { LAYER_INDEX_OF_GRAPHIC } from '../../const'
15
17
 
16
18
  const pluginName = 'MultiBars'
17
19
 
18
20
  const gridClassName = getClassName(pluginName, 'grid')
19
21
 
20
- export const MultiBars = defineMultiGridPlugin(pluginName, DEFAULT_MULTI_BARS_PARAMS)(({ selection, name, subject, observer }) => {
22
+ const pluginConfig: DefinePluginConfig<typeof pluginName, typeof DEFAULT_MULTI_BARS_PARAMS> = {
23
+ name: pluginName,
24
+ defaultParams: DEFAULT_MULTI_BARS_PARAMS,
25
+ layerIndex: LAYER_INDEX_OF_GRAPHIC,
26
+ validator: (params, { validateColumns }) => {
27
+ const result = validateColumns(params, {
28
+ gridIndexes: {
29
+ toBe: 'number[] | "all"',
30
+ test: (value: any) => {
31
+ return value === 'all' || (Array.isArray(value) && value.every((v: any) => typeof v === 'number'))
32
+ }
33
+ },
34
+ barWidth: {
35
+ toBeTypes: ['number']
36
+ },
37
+ barPadding: {
38
+ toBeTypes: ['number']
39
+ },
40
+ barGroupPadding: {
41
+ toBeTypes: ['number']
42
+ },
43
+ barRadius: {
44
+ toBeTypes: ['number', 'boolean']
45
+ }
46
+ })
47
+ return result
48
+ }
49
+ }
50
+
51
+ export const MultiBars = defineMultiGridPlugin(pluginConfig)(({ selection, name, subject, observer }) => {
21
52
  const destroy$ = new Subject()
22
53
 
23
54
  const unsubscribeFnArr: (() => void)[] = []
@@ -6,18 +6,55 @@ import {
6
6
  shareReplay,
7
7
  takeUntil
8
8
  } from 'rxjs'
9
+ import type { DefinePluginConfig } from '../../../lib/core-types'
9
10
  import {
10
- defineMultiGridPlugin } from '@orbcharts/core'
11
+ defineMultiGridPlugin } from '../../../lib/core'
11
12
  import { DEFAULT_MULTI_BARS_TRIANGLE_PARAMS } from '../defaults'
12
13
  import { createBaseBarsTriangle } from '../../base/BaseBarsTriangle'
13
14
  import { multiGridPluginDetailObservables } from '../multiGridObservables'
14
15
  import { getClassName, getUniID } from '../../utils/orbchartsUtils'
16
+ import { LAYER_INDEX_OF_GRAPHIC } from '../../const'
15
17
 
16
18
  const pluginName = 'MultiBarsTriangle'
17
19
 
18
20
  const gridClassName = getClassName(pluginName, 'grid')
19
21
 
20
- export const MultiBarsTriangle = defineMultiGridPlugin(pluginName, DEFAULT_MULTI_BARS_TRIANGLE_PARAMS)(({ selection, name, subject, observer }) => {
22
+ const pluginConfig: DefinePluginConfig<typeof pluginName, typeof DEFAULT_MULTI_BARS_TRIANGLE_PARAMS> = {
23
+ name: pluginName,
24
+ defaultParams: DEFAULT_MULTI_BARS_TRIANGLE_PARAMS,
25
+ layerIndex: LAYER_INDEX_OF_GRAPHIC,
26
+ validator: (params, { validateColumns }) => {
27
+ const result = validateColumns(params, {
28
+ gridIndexes: {
29
+ toBe: 'number[] | "all"',
30
+ test: (value: any) => {
31
+ return value === 'all' || (Array.isArray(value) && value.every((v: any) => typeof v === 'number'))
32
+ }
33
+ },
34
+ barWidth: {
35
+ toBeTypes: ['number']
36
+ },
37
+ barPadding: {
38
+ toBeTypes: ['number']
39
+ },
40
+ barGroupPadding: {
41
+ toBeTypes: ['number']
42
+ },
43
+ linearGradientOpacity: {
44
+ toBe: '[number, number]',
45
+ test: (value: any) => {
46
+ return Array.isArray(value)
47
+ && value.length === 2
48
+ && typeof value[0] === 'number'
49
+ && typeof value[1] === 'number'
50
+ }
51
+ }
52
+ })
53
+ return result
54
+ }
55
+ }
56
+
57
+ export const MultiBarsTriangle = defineMultiGridPlugin(pluginConfig)(({ selection, name, subject, observer }) => {
21
58
  const destroy$ = new Subject()
22
59
 
23
60
  const unsubscribeFnArr: (() => void)[] = []
@@ -2,18 +2,55 @@ import * as d3 from 'd3'
2
2
  import {
3
3
  takeUntil,
4
4
  Subject } from 'rxjs'
5
+ import type { DefinePluginConfig } from '../../../lib/core-types'
5
6
  import {
6
- defineMultiGridPlugin } from '@orbcharts/core'
7
+ defineMultiGridPlugin } from '../../../lib/core'
7
8
  import { DEFAULT_MULTI_DOTS_PARAMS } from '../defaults'
8
9
  import { createBaseDots } from '../../base/BaseDots'
9
10
  import { multiGridPluginDetailObservables } from '../multiGridObservables'
10
11
  import { getClassName, getUniID } from '../../utils/orbchartsUtils'
12
+ import { LAYER_INDEX_OF_GRAPHIC_COVER } from '../../const'
11
13
 
12
14
  const pluginName = 'MultiDots'
13
15
 
14
16
  const gridClassName = getClassName(pluginName, 'grid')
15
17
 
16
- export const MultiDots = defineMultiGridPlugin(pluginName, DEFAULT_MULTI_DOTS_PARAMS)(({ selection, name, subject, observer }) => {
18
+ const pluginConfig: DefinePluginConfig<typeof pluginName, typeof DEFAULT_MULTI_DOTS_PARAMS> = {
19
+ name: pluginName,
20
+ defaultParams: DEFAULT_MULTI_DOTS_PARAMS,
21
+ layerIndex: LAYER_INDEX_OF_GRAPHIC_COVER,
22
+ validator: (params, { validateColumns }) => {
23
+ const result = validateColumns(params, {
24
+ gridIndexes: {
25
+ toBe: 'number[] | "all"',
26
+ test: (value: any) => {
27
+ return value === 'all' || (Array.isArray(value) && value.every((v: any) => typeof v === 'number'))
28
+ }
29
+ },
30
+ radius: {
31
+ toBeTypes: ['number']
32
+ },
33
+ fillColorType: {
34
+ toBeOption: 'ColorType',
35
+ },
36
+ strokeColorType: {
37
+ toBeOption: 'ColorType',
38
+ },
39
+ strokeWidth: {
40
+ toBeTypes: ['number']
41
+ },
42
+ // strokeWidthWhileHighlight: {
43
+ // toBeTypes: ['number']
44
+ // },
45
+ onlyShowHighlighted: {
46
+ toBeTypes: ['boolean']
47
+ }
48
+ })
49
+ return result
50
+ }
51
+ }
52
+
53
+ export const MultiDots = defineMultiGridPlugin(pluginConfig)(({ selection, name, subject, observer }) => {
17
54
  const destroy$ = new Subject()
18
55
 
19
56
  const unsubscribeFnArr: (() => void)[] = []