@orbcharts/plugins-basic 3.0.0-alpha.43 → 3.0.0-alpha.45

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) hide show
  1. package/dist/{src → orbcharts-plugins-basic/src}/base/BaseBarStack.d.ts +6 -4
  2. package/dist/{src → orbcharts-plugins-basic/src}/base/BaseBars.d.ts +6 -4
  3. package/dist/{src → orbcharts-plugins-basic/src}/base/BaseBarsTriangle.d.ts +7 -4
  4. package/dist/{src → orbcharts-plugins-basic/src}/base/BaseDots.d.ts +5 -3
  5. package/dist/{src → orbcharts-plugins-basic/src}/base/BaseGroupAxis.d.ts +3 -3
  6. package/dist/{src → orbcharts-plugins-basic/src}/base/BaseLegend.d.ts +1 -0
  7. package/dist/{src → orbcharts-plugins-basic/src}/base/BaseLineAreas.d.ts +6 -3
  8. package/dist/{src → orbcharts-plugins-basic/src}/base/BaseLines.d.ts +6 -3
  9. package/dist/{src → orbcharts-plugins-basic/src}/base/BaseValueAxis.d.ts +3 -3
  10. package/dist/{src → orbcharts-plugins-basic/src}/grid/gridObservables.d.ts +4 -4
  11. package/dist/orbcharts-plugins-basic/src/index.d.ts +5 -0
  12. package/dist/orbcharts-plugins-basic/src/multiGrid/multiGridObservables.d.ts +8 -0
  13. package/dist/orbcharts-plugins-basic/src/series/plugins/PieEventTexts.d.ts +3 -0
  14. package/dist/orbcharts-plugins-basic/src/series/seriesObservables.d.ts +21 -0
  15. package/dist/{src → orbcharts-plugins-basic/src}/series/seriesUtils.d.ts +3 -3
  16. package/dist/orbcharts-plugins-basic.es.js +8349 -8142
  17. package/dist/orbcharts-plugins-basic.umd.js +8 -8
  18. package/dist/src/index.d.ts +1 -5
  19. package/package.json +2 -2
  20. package/src/base/BaseBarStack.ts +105 -208
  21. package/src/base/BaseBars.ts +78 -64
  22. package/src/base/BaseBarsTriangle.ts +76 -63
  23. package/src/base/BaseDots.ts +41 -178
  24. package/src/base/BaseGroupAxis.ts +16 -16
  25. package/src/base/BaseLegend.ts +18 -13
  26. package/src/base/BaseLineAreas.ts +85 -81
  27. package/src/base/BaseLines.ts +82 -75
  28. package/src/base/BaseValueAxis.ts +17 -18
  29. package/src/grid/gridObservables.ts +22 -38
  30. package/src/grid/plugins/BarStack.ts +16 -3
  31. package/src/grid/plugins/Bars.ts +18 -4
  32. package/src/grid/plugins/BarsDiverging.ts +6 -4
  33. package/src/grid/plugins/BarsTriangle.ts +20 -4
  34. package/src/grid/plugins/Dots.ts +4 -2
  35. package/src/grid/plugins/GridLegend.ts +2 -1
  36. package/src/grid/plugins/GroupAux.ts +8 -6
  37. package/src/grid/plugins/GroupAxis.ts +15 -3
  38. package/src/grid/plugins/LineAreas.ts +5 -2
  39. package/src/grid/plugins/Lines.ts +5 -2
  40. package/src/grid/plugins/ScalingArea.ts +0 -1
  41. package/src/grid/plugins/ValueAxis.ts +15 -3
  42. package/src/grid/plugins/ValueStackAxis.ts +14 -5
  43. package/src/multiGrid/multiGridObservables.ts +14 -261
  44. package/src/multiGrid/plugins/MultiBarStack.ts +22 -8
  45. package/src/multiGrid/plugins/MultiBars.ts +21 -7
  46. package/src/multiGrid/plugins/MultiBarsTriangle.ts +22 -7
  47. package/src/multiGrid/plugins/MultiDots.ts +7 -5
  48. package/src/multiGrid/plugins/MultiGridLegend.ts +3 -2
  49. package/src/multiGrid/plugins/MultiGroupAxis.ts +19 -7
  50. package/src/multiGrid/plugins/MultiLineAreas.ts +9 -6
  51. package/src/multiGrid/plugins/MultiLines.ts +9 -6
  52. package/src/multiGrid/plugins/MultiValueAxis.ts +19 -7
  53. package/src/multiGrid/plugins/OverlappingValueAxes.ts +52 -47
  54. package/src/noneData/defaults.ts +3 -0
  55. package/src/noneData/plugins/Tooltip.ts +9 -3
  56. package/src/series/defaults.ts +13 -3
  57. package/src/series/plugins/Bubbles.ts +57 -37
  58. package/src/series/plugins/Pie.ts +300 -352
  59. package/src/series/plugins/PieEventTexts.ts +102 -38
  60. package/src/series/plugins/PieLabels.ts +95 -48
  61. package/src/series/plugins/SeriesLegend.ts +2 -1
  62. package/src/series/seriesObservables.ts +145 -0
  63. package/src/series/seriesUtils.ts +4 -4
  64. package/src/tree/plugins/TreeLegend.ts +2 -1
  65. package/src/tree/plugins/TreeMap.ts +8 -5
  66. package/tsconfig.json +3 -0
  67. package/dist/src/multiGrid/multiGridObservables.d.ts +0 -12
  68. package/dist/src/series/plugins/PieEventTexts.d.ts +0 -1
  69. /package/dist/{src → orbcharts-plugins-basic/src}/base/BaseGroupArea.d.ts +0 -0
  70. /package/dist/{src → orbcharts-plugins-basic/src}/base/types.d.ts +0 -0
  71. /package/dist/{src → orbcharts-plugins-basic/src}/grid/defaults.d.ts +0 -0
  72. /package/dist/{src → orbcharts-plugins-basic/src}/grid/index.d.ts +0 -0
  73. /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/BarStack.d.ts +0 -0
  74. /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/Bars.d.ts +0 -0
  75. /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/BarsDiverging.d.ts +0 -0
  76. /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/BarsTriangle.d.ts +0 -0
  77. /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/Dots.d.ts +0 -0
  78. /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/GridLegend.d.ts +0 -0
  79. /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/GroupAux.d.ts +0 -0
  80. /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/GroupAxis.d.ts +0 -0
  81. /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/LineAreas.d.ts +0 -0
  82. /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/Lines.d.ts +0 -0
  83. /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/Ranking.d.ts +0 -0
  84. /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/RankingAxis.d.ts +0 -0
  85. /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/ScalingArea.d.ts +0 -0
  86. /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/ValueAxis.d.ts +0 -0
  87. /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/ValueStackAxis.d.ts +0 -0
  88. /package/dist/{src → orbcharts-plugins-basic/src}/grid/types.d.ts +0 -0
  89. /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/defaults.d.ts +0 -0
  90. /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/index.d.ts +0 -0
  91. /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/plugins/MultiBarStack.d.ts +0 -0
  92. /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/plugins/MultiBars.d.ts +0 -0
  93. /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/plugins/MultiBarsTriangle.d.ts +0 -0
  94. /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/plugins/MultiDots.d.ts +0 -0
  95. /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/plugins/MultiGridLegend.d.ts +0 -0
  96. /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/plugins/MultiGroupAxis.d.ts +0 -0
  97. /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/plugins/MultiLineAreas.d.ts +0 -0
  98. /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/plugins/MultiLines.d.ts +0 -0
  99. /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/plugins/MultiValueAxis.d.ts +0 -0
  100. /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/plugins/OverlappingValueAxes.d.ts +0 -0
  101. /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/types.d.ts +0 -0
  102. /package/dist/{src → orbcharts-plugins-basic/src}/multiValue/index.d.ts +0 -0
  103. /package/dist/{src → orbcharts-plugins-basic/src}/multiValue/plugins/Scatter.d.ts +0 -0
  104. /package/dist/{src → orbcharts-plugins-basic/src}/multiValue/plugins/ScatterAxes.d.ts +0 -0
  105. /package/dist/{src → orbcharts-plugins-basic/src}/noneData/defaults.d.ts +0 -0
  106. /package/dist/{src → orbcharts-plugins-basic/src}/noneData/index.d.ts +0 -0
  107. /package/dist/{src → orbcharts-plugins-basic/src}/noneData/plugins/Container.d.ts +0 -0
  108. /package/dist/{src → orbcharts-plugins-basic/src}/noneData/plugins/Tooltip.d.ts +0 -0
  109. /package/dist/{src → orbcharts-plugins-basic/src}/noneData/types.d.ts +0 -0
  110. /package/dist/{src → orbcharts-plugins-basic/src}/relationship/index.d.ts +0 -0
  111. /package/dist/{src → orbcharts-plugins-basic/src}/relationship/plugins/Relationship.d.ts +0 -0
  112. /package/dist/{src → orbcharts-plugins-basic/src}/series/defaults.d.ts +0 -0
  113. /package/dist/{src → orbcharts-plugins-basic/src}/series/index.d.ts +0 -0
  114. /package/dist/{src → orbcharts-plugins-basic/src}/series/plugins/Bubbles.d.ts +0 -0
  115. /package/dist/{src → orbcharts-plugins-basic/src}/series/plugins/Pie.d.ts +0 -0
  116. /package/dist/{src → orbcharts-plugins-basic/src}/series/plugins/PieLabels.d.ts +0 -0
  117. /package/dist/{src → orbcharts-plugins-basic/src}/series/plugins/SeriesLegend.d.ts +0 -0
  118. /package/dist/{src → orbcharts-plugins-basic/src}/series/plugins/Waffle.d.ts +0 -0
  119. /package/dist/{src → orbcharts-plugins-basic/src}/series/types.d.ts +0 -0
  120. /package/dist/{src → orbcharts-plugins-basic/src}/tree/defaults.d.ts +0 -0
  121. /package/dist/{src → orbcharts-plugins-basic/src}/tree/index.d.ts +0 -0
  122. /package/dist/{src → orbcharts-plugins-basic/src}/tree/plugins/TreeLegend.d.ts +0 -0
  123. /package/dist/{src → orbcharts-plugins-basic/src}/tree/plugins/TreeMap.d.ts +0 -0
  124. /package/dist/{src → orbcharts-plugins-basic/src}/tree/types.d.ts +0 -0
  125. /package/dist/{src → orbcharts-plugins-basic/src}/utils/commonUtils.d.ts +0 -0
  126. /package/dist/{src → orbcharts-plugins-basic/src}/utils/d3Graphics.d.ts +0 -0
  127. /package/dist/{src → orbcharts-plugins-basic/src}/utils/d3Utils.d.ts +0 -0
  128. /package/dist/{src → orbcharts-plugins-basic/src}/utils/observables.d.ts +0 -0
  129. /package/dist/{src → orbcharts-plugins-basic/src}/utils/orbchartsUtils.d.ts +0 -0
  130. /package/dist/{vite.config.d.ts → orbcharts-plugins-basic/vite.config.d.ts} +0 -0
