@orbcharts/plugins-basic 3.0.0-alpha.70 → 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 +8863 -7397
  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 +103 -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
@@ -5,14 +5,35 @@ import {
5
5
  takeUntil,
6
6
  Subject,
7
7
  Observable } from 'rxjs'
8
- import { defineGridPlugin } from '@orbcharts/core'
8
+ import type { DefinePluginConfig } from '../../../lib/core-types'
9
+ import { defineGridPlugin } from '../../../lib/core'
9
10
  import { DEFAULT_BAR_STACK_PARAMS } from '../defaults'
11
+ import { LAYER_INDEX_OF_GRAPHIC } from '../../const'
10
12
  import { createBaseBarStack } from '../../base/BaseBarStack'
11
13
 
12
14
  const pluginName = 'BarStack'
13
15
 
16
+ const pluginConfig: DefinePluginConfig<typeof pluginName, typeof DEFAULT_BAR_STACK_PARAMS> = {
17
+ name: pluginName,
18
+ defaultParams: DEFAULT_BAR_STACK_PARAMS,
19
+ layerIndex: 5,
20
+ validator: (params, { validateColumns }) => {
21
+ const result = validateColumns(params, {
22
+ barWidth: {
23
+ toBeTypes: ['number']
24
+ },
25
+ barGroupPadding: {
26
+ toBeTypes: ['number']
27
+ },
28
+ barRadius: {
29
+ toBeTypes: ['number', 'boolean']
30
+ }
31
+ })
32
+ return result
33
+ }
34
+ }
14
35
 
15
- export const BarStack = defineGridPlugin(pluginName, DEFAULT_BAR_STACK_PARAMS)(({ selection, name, subject, observer }) => {
36
+ export const BarStack = defineGridPlugin(pluginConfig)(({ selection, name, subject, observer }) => {
16
37
  const destroy$ = new Subject()
17
38
 
18
39
  const unsubscribeBaseBars = createBaseBarStack(pluginName, {
@@ -6,14 +6,39 @@ import {
6
6
  shareReplay,
7
7
  takeUntil
8
8
  } from 'rxjs'
9
+ import type { DefinePluginConfig } from '../../../lib/core-types'
9
10
  import {
10
- defineGridPlugin } from '@orbcharts/core'
11
+ defineGridPlugin } from '../../../lib/core'
11
12
  import { DEFAULT_BARS_PARAMS } from '../defaults'
13
+ import { LAYER_INDEX_OF_GRAPHIC } from '../../const'
12
14
  import { createBaseBars } from '../../base/BaseBars'
13
15
 
14
16
  const pluginName = 'Bars'
15
17
 
16
- export const Bars = defineGridPlugin(pluginName, DEFAULT_BARS_PARAMS)(({ selection, name, subject, observer }) => {
18
+ const pluginConfig: DefinePluginConfig<typeof pluginName, typeof DEFAULT_BARS_PARAMS> = {
19
+ name: pluginName,
20
+ defaultParams: DEFAULT_BARS_PARAMS,
21
+ layerIndex: LAYER_INDEX_OF_GRAPHIC,
22
+ validator: (params, { validateColumns }) => {
23
+ const result = validateColumns(params, {
24
+ barWidth: {
25
+ toBeTypes: ['number']
26
+ },
27
+ barPadding: {
28
+ toBeTypes: ['number']
29
+ },
30
+ barGroupPadding: {
31
+ toBeTypes: ['number']
32
+ },
33
+ barRadius: {
34
+ toBeTypes: ['number', 'boolean']
35
+ }
36
+ })
37
+ return result
38
+ }
39
+ }
40
+
41
+ export const Bars = defineGridPlugin(pluginConfig)(({ selection, name, subject, observer }) => {
17
42
  const destroy$ = new Subject()
18
43
 
19
44
  const unsubscribeBaseBars = createBaseBars(pluginName, {
@@ -2,14 +2,39 @@ import {
2
2
  of,
3
3
  Subject,
4
4
  Observable } from 'rxjs'
5
+ import type { DefinePluginConfig } from '../../../lib/core-types'
5
6
  import {
6
- defineGridPlugin } from '@orbcharts/core'
7
+ defineGridPlugin } from '../../../lib/core'
7
8
  import { DEFAULT_BARS_PARAMS } from '../defaults'
9
+ import { LAYER_INDEX_OF_GRAPHIC } from '../../const'
8
10
  import { createBaseBars } from '../../base/BaseBars'
9
11
 
10
12
  const pluginName = 'BarsPN'
11
13
 
12
- export const BarsPN = defineGridPlugin(pluginName, DEFAULT_BARS_PARAMS)(({ selection, name, subject, observer }) => {
14
+ const pluginConfig: DefinePluginConfig<typeof pluginName, typeof DEFAULT_BARS_PARAMS> = {
15
+ name: pluginName,
16
+ defaultParams: DEFAULT_BARS_PARAMS,
17
+ layerIndex: LAYER_INDEX_OF_GRAPHIC,
18
+ validator: (params, { validateColumns }) => {
19
+ const result = validateColumns(params, {
20
+ barWidth: {
21
+ toBeTypes: ['number']
22
+ },
23
+ barPadding: {
24
+ toBeTypes: ['number']
25
+ },
26
+ barGroupPadding: {
27
+ toBeTypes: ['number']
28
+ },
29
+ barRadius: {
30
+ toBeTypes: ['number', 'boolean']
31
+ }
32
+ })
33
+ return result
34
+ }
35
+ }
36
+
37
+ export const BarsPN = defineGridPlugin(pluginConfig)(({ selection, name, subject, observer }) => {
13
38
  const destroy$ = new Subject()
14
39
 
15
40
  const unsubscribeBaseBars = createBaseBars(pluginName, {
@@ -6,13 +6,44 @@ import {
6
6
  distinctUntilChanged,
7
7
  shareReplay
8
8
  } from 'rxjs'
9
- import { defineGridPlugin } from '@orbcharts/core'
9
+ import type { DefinePluginConfig } from '../../../lib/core-types'
10
+ import { defineGridPlugin } from '../../../lib/core'
10
11
  import { DEFAULT_BARS_TRIANGLE_PARAMS } from '../defaults'
12
+ import { LAYER_INDEX_OF_GRAPHIC } from '../../const'
11
13
  import { createBaseBarsTriangle } from '../../base/BaseBarsTriangle'
12
14
 
13
15
  const pluginName = 'BarsTriangle'
14
16
 
15
- export const BarsTriangle = defineGridPlugin(pluginName, DEFAULT_BARS_TRIANGLE_PARAMS)(({ selection, name, subject, observer }) => {
17
+ const pluginConfig: DefinePluginConfig<typeof pluginName, typeof DEFAULT_BARS_TRIANGLE_PARAMS> = {
18
+ name: pluginName,
19
+ defaultParams: DEFAULT_BARS_TRIANGLE_PARAMS,
20
+ layerIndex: 5,
21
+ validator: (params, { validateColumns }) => {
22
+ const result = validateColumns(params, {
23
+ barWidth: {
24
+ toBeTypes: ['number']
25
+ },
26
+ barPadding: {
27
+ toBeTypes: ['number']
28
+ },
29
+ barGroupPadding: {
30
+ toBeTypes: ['number']
31
+ },
32
+ linearGradientOpacity: {
33
+ toBe: '[number, number]',
34
+ test: (value: any) => {
35
+ return Array.isArray(value)
36
+ && value.length === 2
37
+ && typeof value[0] === 'number'
38
+ && typeof value[1] === 'number'
39
+ }
40
+ }
41
+ })
42
+ return result
43
+ }
44
+ }
45
+
46
+ export const BarsTriangle = defineGridPlugin(pluginConfig)(({ selection, name, subject, observer }) => {
16
47
  const destroy$ = new Subject()
17
48
 
18
49
  const unsubscribeBaseBars = createBaseBarsTriangle(pluginName, {
@@ -1,13 +1,44 @@
1
1
  import {
2
2
  Subject } from 'rxjs'
3
3
  import {
4
- defineGridPlugin } from '@orbcharts/core'
4
+ defineGridPlugin } from '../../../lib/core'
5
+ import type { DefinePluginConfig } from '../../../lib/core-types'
5
6
  import { DEFAULT_DOTS_PARAMS } from '../defaults'
7
+ import { LAYER_INDEX_OF_GRAPHIC_COVER } from '../../const'
6
8
  import { createBaseDots } from '../../base/BaseDots'
7
9
 
8
10
  const pluginName = 'Dots'
9
11
 
10
- export const Dots = defineGridPlugin(pluginName, DEFAULT_DOTS_PARAMS)(({ selection, name, subject, observer }) => {
12
+ const pluginConfig: DefinePluginConfig<typeof pluginName, typeof DEFAULT_DOTS_PARAMS> = {
13
+ name: pluginName,
14
+ defaultParams: DEFAULT_DOTS_PARAMS,
15
+ layerIndex: LAYER_INDEX_OF_GRAPHIC_COVER,
16
+ validator: (params, { validateColumns }) => {
17
+ const result = validateColumns(params, {
18
+ radius: {
19
+ toBeTypes: ['number']
20
+ },
21
+ fillColorType: {
22
+ toBeOption: 'ColorType',
23
+ },
24
+ strokeColorType: {
25
+ toBeOption: 'ColorType',
26
+ },
27
+ strokeWidth: {
28
+ toBeTypes: ['number']
29
+ },
30
+ // strokeWidthWhileHighlight: {
31
+ // toBeTypes: ['number']
32
+ // },
33
+ onlyShowHighlighted: {
34
+ toBeTypes: ['boolean']
35
+ }
36
+ })
37
+ return result
38
+ }
39
+ }
40
+
41
+ export const Dots = defineGridPlugin(pluginConfig)(({ selection, name, subject, observer }) => {
11
42
 
12
43
  const destroy$ = new Subject()
13
44
 
@@ -7,13 +7,50 @@ import {
7
7
  Observable,
8
8
  Subject } from 'rxjs'
9
9
  import {
10
- defineGridPlugin } from '@orbcharts/core'
10
+ defineGridPlugin } from '../../../lib/core'
11
+ import type { DefinePluginConfig } from '../../../lib/core-types'
11
12
  import { DEFAULT_GRID_LEGEND_PARAMS } from '../defaults'
13
+ import { LAYER_INDEX_OF_INFO } from '../../const'
12
14
  import { createBaseLegend } from '../../base/BaseLegend'
13
15
 
14
16
  const pluginName = 'GridLegend'
15
17
 
16
- export const GridLegend = defineGridPlugin(pluginName, DEFAULT_GRID_LEGEND_PARAMS)(({ selection, rootSelection, observer, subject }) => {
18
+ const pluginConfig: DefinePluginConfig<typeof pluginName, typeof DEFAULT_GRID_LEGEND_PARAMS> = {
19
+ name: pluginName,
20
+ defaultParams: DEFAULT_GRID_LEGEND_PARAMS,
21
+ layerIndex: LAYER_INDEX_OF_INFO,
22
+ validator: (params, { validateColumns }) => {
23
+ const result = validateColumns(params, {
24
+ padding: {
25
+ toBeTypes: ['number']
26
+ },
27
+ backgroundFill: {
28
+ toBeOption: 'ColorType',
29
+ },
30
+ backgroundStroke: {
31
+ toBeOption: 'ColorType',
32
+ },
33
+ gap: {
34
+ toBeTypes: ['number']
35
+ },
36
+ listRectWidth: {
37
+ toBeTypes: ['number']
38
+ },
39
+ listRectHeight: {
40
+ toBeTypes: ['number']
41
+ },
42
+ listRectRadius: {
43
+ toBeTypes: ['number']
44
+ },
45
+ textColorType: {
46
+ toBeOption: 'ColorType',
47
+ }
48
+ })
49
+ return result
50
+ }
51
+ }
52
+
53
+ export const GridLegend = defineGridPlugin(pluginConfig)(({ selection, rootSelection, observer, subject }) => {
17
54
 
18
55
  const destroy$ = new Subject()
19
56
 
@@ -14,11 +14,12 @@ import {
14
14
  Subject,
15
15
  Observable } from 'rxjs'
16
16
  import {
17
- defineGridPlugin } from '@orbcharts/core'
17
+ defineGridPlugin } from '../../../lib/core'
18
+ import type { DefinePluginConfig } from '../../../lib/core-types'
18
19
  import type {
19
20
  TransformData,
20
21
  DataFormatterGrid,
21
- ChartParams } from '@orbcharts/core'
22
+ ChartParams } from '../../../lib/core-types'
22
23
  import { DEFAULT_GROUP_AREA_PARAMS } from '../defaults'
23
24
  import { parseTickFormatValue } from '../../utils/d3Utils'
24
25
  import { measureTextWidth } from '../../utils/commonUtils'
@@ -28,6 +29,7 @@ import { gridGroupPosition } from '../gridObservables'
28
29
  import type { GroupAuxParams } from '../types'
29
30
  import { gridSelectionsObservable } from '../gridObservables'
30
31
  import { renderTspansOnAxis } from '../../utils/d3Graphics'
32
+ import { LAYER_INDEX_OF_AUX } from '../../const'
31
33
 
32
34
  interface LineDatum {
33
35
  id: string
@@ -50,6 +52,44 @@ interface LabelDatum {
50
52
  const pluginName = 'GroupAux'
51
53
  const labelClassName = getClassName(pluginName, 'label-box')
52
54
 
55
+ const pluginConfig: DefinePluginConfig<typeof pluginName, typeof DEFAULT_GROUP_AREA_PARAMS> = {
56
+ name: pluginName,
57
+ defaultParams: DEFAULT_GROUP_AREA_PARAMS,
58
+ layerIndex: LAYER_INDEX_OF_AUX,
59
+ validator: (params, { validateColumns }) => {
60
+ const result = validateColumns(params, {
61
+ showLine: {
62
+ toBeTypes: ['boolean']
63
+ },
64
+ showLabel: {
65
+ toBeTypes: ['boolean']
66
+ },
67
+ lineDashArray: {
68
+ toBeTypes: ['string']
69
+ },
70
+ lineColorType: {
71
+ toBeOption: 'ColorType'
72
+ },
73
+ labelColorType: {
74
+ toBeOption: 'ColorType'
75
+ },
76
+ labelTextColorType: {
77
+ toBeOption: 'ColorType'
78
+ },
79
+ labelTextFormat: {
80
+ toBeTypes: ['string', 'Function']
81
+ },
82
+ labelPadding: {
83
+ toBeTypes: ['number']
84
+ },
85
+ labelRotate: {
86
+ toBeTypes: ['number']
87
+ }
88
+ })
89
+ return result
90
+ }
91
+ }
92
+
53
93
  function createLineData ({ groupLabel, axisX, axisHeight, fullParams }: {
54
94
  groupLabel: string
55
95
  axisX: number
@@ -199,50 +239,93 @@ function renderLabel ({ selection, labelData, fullParams, fullDataFormatter, ful
199
239
  rectY = - rectHeight + 2
200
240
  }
201
241
 
202
- const rectUpdate = d3.select(n[i])
242
+ // -- rect --
243
+ d3.select(n[i])
203
244
  .selectAll<SVGRectElement, LabelDatum>('rect')
204
245
  .data([datum])
205
- const rectEnter = rectUpdate
206
- .enter()
207
- .append('rect')
246
+ .join(
247
+ enter => enter.append('rect')
248
+ .style('cursor', 'pointer')
249
+ .attr('rx', 5)
250
+ .attr('ry', 5),
251
+ update => update,
252
+ exit => exit.remove()
253
+ )
254
+ .attr('width', d => `${rectWidth}px`)
208
255
  .attr('height', `${rectHeight}px`)
209
256
  .attr('fill', d => getColor(fullParams.labelColorType, fullChartParams))
210
257
  .attr('x', rectX)
211
258
  .attr('y', rectY - 3) // 奇怪的偏移修正
212
- .attr('rx', 5)
213
- .attr('ry', 5)
214
- .style('cursor', 'pointer')
215
- // .style('pointer-events', 'none')
216
- const rect = rectUpdate.merge(rectEnter)
217
- .attr('width', d => `${rectWidth}px`)
218
259
  .style('transform', textReverseTransformWithRotate)
219
- rectUpdate.exit().remove()
220
260
 
221
- const textUpdate = d3.select(n[i])
261
+ // const rectUpdate = d3.select(n[i])
262
+ // .selectAll<SVGRectElement, LabelDatum>('rect')
263
+ // .data([datum])
264
+ // const rectEnter = rectUpdate
265
+ // .enter()
266
+ // .append('rect')
267
+ // .attr('height', `${rectHeight}px`)
268
+ // .attr('fill', d => getColor(fullParams.labelColorType, fullChartParams))
269
+ // .attr('x', rectX)
270
+ // .attr('y', rectY - 3) // 奇怪的偏移修正
271
+ // .attr('rx', 5)
272
+ // .attr('ry', 5)
273
+ // .style('cursor', 'pointer')
274
+ // // .style('pointer-events', 'none')
275
+ // const rect = rectUpdate.merge(rectEnter)
276
+ // .attr('width', d => `${rectWidth}px`)
277
+ // .style('transform', textReverseTransformWithRotate)
278
+ // rectUpdate.exit().remove()
279
+
280
+ // -- text --
281
+ d3.select(n[i])
222
282
  .selectAll<SVGTextElement, LabelDatum>('text')
223
283
  .data([datum])
224
- const textEnter = textUpdate
225
- .enter()
226
- .append('text')
227
- .style('dominant-baseline', 'hanging')
228
- .style('cursor', 'pointer')
229
- // .style('pointer-events', 'none')
230
- const text = textUpdate.merge(textEnter)
231
- // .text(d => d.text)
284
+ .join(
285
+ enter => enter.append('text')
286
+ .style('dominant-baseline', 'hanging')
287
+ .style('cursor', 'pointer'),
288
+ update => update,
289
+ exit => exit.remove()
290
+ )
232
291
  .style('transform', textReverseTransformWithRotate)
233
292
  .attr('fill', d => getColor(fullParams.labelTextColorType, fullChartParams))
234
293
  .attr('font-size', fullChartParams.styles.textSize)
235
294
  .attr('x', rectX + 6)
236
295
  .attr('y', rectY)
237
- textUpdate.exit().remove()
238
-
239
- text.each((d, i, n) => {
240
- renderTspansOnAxis(d3.select(n[i]), {
241
- textArr: datum.textArr,
242
- textSizePx,
243
- groupAxisPosition: fullDataFormatter.grid.groupAxis.position
296
+ .each((d, i, n) => {
297
+ renderTspansOnAxis(d3.select(n[i]), {
298
+ textArr: datum.textArr,
299
+ textSizePx,
300
+ groupAxisPosition: fullDataFormatter.grid.groupAxis.position
301
+ })
244
302
  })
245
- })
303
+
304
+ // const textUpdate = d3.select(n[i])
305
+ // .selectAll<SVGTextElement, LabelDatum>('text')
306
+ // .data([datum])
307
+ // const textEnter = textUpdate
308
+ // .enter()
309
+ // .append('text')
310
+ // .style('dominant-baseline', 'hanging')
311
+ // .style('cursor', 'pointer')
312
+ // // .style('pointer-events', 'none')
313
+ // const text = textUpdate.merge(textEnter)
314
+ // // .text(d => d.text)
315
+ // .style('transform', textReverseTransformWithRotate)
316
+ // .attr('fill', d => getColor(fullParams.labelTextColorType, fullChartParams))
317
+ // .attr('font-size', fullChartParams.styles.textSize)
318
+ // .attr('x', rectX + 6)
319
+ // .attr('y', rectY)
320
+ // textUpdate.exit().remove()
321
+
322
+ // text.each((d, i, n) => {
323
+ // renderTspansOnAxis(d3.select(n[i]), {
324
+ // textArr: datum.textArr,
325
+ // textSizePx,
326
+ // groupAxisPosition: fullDataFormatter.grid.groupAxis.position
327
+ // })
328
+ // })
246
329
  })
247
330
 
248
331
  return axisLabelSelection
@@ -256,7 +339,8 @@ function removeLabel (selection: d3.Selection<any, string, any, unknown>) {
256
339
  gUpdate.exit().remove()
257
340
  }
258
341
 
259
- export const GroupAux = defineGridPlugin(pluginName, DEFAULT_GROUP_AREA_PARAMS)(({ selection, rootSelection, name, subject, observer }) => {
342
+
343
+ export const GroupAux = defineGridPlugin(pluginConfig)(({ selection, rootSelection, name, subject, observer }) => {
260
344
  const destroy$ = new Subject()
261
345
 
262
346
  let isLabelMouseover = false
@@ -5,14 +5,75 @@ 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_GROUP_AXIS_PARAMS } from '../defaults'
11
12
  import { createBaseGroupAxis } from '../../base/BaseGroupAxis'
13
+ import { LAYER_INDEX_OF_AXIS } from '../../const'
12
14
 
13
15
  const pluginName = 'GroupAxis'
14
16
 
15
- export const GroupAxis = defineGridPlugin(pluginName, DEFAULT_GROUP_AXIS_PARAMS)(({ selection, name, observer, subject }) => {
17
+ const pluginConfig: DefinePluginConfig<typeof pluginName, typeof DEFAULT_GROUP_AXIS_PARAMS> = {
18
+ name: pluginName,
19
+ defaultParams: DEFAULT_GROUP_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
+ toBe: 'number | null | "all"',
43
+ test: (value: any) => {
44
+ return value === null || value === 'all' || typeof value === 'number'
45
+ }
46
+ },
47
+ tickFormat: {
48
+ toBeTypes: ['string', 'Function']
49
+ },
50
+ tickLineVisible: {
51
+ toBeTypes: ['boolean']
52
+ },
53
+ tickPadding: {
54
+ toBeTypes: ['number']
55
+ },
56
+ tickFullLine: {
57
+ toBeTypes: ['boolean']
58
+ },
59
+ tickFullLineDasharray: {
60
+ toBeTypes: ['string']
61
+ },
62
+ tickColorType: {
63
+ toBeOption: 'ColorType',
64
+ },
65
+ tickTextRotate: {
66
+ toBeTypes: ['number']
67
+ },
68
+ tickTextColorType: {
69
+ toBeOption: 'ColorType',
70
+ }
71
+ })
72
+ return result
73
+ }
74
+ }
75
+
76
+ export const GroupAxis = defineGridPlugin(pluginConfig)(({ selection, name, observer, subject }) => {
16
77
 
17
78
  const destroy$ = new Subject()
18
79
 
@@ -1,13 +1,38 @@
1
1
  import {
2
2
  Subject } from 'rxjs'
3
+ import type { DefinePluginConfig } from '../../../lib/core-types'
3
4
  import {
4
- defineGridPlugin } from '@orbcharts/core'
5
+ defineGridPlugin } from '../../../lib/core'
5
6
  import { DEFAULT_LINE_AREAS_PARAMS } from '../defaults'
6
7
  import { createBaseLineAreas } from '../../base/BaseLineAreas'
8
+ import { LAYER_INDEX_OF_GRAPHIC_GROUND } from '../../const'
7
9
 
8
10
  const pluginName = 'LineAreas'
9
11
 
10
- export const LineAreas = defineGridPlugin(pluginName, DEFAULT_LINE_AREAS_PARAMS)(({ selection, name, observer, subject }) => {
12
+ const pluginConfig: DefinePluginConfig<typeof pluginName, typeof DEFAULT_LINE_AREAS_PARAMS> = {
13
+ name: pluginName,
14
+ defaultParams: DEFAULT_LINE_AREAS_PARAMS,
15
+ layerIndex: LAYER_INDEX_OF_GRAPHIC_GROUND,
16
+ validator: (params, { validateColumns }) => {
17
+ const result = validateColumns(params, {
18
+ lineCurve: {
19
+ toBeTypes: ['string']
20
+ },
21
+ linearGradientOpacity: {
22
+ toBe: '[number, number]',
23
+ test: (value: any) => {
24
+ return Array.isArray(value)
25
+ && value.length === 2
26
+ && typeof value[0] === 'number'
27
+ && typeof value[1] === 'number'
28
+ }
29
+ },
30
+ })
31
+ return result
32
+ }
33
+ }
34
+
35
+ export const LineAreas = defineGridPlugin(pluginConfig)(({ selection, name, observer, subject }) => {
11
36
 
12
37
  const destroy$ = new Subject()
13
38
 
@@ -1,13 +1,32 @@
1
1
  import {
2
2
  Subject } from 'rxjs'
3
+ import type { DefinePluginConfig } from '../../../lib/core-types'
3
4
  import {
4
- defineGridPlugin } from '@orbcharts/core'
5
+ defineGridPlugin } from '../../../lib/core'
5
6
  import { DEFAULT_LINES_PARAMS } from '../defaults'
6
7
  import { createBaseLines } from '../../base/BaseLines'
8
+ import { LAYER_INDEX_OF_GRAPHIC } from '../../const'
7
9
 
8
10
  const pluginName = 'Lines'
9
11
 
10
- export const Lines = defineGridPlugin(pluginName, DEFAULT_LINES_PARAMS)(({ selection, rootSelection, name, observer, subject }) => {
12
+ const pluginConfig: DefinePluginConfig<typeof pluginName, typeof DEFAULT_LINES_PARAMS> = {
13
+ name: pluginName,
14
+ defaultParams: DEFAULT_LINES_PARAMS,
15
+ layerIndex: LAYER_INDEX_OF_GRAPHIC,
16
+ validator: (params, { validateColumns }) => {
17
+ const result = validateColumns(params, {
18
+ lineCurve: {
19
+ toBeTypes: ['string']
20
+ },
21
+ lineWidth: {
22
+ toBeTypes: ['number']
23
+ },
24
+ })
25
+ return result
26
+ }
27
+ }
28
+
29
+ export const Lines = defineGridPlugin(pluginConfig)(({ selection, rootSelection, name, observer, subject }) => {
11
30
 
12
31
  const destroy$ = new Subject()
13
32