@@ -6,7 +6,7 @@ import {
6
6
 
7
7
  import { DEFAULT_MULTI_LINES_PARAMS } from '../defaults'
8
8
  import { createBaseLines } from '../../base/BaseLines'
9
- import { multiGridDetailObservables } from '../multiGridObservables'
9
+ import { multiGridPluginObservables } from '../multiGridObservables'
10
10
  import { getClassName, getUniID } from '../../utils/orbchartsUtils'
11
11
 
12
12
  const pluginName = 'MultiLines'
@@ -18,7 +18,7 @@ export const MultiLines = defineMultiGridPlugin(pluginName, DEFAULT_MULTI_LINES_
18
18
 
19
19
  const unsubscribeFnArr: (() => void)[] = []
20
20
 
21
- const multiGridPlugin$ = multiGridDetailObservables(observer)
21
+ const multiGridPlugin$ = multiGridPluginObservables(observer)
22
22
 
23
23
  multiGridPlugin$.subscribe(data => {
24
24
  // 每次重新計算時,清除之前的訂閱
@@ -34,18 +34,21 @@ export const MultiLines = defineMultiGridPlugin(pluginName, DEFAULT_MULTI_LINES_
34
34
 
35
35
  unsubscribeFnArr[i] = createBaseLines(pluginName, {
36
36
  selection: gridSelection,
37
- computedData$: d.gridComputedData$,
38
- existSeriesLabels$: d.existSeriesLabels$,
37
+ computedData$: d.computedData$,
38
+ computedLayoutData$: d.computedLayoutData$,
39
+ visibleComputedData$: d.visibleComputedData$,
40
+ visibleComputedLayoutData$: d.visibleComputedLayoutData$,
41
+ seriesLabels$: d.seriesLabels$,
39
42
  SeriesDataMap$: d.SeriesDataMap$,
40
43
  GroupDataMap$: d.GroupDataMap$,
41
- fullDataFormatter$: d.gridDataFormatter$,
44
+ fullDataFormatter$: d.dataFormatter$,
42
45
  fullParams$: observer.fullParams$,
43
46
  fullChartParams$: observer.fullChartParams$,
44
47
  gridAxesTransform$: d.gridAxesTransform$,
45
48
  gridGraphicTransform$: d.gridGraphicTransform$,
46
49
  gridAxesSize$: d.gridAxesSize$,
47
50
  gridHighlight$: d.gridHighlight$,
48
- gridContainer$: d.gridContainer$,
51
+ gridContainerPosition$: d.gridContainerPosition$,
49
52
  event$: subject.event$ as Subject<any>,
50
53
  })
51
54
  })
@@ -1,11 +1,16 @@
1
1
  import * as d3 from 'd3'
2
2
  import {
3
- Subject } from 'rxjs'
3
+ Subject,
4
+ map,
5
+ distinctUntilChanged,
6
+ shareReplay,
7
+ takeUntil
8
+ } from 'rxjs'
4
9
  import {
5
10
  defineMultiGridPlugin } from '@orbcharts/core'
6
11
  import { DEFAULT_MULTI_VALUE_AXIS_PARAMS } from '../defaults'
7
12
  import { createBaseValueAxis } from '../../base/BaseValueAxis'
8
- import { multiGridDetailObservables } from '../multiGridObservables'
13
+ import { multiGridPluginObservables } from '../multiGridObservables'
9
14
  import { getClassName, getUniID } from '../../utils/orbchartsUtils'
10
15
 
11
16
  const pluginName = 'MultiValueAxis'
@@ -17,7 +22,7 @@ export const MultiValueAxis = defineMultiGridPlugin(pluginName, DEFAULT_MULTI_VA
17
22
 
18
23
  const unsubscribeFnArr: (() => void)[] = []
19
24
 
20
- const multiGridPlugin$ = multiGridDetailObservables(observer)
25
+ const multiGridPlugin$ = multiGridPluginObservables(observer)
21
26
 
22
27
  multiGridPlugin$.subscribe(data => {
23
28
  // 每次重新計算時,清除之前的訂閱
@@ -31,17 +36,24 @@ export const MultiValueAxis = defineMultiGridPlugin(pluginName, DEFAULT_MULTI_VA
31
36
 
32
37
  const gridSelection = d3.select(g[i])
33
38
 
39
+ const isSeriesSeprate$ = d.dataFormatter$.pipe(
40
+ takeUntil(destroy$),
41
+ map(d => d.grid.separateSeries),
42
+ distinctUntilChanged(),
43
+ shareReplay(1)
44
+ )
45
+
34
46
  unsubscribeFnArr[i] = createBaseValueAxis(pluginName, {
35
47
  selection: gridSelection,
36
- computedData$: d.gridComputedData$,
48
+ computedData$: d.computedData$,
37
49
  fullParams$: observer.fullParams$,
38
- fullDataFormatter$: d.gridDataFormatter$,
50
+ fullDataFormatter$: d.dataFormatter$,
39
51
  fullChartParams$: observer.fullChartParams$,
40
52
  gridAxesTransform$: d.gridAxesTransform$,
41
53
  gridAxesReverseTransform$: d.gridAxesReverseTransform$,
42
54
  gridAxesSize$: d.gridAxesSize$,
43
- gridContainer$: d.gridContainer$,
44
- isSeriesPositionSeprate$: d.isSeriesPositionSeprate$,
55
+ gridContainerPosition$: d.gridContainerPosition$,
56
+ isSeriesSeprate$,
45
57
  })
46
58
  })
47
59
  })
@@ -5,18 +5,19 @@ import {
5
5
  switchMap,
6
6
  combineLatest,
7
7
  takeUntil,
8
+ distinctUntilChanged,
9
+ shareReplay,
8
10
  iif,
9
11
  Observable,
10
12
  Subject } from 'rxjs'
11
- import type { ContextObserverMultiGrid, DataFormatterGrid } from '@orbcharts/core'
13
+ import type { ContextObserverMultiGrid, DataFormatterGrid, DataFormatterTypeMap, Layout } from '@orbcharts/core'
12
14
  import {
13
15
  defineMultiGridPlugin } from '@orbcharts/core'
14
16
  import { DEFAULT_OVERLAPPING_VALUE_AXES_PARAMS } from '../defaults'
15
17
  import { createBaseValueAxis } from '../../base/BaseValueAxis'
16
- import { multiGridDetailObservables } from '../multiGridObservables'
18
+ import { multiGridPluginObservables } from '../multiGridObservables'
17
19
  import { getClassName, getUniID } from '../../utils/orbchartsUtils'
18
- // @Q@
19
- import { gridAxesTransformObservable, gridAxesReverseTransformObservable, gridContainerObservable } from '@orbcharts/core/src/grid/gridObservables'
20
+ import { gridAxesTransformObservable, gridAxesReverseTransformObservable, gridContainerPositionObservable } from '@orbcharts/core/src/grid/gridObservables'
20
21
 
21
22
  const pluginName = 'OverlappingValueAxes'
22
23
 
@@ -40,43 +41,41 @@ export const OverlappingValueAxes = defineMultiGridPlugin(pluginName, DEFAULT_OV
40
41
  // 為了要反轉第二個valueAxis的位置所以要重新計算
41
42
  const secondGridDataFormatter$: Observable<DataFormatterGrid> = combineLatest({
42
43
  firstGridIndex: firstGridIndex$,
43
- secondGridIndex: secondGridIndex$
44
+ secondGridIndex: secondGridIndex$,
45
+ fullDataFormatter: observer.fullDataFormatter$,
44
46
  }).pipe(
45
47
  takeUntil(destroy$),
46
- switchMap(data => {
47
- return observer.fullDataFormatter$.pipe(
48
- takeUntil(destroy$),
49
- map(fullDataFormatter => {
50
- if (!fullDataFormatter.gridList[data.secondGridIndex]) {
51
- fullDataFormatter.gridList[data.secondGridIndex] = Object.assign({}, fullDataFormatter.gridList[data.firstGridIndex])
52
- }
53
- // 反轉第二個valueAxis的位置
54
- let reversePosition = ''
55
- if (fullDataFormatter.gridList[data.firstGridIndex].valueAxis.position === 'left') {
56
- reversePosition = 'right'
57
- } else if (fullDataFormatter.gridList[data.firstGridIndex].valueAxis.position === 'bottom') {
58
- reversePosition = 'top'
59
- } else if (fullDataFormatter.gridList[data.firstGridIndex].valueAxis.position === 'top') {
60
- reversePosition = 'bottom'
61
- } else if (fullDataFormatter.gridList[data.firstGridIndex].valueAxis.position === 'right') {
62
- reversePosition = 'left'
63
- }
64
- return <DataFormatterGrid>{
65
- type: 'grid',
66
- grid: {
67
- ...fullDataFormatter.gridList[data.secondGridIndex],
68
- valueAxis: {
69
- ...fullDataFormatter.gridList[data.secondGridIndex].valueAxis,
70
- position: reversePosition
71
- }
72
- },
73
- container: {
74
- ...fullDataFormatter.container
75
- }
48
+ switchMap(async (d) => d),
49
+ map(data => {
50
+ if (!data.fullDataFormatter.gridList[data.secondGridIndex]) {
51
+ data.fullDataFormatter.gridList[data.secondGridIndex] = Object.assign({}, data.fullDataFormatter.gridList[data.firstGridIndex])
52
+ }
53
+ // 反轉第二個valueAxis的位置
54
+ let reversePosition = ''
55
+ if (data.fullDataFormatter.gridList[data.firstGridIndex].valueAxis.position === 'left') {
56
+ reversePosition = 'right'
57
+ } else if (data.fullDataFormatter.gridList[data.firstGridIndex].valueAxis.position === 'bottom') {
58
+ reversePosition = 'top'
59
+ } else if (data.fullDataFormatter.gridList[data.firstGridIndex].valueAxis.position === 'top') {
60
+ reversePosition = 'bottom'
61
+ } else if (data.fullDataFormatter.gridList[data.firstGridIndex].valueAxis.position === 'right') {
62
+ reversePosition = 'left'
63
+ }
64
+ return <DataFormatterGrid>{
65
+ type: 'grid',
66
+ visibleFilter: data.fullDataFormatter.visibleFilter as any,
67
+ grid: {
68
+ ...data.fullDataFormatter.gridList[data.secondGridIndex],
69
+ valueAxis: {
70
+ ...data.fullDataFormatter.gridList[data.secondGridIndex].valueAxis,
71
+ position: reversePosition
76
72
  }
77
- })
78
- )
79
- }),
73
+ },
74
+ container: {
75
+ ...data.fullDataFormatter.container
76
+ }
77
+ }
78
+ })
80
79
  )
81
80
 
82
81
  const multiGridPlugin$ = of(observer).pipe(
@@ -95,7 +94,7 @@ export const OverlappingValueAxes = defineMultiGridPlugin(pluginName, DEFAULT_OV
95
94
  )
96
95
  }
97
96
  }),
98
- switchMap(observer => multiGridDetailObservables(observer)),
97
+ switchMap(observer => multiGridPluginObservables(observer)),
99
98
  map(data => {
100
99
  return data.map((observables, index) => {
101
100
  if (index === 0) {
@@ -109,17 +108,16 @@ export const OverlappingValueAxes = defineMultiGridPlugin(pluginName, DEFAULT_OV
109
108
  const gridAxesReverseTransform$ = gridAxesReverseTransformObservable({
110
109
  gridAxesTransform$
111
110
  })
112
- const gridContainer$ = gridContainerObservable({
113
- computedData$: observables.gridComputedData$,
111
+ const gridContainerPosition$ = gridContainerPositionObservable({
112
+ computedData$: observables.computedData$,
114
113
  fullDataFormatter$: secondGridDataFormatter$,
115
- fullChartParams$: observer.fullChartParams$,
116
114
  layout$: observer.layout$
117
115
  })
118
116
  return {
119
117
  ...observables,
120
118
  gridAxesTransform$,
121
119
  gridAxesReverseTransform$,
122
- gridContainer$,
120
+ gridContainerPosition$,
123
121
  }
124
122
  })
125
123
  })
@@ -140,19 +138,26 @@ export const OverlappingValueAxes = defineMultiGridPlugin(pluginName, DEFAULT_OV
140
138
 
141
139
  const gridSelection = d3.select(g[i])
142
140
 
141
+ const isSeriesSeprate$ = d.dataFormatter$.pipe(
142
+ takeUntil(destroy$),
143
+ map(d => d.grid.separateSeries),
144
+ distinctUntilChanged(),
145
+ shareReplay(1)
146
+ )
147
+
143
148
  unsubscribeFnArr[i] = createBaseValueAxis(pluginName, {
144
149
  selection: gridSelection,
145
- computedData$: d.gridComputedData$,
150
+ computedData$: d.computedData$,
146
151
  fullParams$: observer.fullParams$.pipe(
147
152
  map(fullParams => i === 0 ? fullParams.firstAxis : fullParams.secondAxis)
148
153
  ),
149
- fullDataFormatter$: d.gridDataFormatter$,
154
+ fullDataFormatter$: d.dataFormatter$,
150
155
  fullChartParams$: observer.fullChartParams$,
151
156
  gridAxesTransform$: d.gridAxesTransform$,
152
157
  gridAxesReverseTransform$: d.gridAxesReverseTransform$,
153
158
  gridAxesSize$: d.gridAxesSize$,
154
- gridContainer$: d.gridContainer$,
155
- isSeriesPositionSeprate$: d.isSeriesPositionSeprate$,
159
+ gridContainerPosition$: d.gridContainerPosition$,
160
+ isSeriesSeprate$,
156
161
  })
157
162
  })
158
163
  })
@@ -27,6 +27,7 @@ export const TOOLTIP_PARAMS: TooltipParams = {
27
27
  } else if (eventData.highlightTarget === 'series') {
28
28
  const label = (eventData as EventBaseSeriesValue<any, any>).seriesLabel
29
29
  const valueArr = (eventData as EventBaseSeriesValue<any, any>).series
30
+ .filter(d => d.visible == true)
30
31
  .map(d => {
31
32
  return d.value
32
33
  })
@@ -37,6 +38,7 @@ export const TOOLTIP_PARAMS: TooltipParams = {
37
38
  } else if (eventData.highlightTarget === 'group') {
38
39
  const label = (eventData as EventBaseGridValue<any, any>).groupLabel
39
40
  const valueArr = (eventData as EventBaseGridValue<any, any>).series
41
+ .filter(d => d.visible == true)
40
42
  .map(d => {
41
43
  return d.value
42
44
  })
@@ -47,6 +49,7 @@ export const TOOLTIP_PARAMS: TooltipParams = {
47
49
  } else if (eventData.highlightTarget === 'category') {
48
50
  const label = (eventData as EventBaseCategoryValue<any, any>).categoryLabel
49
51
  const valueArr = (eventData as EventBaseCategoryValue<any, any>).category
52
+ .filter(d => d.visible == true)
50
53
  .map(d => {
51
54
  return d.value
52
55
  })
@@ -17,6 +17,7 @@ import { defineNoneDataPlugin } from '@orbcharts/core'
17
17
  import { getSvgGElementSize, appendSvg } from '../../utils/d3Utils'
18
18
  import { getColor, getClassName } from '../../utils/orbchartsUtils'
19
19
  import { TOOLTIP_PARAMS } from '../defaults'
20
+ import { textSizePxObservable } from '@orbcharts/core'
20
21
 
21
22
  interface TooltipStyle {
22
23
  backgroundColor: string
@@ -25,7 +26,8 @@ interface TooltipStyle {
25
26
  offset: [number, number]
26
27
  padding: number
27
28
  textColor: string
28
- textSize: number
29
+ textSize: number | string // chartParams上的設定
30
+ textSizePx: number
29
31
  }
30
32
 
31
33
  const pluginName = 'Tooltip'
@@ -33,7 +35,7 @@ const gClassName = getClassName(pluginName, 'g')
33
35
  const boxClassName = getClassName(pluginName, 'box')
34
36
 
35
37
  function textToSvg (textArr: string[], textStyle: TooltipStyle) {
36
- const lineHeight = textStyle.textSize * 1.5
38
+ const lineHeight = textStyle.textSizePx * 1.5
37
39
  return textArr
38
40
  .filter(d => d != '')
39
41
  .map((text, i) => {
@@ -203,9 +205,12 @@ export const Tooltip: PluginConstructor<any, string, any> = defineNoneDataPlugin
203
205
  // map(d => d as EventTypeMap<typeof chartType>)
204
206
  )
205
207
 
208
+ const textSizePx$ = textSizePxObservable(observer.fullChartParams$)
209
+
206
210
  const tooltipStyle$: Observable<TooltipStyle> = combineLatest({
207
211
  fullChartParams: observer.fullChartParams$,
208
- fullParams: observer.fullParams$
212
+ fullParams: observer.fullParams$,
213
+ textSizePx: textSizePx$
209
214
  }).pipe(
210
215
  takeUntil(destroy$),
211
216
  switchMap(async d => d),
@@ -217,6 +222,7 @@ export const Tooltip: PluginConstructor<any, string, any> = defineNoneDataPlugin
217
222
  offset: data.fullParams.offset,
218
223
  padding: data.fullParams.padding,
219
224
  textSize: data.fullChartParams.styles.textSize,
225
+ textSizePx: data.textSizePx,
220
226
  textColor: getColor(data.fullParams.textColorType, data.fullChartParams),
221
227
  }
222
228
  })
@@ -45,11 +45,21 @@ export const DEFAULT_PIE_PARAMS: PieParams = {
45
45
  }
46
46
 
47
47
  export const DEFAULT_PIE_EVENT_TEXTS_PARAMS: PieEventTextsParams = {
48
- eventFn: (d: EventSeries, eventName: EventName, t: number) => {
48
+ eventFn: (eventData: EventSeries, eventName: EventName, t: number) => {
49
49
  if (eventName === 'mouseover' || eventName === 'mousemove') {
50
- return [String(d.datum!.value)]
50
+ return [String(eventData.datum!.value)]
51
51
  }
52
- return [String(Math.round(d.data.reduce((previous,current)=>previous+(current.value??0),0)*t))]
52
+ return [
53
+ String(
54
+ Math.round(
55
+ eventData.data.reduce((acc, seriesData) => {
56
+ return acc + seriesData.reduce((_acc, data) => {
57
+ return _acc + (data.value ?? 0)
58
+ }, 0)
59
+ }, 0) * t
60
+ )
61
+ )
62
+ ]
53
63
  },
54
64
  textAttrs: [
55
65
  {
@@ -14,7 +14,8 @@ import type {
14
14
  DataSeries,
15
15
  EventName,
16
16
  ComputedDataSeries,
17
- ComputedDatumSeries } from '@orbcharts/core'
17
+ ComputedDatumSeries,
18
+ SeriesContainerPosition } from '@orbcharts/core'
18
19
  import {
19
20
  defineSeriesPlugin } from '@orbcharts/core'
20
21
  import type { BubblesParams, BubbleScaleType } from '../types'
@@ -28,6 +29,8 @@ interface BubblesDatum extends ComputedDatumSeries {
28
29
  _originR: number // 紀錄變化前的r
29
30
  }
30
31
 
32
+ type BubblesSimulationDatum = BubblesDatum & d3.SimulationNodeDatum
33
+
31
34
  let force: d3.Simulation<d3.SimulationNodeDatum, undefined> | undefined
32
35
 
33
36
  function makeForce (bubblesSelection: d3.Selection<SVGGElement, any, any, any>, fullParams: BubblesParams) {
@@ -81,11 +84,12 @@ function getMaxR ({ data, bubbleGroupR, maxValue, avgValue }: {
81
84
  return maxR * modifier
82
85
  }
83
86
 
84
- function createBubblesData ({ data, LastBubbleDataMap, graphicWidth, graphicHeight, scaleType }: {
87
+ function createBubblesData ({ data, LastBubbleDataMap, graphicWidth, graphicHeight, SeriesContainerPositionMap, scaleType }: {
85
88
  data: ComputedDataSeries
86
89
  LastBubbleDataMap: Map<string, BubblesDatum>
87
90
  graphicWidth: number
88
91
  graphicHeight: number
92
+ SeriesContainerPositionMap: Map<string, SeriesContainerPosition>
89
93
  scaleType: BubbleScaleType
90
94
  // highlightIds: string[]
91
95
  }) {
@@ -124,8 +128,9 @@ function createBubblesData ({ data, LastBubbleDataMap, graphicWidth, graphicHeig
124
128
  d.x = existDatum.x
125
129
  d.y = existDatum.y
126
130
  } else {
127
- d.x = Math.random() * graphicWidth
128
- d.y = Math.random() * graphicHeight
131
+ const seriesContainerPosition = SeriesContainerPositionMap.get(d.seriesLabel)!
132
+ d.x = Math.random() * seriesContainerPosition.width
133
+ d.y = Math.random() * seriesContainerPosition.height
129
134
  }
130
135
  const r = scaleBubbleR!(d.value ?? 0)!
131
136
  d.r = r
@@ -148,7 +153,7 @@ function renderBubbles ({ graphicSelection, bubblesData, fullParams }: {
148
153
  .append<SVGGElement>("g")
149
154
  .attr('cursor', 'pointer')
150
155
  enter
151
- .style('font-size', 12)
156
+ .attr('font-size', 12)
152
157
  .style('fill', '#ffffff')
153
158
  .attr("text-anchor", "middle")
154
159
  .attr("transform", (d) => {
@@ -253,16 +258,22 @@ function drag (): d3.DragBehavior<Element, unknown, unknown> {
253
258
  // return typeCenter ? typeCenter.x : 0
254
259
  // }
255
260
 
256
- function groupBubbles ({ fullParams, graphicWidth, graphicHeight }: {
261
+ function groupBubbles ({ fullParams, SeriesContainerPositionMap }: {
257
262
  fullParams: BubblesParams
258
- graphicWidth: number
259
- graphicHeight: number
263
+ // graphicWidth: number
264
+ // graphicHeight: number
265
+ SeriesContainerPositionMap: Map<string, SeriesContainerPosition>
260
266
  }) {
267
+ // console.log('groupBubbles')
261
268
  force!
262
269
  // .force('x', d3.forceX().strength(fullParams.force.strength).x(graphicWidth / 2))
263
270
  // .force('y', d3.forceY().strength(fullParams.force.strength).y(graphicHeight / 2))
264
- .force('x', d3.forceX().strength(fullParams.force.strength).x(0))
265
- .force('y', d3.forceY().strength(fullParams.force.strength).y(0))
271
+ .force('x', d3.forceX().strength(fullParams.force.strength).x((data: BubblesSimulationDatum) => {
272
+ return SeriesContainerPositionMap.get(data.seriesLabel)!.centerX
273
+ }))
274
+ .force('y', d3.forceY().strength(fullParams.force.strength).y((data: BubblesSimulationDatum) => {
275
+ return SeriesContainerPositionMap.get(data.seriesLabel)!.centerY
276
+ }))
266
277
 
267
278
  force!.alpha(1).restart();
268
279
  }
@@ -312,23 +323,27 @@ export const Bubbles = defineSeriesPlugin('Bubbles', DEFAULT_BUBBLES_PARAMS)(({
312
323
  // force = makeForce(bubblesSelection, d)
313
324
  // })
314
325
 
315
- observer.layout$
316
- .pipe(
317
- first()
318
- )
319
- .subscribe(size => {
320
- selection
321
- .attr('transform', `translate(${size.width / 2}, ${size.height / 2})`)
322
- observer.layout$
323
- .pipe(
324
- takeUntil(destroy$)
325
- )
326
- .subscribe(size => {
327
- selection
328
- .transition()
329
- .attr('transform', `translate(${size.width / 2}, ${size.height / 2})`)
330
- })
331
- })
326
+ // observer.seriesContainerPosition$.subscribe(d => {
327
+ // console.log(d)
328
+ // })
329
+
330
+ // observer.layout$
331
+ // .pipe(
332
+ // first()
333
+ // )
334
+ // .subscribe(size => {
335
+ // selection
336
+ // .attr('transform', `translate(${size.width / 2}, ${size.height / 2})`)
337
+ // observer.layout$
338
+ // .pipe(
339
+ // takeUntil(destroy$)
340
+ // )
341
+ // .subscribe(size => {
342
+ // selection
343
+ // .transition()
344
+ // .attr('transform', `translate(${size.width / 2}, ${size.height / 2})`)
345
+ // })
346
+ // })
332
347
 
333
348
  // const bubbleGroupR$ = layout$.pipe(
334
349
  // map(d => {
@@ -370,18 +385,20 @@ export const Bubbles = defineSeriesPlugin('Bubbles', DEFAULT_BUBBLES_PARAMS)(({
370
385
  const bubblesData$ = new Observable<BubblesDatum[]>(subscriber => {
371
386
  combineLatest({
372
387
  layout: observer.layout$,
373
- computedData: observer.computedData$,
388
+ SeriesContainerPositionMap: observer.SeriesContainerPositionMap$,
389
+ visibleComputedLayoutData: observer.visibleComputedLayoutData$,
374
390
  scaleType: scaleType$
375
391
  }).pipe(
376
392
  takeUntil(destroy$),
377
- // 轉換後會退訂前一個未完成的訂閱事件,因此可以取到「同時間」最後一次的訂閱事件
378
393
  switchMap(async (d) => d),
379
394
  ).subscribe(data => {
395
+ // console.log(data.visibleComputedLayoutData)
380
396
  const bubblesData = createBubblesData({
381
- data: data.computedData,
397
+ data: data.visibleComputedLayoutData,
382
398
  LastBubbleDataMap,
383
399
  graphicWidth: data.layout.width,
384
400
  graphicHeight: data.layout.height,
401
+ SeriesContainerPositionMap: data.SeriesContainerPositionMap,
385
402
  scaleType: data.scaleType
386
403
  })
387
404
  subscriber.next(bubblesData)
@@ -405,12 +422,12 @@ export const Bubbles = defineSeriesPlugin('Bubbles', DEFAULT_BUBBLES_PARAMS)(({
405
422
  bubblesData: bubblesData$,
406
423
  SeriesDataMap: observer.SeriesDataMap$,
407
424
  fullParams: observer.fullParams$,
408
- highlightTarget: highlightTarget$
425
+ highlightTarget: highlightTarget$,
426
+ SeriesContainerPositionMap: observer.SeriesContainerPositionMap$,
409
427
  // fullChartParams: fullChartParams$
410
428
  // highlight: highlight$
411
429
  }).pipe(
412
430
  takeUntil(destroy$),
413
- // 轉換後會退訂前一個未完成的訂閱事件,因此可以取到「同時間」最後一次的訂閱事件
414
431
  switchMap(async (d) => d),
415
432
  ).subscribe(data => {
416
433
 
@@ -499,8 +516,9 @@ export const Bubbles = defineSeriesPlugin('Bubbles', DEFAULT_BUBBLES_PARAMS)(({
499
516
 
500
517
  groupBubbles({
501
518
  fullParams: data.fullParams,
502
- graphicWidth: data.layout.width,
503
- graphicHeight: data.layout.height
519
+ SeriesContainerPositionMap: data.SeriesContainerPositionMap
520
+ // graphicWidth: data.layout.width,
521
+ // graphicHeight: data.layout.height
504
522
  })
505
523
 
506
524
  bubblesSelection$.next(bubblesSelection)
@@ -514,7 +532,8 @@ export const Bubbles = defineSeriesPlugin('Bubbles', DEFAULT_BUBBLES_PARAMS)(({
514
532
  ),
515
533
  fullChartParams: observer.fullChartParams$,
516
534
  fullParams: observer.fullParams$,
517
- layout: observer.layout$
535
+ // layout: observer.layout$,
536
+ SeriesContainerPositionMap: observer.SeriesContainerPositionMap$,
518
537
  }).pipe(
519
538
  takeUntil(destroy$),
520
539
  switchMap(async d => d)
@@ -540,8 +559,9 @@ export const Bubbles = defineSeriesPlugin('Bubbles', DEFAULT_BUBBLES_PARAMS)(({
540
559
 
541
560
  groupBubbles({
542
561
  fullParams: data.fullParams,
543
- graphicWidth: data.layout.width,
544
- graphicHeight: data.layout.height
562
+ SeriesContainerPositionMap: data.SeriesContainerPositionMap
563
+ // graphicWidth: data.layout.width,
564
+ // graphicHeight: data.layout.height
545
565
  })
546
566
  force!.nodes(data.bubblesData);
547
567
  })