@orbcharts/plugins-basic 3.0.0-beta.3 → 3.0.0-beta.5

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 (147) hide show
  1. package/dist/{src → orbcharts-plugins-basic/src}/base/BaseBarStack.d.ts +2 -2
  2. package/dist/{src → orbcharts-plugins-basic/src}/base/BaseBars.d.ts +2 -2
  3. package/dist/{src → orbcharts-plugins-basic/src}/base/BaseBarsTriangle.d.ts +2 -2
  4. package/dist/{src → orbcharts-plugins-basic/src}/base/BaseDots.d.ts +2 -2
  5. package/dist/{src → orbcharts-plugins-basic/src}/base/BaseGroupAxis.d.ts +2 -2
  6. package/dist/{src → orbcharts-plugins-basic/src}/base/BaseLegend.d.ts +1 -1
  7. package/dist/{src → orbcharts-plugins-basic/src}/base/BaseLineAreas.d.ts +3 -3
  8. package/dist/{src → orbcharts-plugins-basic/src}/base/BaseLines.d.ts +3 -3
  9. package/dist/{src → orbcharts-plugins-basic/src}/base/BaseValueAxis.d.ts +3 -2
  10. package/dist/{src → orbcharts-plugins-basic/src}/grid/defaults.d.ts +1 -1
  11. package/dist/{src → orbcharts-plugins-basic/src}/grid/gridObservables.d.ts +5 -5
  12. package/dist/orbcharts-plugins-basic/src/index.d.ts +6 -0
  13. package/dist/orbcharts-plugins-basic/src/multiValue/defaults.d.ts +9 -0
  14. package/dist/orbcharts-plugins-basic/src/multiValue/index.d.ts +8 -0
  15. package/dist/orbcharts-plugins-basic/src/multiValue/multiValueObservables.d.ts +33 -0
  16. package/dist/orbcharts-plugins-basic/src/multiValue/plugins/MultiValueLegend.d.ts +1 -0
  17. package/dist/orbcharts-plugins-basic/src/multiValue/plugins/MultiValueTooltip.d.ts +1 -0
  18. package/dist/orbcharts-plugins-basic/src/multiValue/plugins/Scatter.d.ts +3 -0
  19. package/dist/orbcharts-plugins-basic/src/multiValue/plugins/ScatterBubbles.d.ts +3 -0
  20. package/dist/orbcharts-plugins-basic/src/multiValue/plugins/XYAux.d.ts +3 -0
  21. package/dist/orbcharts-plugins-basic/src/multiValue/plugins/XYAxes.d.ts +3 -0
  22. package/dist/orbcharts-plugins-basic/src/multiValue/plugins/XYZoom.d.ts +1 -0
  23. package/dist/{src → orbcharts-plugins-basic/src}/series/seriesObservables.d.ts +3 -3
  24. package/dist/{src → orbcharts-plugins-basic/src}/utils/observables.d.ts +1 -1
  25. package/dist/{src → orbcharts-plugins-basic/src}/utils/orbchartsUtils.d.ts +3 -3
  26. package/dist/orbcharts-plugins-basic.es.js +11809 -10185
  27. package/dist/orbcharts-plugins-basic.umd.js +66 -34
  28. package/dist/src/index.d.ts +1 -5
  29. package/package.json +4 -4
  30. package/src/base/BaseBarStack.ts +2 -2
  31. package/src/base/BaseBars.ts +2 -2
  32. package/src/base/BaseBarsTriangle.ts +2 -2
  33. package/src/base/BaseDots.ts +2 -53
  34. package/src/base/BaseGroupAxis.ts +3 -3
  35. package/src/base/BaseLegend.ts +21 -17
  36. package/src/base/BaseLineAreas.ts +3 -3
  37. package/src/base/BaseLines.ts +3 -3
  38. package/src/base/BaseValueAxis.ts +46 -43
  39. package/src/grid/defaults.ts +3 -3
  40. package/src/grid/gridObservables.ts +24 -15
  41. package/src/grid/plugins/GridLegend.ts +2 -2
  42. package/src/grid/plugins/GridZoom.ts +14 -14
  43. package/src/grid/plugins/GroupAux.ts +206 -201
  44. package/src/grid/plugins/ValueAxis.ts +1 -0
  45. package/src/grid/plugins/ValueStackAxis.ts +1 -0
  46. package/src/index.ts +1 -0
  47. package/src/multiGrid/plugins/MultiGridLegend.ts +2 -2
  48. package/src/multiGrid/plugins/MultiValueAxis.ts +1 -0
  49. package/src/multiGrid/plugins/MultiValueStackAxis.ts +1 -0
  50. package/src/multiGrid/plugins/OverlappingValueAxes.ts +1 -0
  51. package/src/multiGrid/plugins/OverlappingValueStackAxes.ts +1 -0
  52. package/src/multiValue/defaults.ts +163 -0
  53. package/src/multiValue/index.ts +9 -0
  54. package/src/multiValue/multiValueObservables.ts +258 -0
  55. package/src/multiValue/plugins/MultiValueLegend.ts +107 -0
  56. package/src/multiValue/plugins/MultiValueTooltip.ts +66 -0
  57. package/src/multiValue/plugins/Scatter.ts +426 -0
  58. package/src/multiValue/plugins/ScatterBubbles.ts +551 -0
  59. package/src/multiValue/plugins/XYAux.ts +682 -0
  60. package/src/multiValue/plugins/XYAxes.ts +677 -0
  61. package/src/multiValue/plugins/XYZoom.ts +300 -0
  62. package/src/series/plugins/Bubbles.ts +4 -4
  63. package/src/series/plugins/Pie.ts +2 -2
  64. package/src/series/plugins/PieEventTexts.ts +2 -2
  65. package/src/series/plugins/PieLabels.ts +2 -2
  66. package/src/series/plugins/Rose.ts +2 -2
  67. package/src/series/plugins/RoseLabels.ts +2 -2
  68. package/src/series/plugins/SeriesLegend.ts +4 -4
  69. package/src/series/seriesObservables.ts +3 -3
  70. package/src/tree/plugins/TreeLegend.ts +3 -10
  71. package/src/utils/d3Utils.ts +2 -1
  72. package/src/utils/observables.ts +2 -2
  73. package/src/utils/orbchartsUtils.ts +7 -6
  74. package/dist/src/base/BaseGroupArea.d.ts +0 -0
  75. package/dist/src/multiValue/plugins/Scatter.d.ts +0 -0
  76. package/dist/src/multiValue/plugins/ScatterAxes.d.ts +0 -0
  77. package/dist/src/relationship/index.d.ts +0 -0
  78. package/src/base/BaseGroupArea.ts +0 -0
  79. package/src/multiValue/plugins/ScatterAxes.ts +0 -0
  80. /package/dist/{lib → orbcharts-plugins-basic/lib}/core-types.d.ts +0 -0
  81. /package/dist/{lib → orbcharts-plugins-basic/lib}/core.d.ts +0 -0
  82. /package/dist/{lib → orbcharts-plugins-basic/lib}/plugins-basic-types.d.ts +0 -0
  83. /package/dist/{src → orbcharts-plugins-basic/src}/base/BaseTooltip.d.ts +0 -0
  84. /package/dist/{src → orbcharts-plugins-basic/src}/base/types.d.ts +0 -0
  85. /package/dist/{src → orbcharts-plugins-basic/src}/const.d.ts +0 -0
  86. /package/dist/{src → orbcharts-plugins-basic/src}/grid/index.d.ts +0 -0
  87. /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/BarStack.d.ts +0 -0
  88. /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/Bars.d.ts +0 -0
  89. /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/BarsPN.d.ts +0 -0
  90. /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/BarsTriangle.d.ts +0 -0
  91. /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/Dots.d.ts +0 -0
  92. /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/GridLegend.d.ts +0 -0
  93. /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/GridTooltip.d.ts +0 -0
  94. /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/GridZoom.d.ts +0 -0
  95. /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/GroupAux.d.ts +0 -0
  96. /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/GroupAxis.d.ts +0 -0
  97. /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/LineAreas.d.ts +0 -0
  98. /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/Lines.d.ts +0 -0
  99. /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/ValueAxis.d.ts +0 -0
  100. /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/ValueStackAxis.d.ts +0 -0
  101. /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/defaults.d.ts +0 -0
  102. /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/index.d.ts +0 -0
  103. /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/multiGridObservables.d.ts +0 -0
  104. /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/plugins/MultiBarStack.d.ts +0 -0
  105. /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/plugins/MultiBars.d.ts +0 -0
  106. /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/plugins/MultiBarsTriangle.d.ts +0 -0
  107. /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/plugins/MultiDots.d.ts +0 -0
  108. /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/plugins/MultiGridLegend.d.ts +0 -0
  109. /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/plugins/MultiGridTooltip.d.ts +0 -0
  110. /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/plugins/MultiGroupAxis.d.ts +0 -0
  111. /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/plugins/MultiLineAreas.d.ts +0 -0
  112. /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/plugins/MultiLines.d.ts +0 -0
  113. /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/plugins/MultiValueAxis.d.ts +0 -0
  114. /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/plugins/MultiValueStackAxis.d.ts +0 -0
  115. /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/plugins/OverlappingValueAxes.d.ts +0 -0
  116. /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/plugins/OverlappingValueStackAxes.d.ts +0 -0
  117. /package/dist/{src/grid → orbcharts-plugins-basic/src/multiValue}/plugins/Ranking.d.ts +0 -0
  118. /package/dist/{src/grid → orbcharts-plugins-basic/src/multiValue}/plugins/RankingAxis.d.ts +0 -0
  119. /package/dist/{src → orbcharts-plugins-basic/src}/noneData/defaults.d.ts +0 -0
  120. /package/dist/{src → orbcharts-plugins-basic/src}/noneData/index.d.ts +0 -0
  121. /package/dist/{src → orbcharts-plugins-basic/src}/noneData/plugins/Container.d.ts +0 -0
  122. /package/dist/{src → orbcharts-plugins-basic/src}/noneData/plugins/Tooltip.d.ts +0 -0
  123. /package/dist/{src/multiValue → orbcharts-plugins-basic/src/relationship}/index.d.ts +0 -0
  124. /package/dist/{src → orbcharts-plugins-basic/src}/relationship/plugins/Relationship.d.ts +0 -0
  125. /package/dist/{src → orbcharts-plugins-basic/src}/series/defaults.d.ts +0 -0
  126. /package/dist/{src → orbcharts-plugins-basic/src}/series/index.d.ts +0 -0
  127. /package/dist/{src → orbcharts-plugins-basic/src}/series/plugins/Bubbles.d.ts +0 -0
  128. /package/dist/{src → orbcharts-plugins-basic/src}/series/plugins/Pie.d.ts +0 -0
  129. /package/dist/{src → orbcharts-plugins-basic/src}/series/plugins/PieEventTexts.d.ts +0 -0
  130. /package/dist/{src → orbcharts-plugins-basic/src}/series/plugins/PieLabels.d.ts +0 -0
  131. /package/dist/{src → orbcharts-plugins-basic/src}/series/plugins/Rose.d.ts +0 -0
  132. /package/dist/{src → orbcharts-plugins-basic/src}/series/plugins/RoseLabels.d.ts +0 -0
  133. /package/dist/{src → orbcharts-plugins-basic/src}/series/plugins/SeriesLegend.d.ts +0 -0
  134. /package/dist/{src → orbcharts-plugins-basic/src}/series/plugins/SeriesTooltip.d.ts +0 -0
  135. /package/dist/{src → orbcharts-plugins-basic/src}/series/plugins/Waffle.d.ts +0 -0
  136. /package/dist/{src → orbcharts-plugins-basic/src}/series/seriesUtils.d.ts +0 -0
  137. /package/dist/{src → orbcharts-plugins-basic/src}/tree/defaults.d.ts +0 -0
  138. /package/dist/{src → orbcharts-plugins-basic/src}/tree/index.d.ts +0 -0
  139. /package/dist/{src → orbcharts-plugins-basic/src}/tree/plugins/TreeLegend.d.ts +0 -0
  140. /package/dist/{src → orbcharts-plugins-basic/src}/tree/plugins/TreeMap.d.ts +0 -0
  141. /package/dist/{src → orbcharts-plugins-basic/src}/tree/plugins/TreeTooltip.d.ts +0 -0
  142. /package/dist/{src → orbcharts-plugins-basic/src}/utils/commonUtils.d.ts +0 -0
  143. /package/dist/{src → orbcharts-plugins-basic/src}/utils/d3Graphics.d.ts +0 -0
  144. /package/dist/{src → orbcharts-plugins-basic/src}/utils/d3Utils.d.ts +0 -0
  145. /package/dist/{vite.config.d.ts → orbcharts-plugins-basic/vite.config.d.ts} +0 -0
  146. /package/src/{grid → multiValue}/plugins/Ranking.ts +0 -0
  147. /package/src/{grid → multiValue}/plugins/RankingAxis.ts +0 -0
@@ -0,0 +1,300 @@
1
+ import * as d3 from 'd3'
2
+ import {
3
+ Observable,
4
+ combineLatest,
5
+ switchMap,
6
+ distinctUntilChanged,
7
+ first,
8
+ map,
9
+ takeUntil,
10
+ debounceTime,
11
+ Subject } from 'rxjs'
12
+ import type { DefinePluginConfig } from '../../../lib/core-types'
13
+ import type { DataFormatterMultiValue } from '../../../lib/core-types'
14
+ import {
15
+ defineMultiValuePlugin, createValueToAxisScale } from '../../../lib/core'
16
+ import { DEFAULT_X_Y_ZOOM_PARAMS } from '../defaults'
17
+ import { getClassName, getUniID } from '../../utils/orbchartsUtils'
18
+ import { LAYER_INDEX_OF_ROOT } from '../../const'
19
+
20
+ const pluginName = 'XYZoom'
21
+ const rectClassName = getClassName(pluginName, 'rect')
22
+
23
+ const pluginConfig: DefinePluginConfig<typeof pluginName, typeof DEFAULT_X_Y_ZOOM_PARAMS> = {
24
+ name: pluginName,
25
+ defaultParams: DEFAULT_X_Y_ZOOM_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 XYZoom = defineMultiValuePlugin(pluginConfig)(({ selection, rootSelection, name, observer, subject }) => {
37
+
38
+ const destroy$ = new Subject()
39
+
40
+ // const rootRectSelection: d3.Selection<SVGRectElement, any, any, any> = rootSelection
41
+ // .append('rect')
42
+ // .classed(rectClassName, true)
43
+ // .attr('opacity', 0)
44
+
45
+ // 紀錄zoom最後一次的transform
46
+ let lastTransform = {
47
+ k: 1,
48
+ x: 0,
49
+ y: 0
50
+ }
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(
64
+ // map(d => d[0] ? d[0].length - 1 : 0),
65
+ // distinctUntilChanged()
66
+ // )
67
+
68
+ // const fullDataFormatterEvent$: Subject<DataFormatterMultiValue> = new Subject()
69
+ // fullDataFormatterEvent$
70
+ // .pipe(
71
+ // takeUntil(destroy$),
72
+ // debounceTime(50)
73
+ // )
74
+ // .subscribe(fullDataFormatter => {
75
+ // store.fullDataFormatter$.next(fullDataFormatter)
76
+ // })
77
+
78
+ const initXAxis$ = observer.fullDataFormatter$.pipe(
79
+ map(d => d.xAxis),
80
+ // 只用第一次資料來計算scale才不會造成每次變動都受到影響
81
+ first()
82
+ )
83
+
84
+ const initYAxis$ = observer.fullDataFormatter$.pipe(
85
+ map(d => d.yAxis),
86
+ // 只用第一次資料來計算scale才不會造成每次變動都受到影響
87
+ first()
88
+ )
89
+
90
+
91
+ // const groupScale$ = combineLatest({
92
+ // initXAxis: initXAxis$,
93
+ // fullDataFormatter: observer.fullDataFormatter$,
94
+ // groupMax: groupMax$,
95
+ // layout: observer.layout$,
96
+ // // axisSize: observer.gridAxesSize$
97
+ // }).pipe(
98
+ // takeUntil(destroy$),
99
+ // switchMap(async (d) => d),
100
+ // map(data => {
101
+ // // const groupMin = 0
102
+ // const groupScaleDomainMin = data.initXAxis.scaleDomain[0] - data.initXAxis.scalePadding
103
+ // const groupScaleDomainMax = data.initXAxis.scaleDomain[1] === 'max'
104
+ // ? data.groupMax + data.initXAxis.scalePadding
105
+ // : data.initXAxis.scaleDomain[1] as number + data.initXAxis.scalePadding
106
+
107
+ // const groupScale: d3.ScaleLinear<number, number> = createValueToAxisScale({
108
+ // maxValue: data.groupMax,
109
+ // minValue: 0,
110
+ // axisWidth: data.layout.width,
111
+ // scaleDomain: [groupScaleDomainMin, groupScaleDomainMax],
112
+ // scaleRange: [0, 1]
113
+ // })
114
+
115
+ // return groupScale
116
+ // })
117
+ // )
118
+ const initXScale$: Observable<d3.ScaleLinear<number, number>> = new Observable(subscriber => {
119
+ combineLatest({
120
+ initXAxis: initXAxis$,
121
+ layout: observer.layout$,
122
+ minMaxXY: observer.minMaxXY$
123
+ }).pipe(
124
+ takeUntil(destroy$),
125
+ switchMap(async (d) => d),
126
+ ).subscribe(data => {
127
+
128
+ const xScale: d3.ScaleLinear<number, number> = createValueToAxisScale({
129
+ maxValue: data.minMaxXY.maxX,
130
+ minValue: data.minMaxXY.minX,
131
+ axisWidth: data.layout.width,
132
+ scaleDomain: data.initXAxis.scaleDomain,
133
+ scaleRange: data.initXAxis.scaleRange,
134
+ })
135
+
136
+ subscriber.next(xScale)
137
+ })
138
+ })
139
+
140
+ const initYScale$: Observable<d3.ScaleLinear<number, number>> = new Observable(subscriber => {
141
+ combineLatest({
142
+ initYAxis: initYAxis$,
143
+ layout: observer.layout$,
144
+ minMaxXY: observer.minMaxXY$
145
+ }).pipe(
146
+ takeUntil(destroy$),
147
+ switchMap(async (d) => d),
148
+ ).subscribe(data => {
149
+
150
+ const yScale: d3.ScaleLinear<number, number> = createValueToAxisScale({
151
+ maxValue: data.minMaxXY.maxY,
152
+ minValue: data.minMaxXY.minY,
153
+ axisWidth: data.layout.height,
154
+ scaleDomain: data.initYAxis.scaleDomain,
155
+ scaleRange: data.initYAxis.scaleRange,
156
+ reverse: true
157
+ })
158
+
159
+ subscriber.next(yScale)
160
+ })
161
+ })
162
+
163
+ const minMaxScaleDomain$ = combineLatest({
164
+ initXAxis: initXAxis$,
165
+ initYAxis: initYAxis$,
166
+ minMaxXY: observer.minMaxXY$
167
+ }).pipe(
168
+ takeUntil(destroy$),
169
+ switchMap(async (d) => d),
170
+ map(data => {
171
+ let minX = data.minMaxXY.minX
172
+ let maxX = data.minMaxXY.maxX
173
+ let minY = data.minMaxXY.minY
174
+ let maxY = data.minMaxXY.maxY
175
+
176
+ // 原始設定為auto時要額外判斷
177
+ if (data.initXAxis.scaleDomain[0] === 'auto' && minX > 0) {
178
+ minX = 0
179
+ }
180
+ if (data.initXAxis.scaleDomain[1] === 'auto' && maxX < 0) {
181
+ maxX = 0
182
+ }
183
+ if (data.initYAxis.scaleDomain[0] === 'auto' && minY > 0) {
184
+ minY = 0
185
+ }
186
+ if (data.initYAxis.scaleDomain[1] === 'auto' && maxY < 0) {
187
+ maxY = 0
188
+ }
189
+
190
+ return {
191
+ minX,
192
+ maxX,
193
+ minY,
194
+ maxY
195
+ }
196
+ }),
197
+ )
198
+
199
+ combineLatest({
200
+ initXScale: initXScale$,
201
+ // initXAxis: initXAxis$,
202
+ // fullDataFormatter: fullDataFormatter$.pipe(first()), // 只用第一次資料來計算scale才不會造成每次變動都受到影響
203
+ fullDataFormatter: observer.fullDataFormatter$,
204
+ // groupMax: groupMax$,
205
+ // minMaxXY: observer.minMaxXY$,
206
+ minMaxScaleDomain: minMaxScaleDomain$,
207
+ // layout: observer.layout$,
208
+ // axisSize: observer.gridAxesSize$
209
+ }).pipe(
210
+ takeUntil(destroy$),
211
+ switchMap(async (d) => d),
212
+ ).subscribe(data => {
213
+ // const groupMin = 0
214
+
215
+ const shadowScale = data.initXScale.copy()
216
+
217
+ const zoom = d3.zoom()
218
+ // .scaleExtent([1, data.groupMaxIndex])
219
+ // .translateExtent([[0, 0], [data.layout.rootWidth, data.layout.rootWidth]])
220
+ .on("zoom", function zoomed(event) {
221
+ // debugger
222
+ // console.log('event', event)
223
+ const t = event.transform;
224
+
225
+ // if (event.sourceEvent.type === 'mousemove') {
226
+ // // 當進行平移時,反向計算 x 軸
227
+ // const dx = event.transform.x - currentTransform.x; // 本次平移增量
228
+ // const reversedX = currentTransform.x - dx; // 反向累積平移
229
+ // // 更新變換狀態
230
+ // currentTransform = d3.zoomIdentity
231
+ // .translate(reversedX, event.transform.y)
232
+ // .scale(event.transform.k);
233
+ // } else {
234
+ // // 縮放操作:只更新縮放比例
235
+ // currentTransform = d3.zoomIdentity
236
+ // .translate(currentTransform.x, currentTransform.y)
237
+ // .scale(event.transform.k);
238
+ // }
239
+ // console.log('currentTransform', currentTransform)
240
+
241
+ // console.log('t.x', t.x)
242
+ const mapGroupindex = (d: number) => {
243
+ const n = Math.round(d)
244
+ return Math.min(data.minMaxScaleDomain.maxX, Math.max(data.minMaxScaleDomain.minX, n));
245
+ }
246
+
247
+ const zoomedDomain = t.rescaleX(shadowScale)
248
+ .domain()
249
+ .map(mapGroupindex)
250
+
251
+
252
+ // domain超過極限值
253
+ if (zoomedDomain[0] <= data.minMaxScaleDomain.minX && zoomedDomain[1] >= data.minMaxScaleDomain.maxX) {
254
+ // 繼續縮小
255
+ if (t.k < lastTransform.k) {
256
+ // 維持前一次的transform
257
+ t.k = lastTransform.k
258
+ t.x = lastTransform.x
259
+ t.y = lastTransform.y
260
+ }
261
+ // domain間距小於1
262
+ } else if ((zoomedDomain[1] - zoomedDomain[0]) <= 1) {
263
+ // 繼續放大
264
+ if (t.k > lastTransform.k) {
265
+ // 維持前一次的transform
266
+ t.k = lastTransform.k
267
+ t.x = lastTransform.x
268
+ t.y = lastTransform.y
269
+ }
270
+ }
271
+
272
+ // 紀錄transform
273
+ lastTransform.k = t.k
274
+ lastTransform.x = t.x
275
+ lastTransform.y = t.y
276
+
277
+ // console.log(zoomedDomain)
278
+ const newDataFormatter: DataFormatterMultiValue = {
279
+ ...data.fullDataFormatter,
280
+ xAxis: {
281
+ ...data.fullDataFormatter.xAxis,
282
+ scaleDomain: zoomedDomain
283
+ }
284
+ }
285
+ subject.dataFormatter$.next(newDataFormatter)
286
+ })
287
+
288
+ // 傳入外層selection
289
+ // subject.selection.call(zoom as any)
290
+ rootSelection.call(zoom)
291
+
292
+ })
293
+
294
+ return () => {
295
+ destroy$.next(undefined)
296
+ // rootRectSelection.remove()
297
+
298
+ rootSelection.call(d3.zoom().on('zoom', null))
299
+ }
300
+ })
@@ -17,7 +17,7 @@ import type {
17
17
  EventName,
18
18
  ComputedDataSeries,
19
19
  ComputedDatumSeries,
20
- SeriesContainerPosition } from '../../../lib/core-types'
20
+ ContainerPosition } from '../../../lib/core-types'
21
21
  import {
22
22
  defineSeriesPlugin } from '../../../lib/core'
23
23
  import type { BubblesParams, ArcScaleType } from '../../../lib/plugins-basic-types'
@@ -147,12 +147,12 @@ function createBubblesData ({ visibleComputedLayoutData, LastBubbleDataMap, grap
147
147
  LastBubbleDataMap: Map<string, BubblesDatum>
148
148
  graphicWidth: number
149
149
  graphicHeight: number
150
- SeriesContainerPositionMap: Map<string, SeriesContainerPosition>
150
+ SeriesContainerPositionMap: Map<string, ContainerPosition>
151
151
  scaleType: ArcScaleType
152
152
  // highlightIds: string[]
153
153
  }): BubblesDatum[] {
154
154
  // 虛擬大圓(所有小圓聚合起來的大圓)的半徑
155
- const totalR = Math.min(...[graphicWidth, graphicHeight]) / 2
155
+ const totalR = Math.min(...[, graphicHeight]) / 2
156
156
 
157
157
  const data = visibleComputedLayoutData.flat()
158
158
 
@@ -330,7 +330,7 @@ function groupBubbles ({ fullParams, SeriesContainerPositionMap }: {
330
330
  fullParams: BubblesParams
331
331
  // graphicWidth: number
332
332
  // graphicHeight: number
333
- SeriesContainerPositionMap: Map<string, SeriesContainerPosition>
333
+ SeriesContainerPositionMap: Map<string, ContainerPosition>
334
334
  }) {
335
335
  // console.log('groupBubbles')
336
336
  force!
@@ -12,7 +12,7 @@ import type { DefinePluginConfig } from '../../../lib/core-types'
12
12
  import type {
13
13
  ComputedDataSeries,
14
14
  ComputedDatumSeries,
15
- SeriesContainerPosition,
15
+ ContainerPosition,
16
16
  ChartParams,
17
17
  EventSeries,
18
18
  Layout } from '../../../lib/core-types'
@@ -210,7 +210,7 @@ function createEachPie (pluginName: string, context: {
210
210
  fullParams$: Observable<PieParams>
211
211
  fullChartParams$: Observable<ChartParams>
212
212
  seriesHighlight$: Observable<ComputedDatumSeries[]>
213
- seriesContainerPosition$: Observable<SeriesContainerPosition>
213
+ seriesContainerPosition$: Observable<ContainerPosition>
214
214
  event$: Subject<EventSeries>
215
215
  }) {
216
216
  const destroy$ = new Subject()
@@ -15,7 +15,7 @@ import {
15
15
  import type {
16
16
  ComputedDatumSeries,
17
17
  ChartParams,
18
- SeriesContainerPosition,
18
+ ContainerPosition,
19
19
  EventName,
20
20
  EventSeries } from '../../../lib/core-types'
21
21
  import type { PieEventTextsParams } from '../../../lib/plugins-basic-types'
@@ -110,7 +110,7 @@ function createEachPieEventTexts (pluginName: string, context: {
110
110
  fullParams$: Observable<PieEventTextsParams>
111
111
  fullChartParams$: Observable<ChartParams>
112
112
  seriesHighlight$: Observable<ComputedDatumSeries[]>
113
- seriesContainerPosition$: Observable<SeriesContainerPosition>
113
+ seriesContainerPosition$: Observable<ContainerPosition>
114
114
  event$: Subject<EventSeries>
115
115
  }) {
116
116
  const destroy$ = new Subject()
@@ -14,7 +14,7 @@ import {
14
14
  defineSeriesPlugin } from '../../../lib/core'
15
15
  import type {
16
16
  ComputedDatumSeries,
17
- SeriesContainerPosition,
17
+ ContainerPosition,
18
18
  EventSeries,
19
19
  ChartParams } from '../../../lib/core-types'
20
20
  import type { PieLabelsParams } from '../../../lib/plugins-basic-types'
@@ -453,7 +453,7 @@ function createEachPieLabel (pluginName: string, context: {
453
453
  fullChartParams$: Observable<ChartParams>
454
454
  textSizePx$: Observable<number>
455
455
  seriesHighlight$: Observable<ComputedDatumSeries[]>
456
- seriesContainerPosition$: Observable<SeriesContainerPosition>
456
+ seriesContainerPosition$: Observable<ContainerPosition>
457
457
  event$: Subject<EventSeries>
458
458
  }) {
459
459
  const destroy$ = new Subject()
@@ -14,7 +14,7 @@ import type { DefinePluginConfig } from '../../../lib/core-types'
14
14
  import type {
15
15
  ComputedDataSeries,
16
16
  ComputedDatumSeries,
17
- SeriesContainerPosition,
17
+ ContainerPosition,
18
18
  ChartParams,
19
19
  EventSeries,
20
20
  Layout } from '../../../lib/core-types'
@@ -219,7 +219,7 @@ function createEachRose (pluginName: string, context: {
219
219
  fullParams$: Observable<RoseParams>
220
220
  fullChartParams$: Observable<ChartParams>
221
221
  seriesHighlight$: Observable<ComputedDatumSeries[]>
222
- seriesContainerPosition$: Observable<SeriesContainerPosition>
222
+ seriesContainerPosition$: Observable<ContainerPosition>
223
223
  event$: Subject<EventSeries>
224
224
  }) {
225
225
  const destroy$ = new Subject()
@@ -14,7 +14,7 @@ import {
14
14
  defineSeriesPlugin } from '../../../lib/core'
15
15
  import type {
16
16
  ComputedDatumSeries,
17
- SeriesContainerPosition,
17
+ ContainerPosition,
18
18
  EventSeries,
19
19
  ChartParams } from '../../../lib/core-types'
20
20
  import type { RoseLabelsParams } from '../../../lib/plugins-basic-types'
@@ -413,7 +413,7 @@ function createEachPieLabel (pluginName: string, context: {
413
413
  fullChartParams$: Observable<ChartParams>
414
414
  textSizePx$: Observable<number>
415
415
  seriesHighlight$: Observable<ComputedDatumSeries[]>
416
- seriesContainerPosition$: Observable<SeriesContainerPosition>
416
+ seriesContainerPosition$: Observable<ContainerPosition>
417
417
  event$: Subject<EventSeries>
418
418
  }) {
419
419
  const destroy$ = new Subject()
@@ -65,7 +65,7 @@ export const SeriesLegend = defineSeriesPlugin(pluginConfig)(({ selection, rootS
65
65
 
66
66
  const destroy$ = new Subject()
67
67
 
68
- const seriesLabels$: Observable<string[]> = observer.SeriesDataMap$.pipe(
68
+ const legendLabels$: Observable<string[]> = observer.SeriesDataMap$.pipe(
69
69
  takeUntil(destroy$),
70
70
  map(data => {
71
71
  return Array.from(data.keys())
@@ -76,7 +76,7 @@ export const SeriesLegend = defineSeriesPlugin(pluginConfig)(({ selection, rootS
76
76
  const fullParams$ = observer.fullParams$.pipe(
77
77
  takeUntil(destroy$),
78
78
  map(d => {
79
- const seriesList = [
79
+ const labelList = [
80
80
  {
81
81
  listRectWidth: d.listRectWidth,
82
82
  listRectHeight: d.listRectHeight,
@@ -85,14 +85,14 @@ export const SeriesLegend = defineSeriesPlugin(pluginConfig)(({ selection, rootS
85
85
  ]
86
86
  return {
87
87
  ...d,
88
- seriesList
88
+ labelList
89
89
  }
90
90
  })
91
91
  )
92
92
 
93
93
  const unsubscribeBaseLegend = createBaseLegend(pluginName, {
94
94
  rootSelection,
95
- seriesLabels$,
95
+ legendLabels$,
96
96
  fullParams$,
97
97
  layout$: observer.layout$,
98
98
  fullChartParams$: observer.fullChartParams$,
@@ -14,7 +14,7 @@ import {
14
14
  distinctUntilChanged
15
15
  } from 'rxjs'
16
16
  import type {
17
- SeriesContainerPosition } from '../../lib/core-types'
17
+ ContainerPosition } from '../../lib/core-types'
18
18
  import { getClassName, getUniID } from '../utils/orbchartsUtils'
19
19
 
20
20
  function createSeriesSelection ({ selection, pluginName, separateSeries$, seriesLabels$ }: {
@@ -55,7 +55,7 @@ export const seriesStartSelectionObservable = ({ selection, pluginName, separate
55
55
  pluginName: string
56
56
  separateSeries$: Observable<boolean>
57
57
  seriesLabels$: Observable<string[]>
58
- seriesContainerPosition$: Observable<SeriesContainerPosition[]>
58
+ seriesContainerPosition$: Observable<ContainerPosition[]>
59
59
  }) => {
60
60
 
61
61
  const seriesStartSelection$ = createSeriesSelection({ selection, pluginName, separateSeries$, seriesLabels$ })
@@ -102,7 +102,7 @@ export const seriesCenterSelectionObservable = ({ selection, pluginName, separat
102
102
  pluginName: string
103
103
  separateSeries$: Observable<boolean>
104
104
  seriesLabels$: Observable<string[]>
105
- seriesContainerPosition$: Observable<SeriesContainerPosition[]>
105
+ seriesContainerPosition$: Observable<ContainerPosition[]>
106
106
  }) => {
107
107
 
108
108
  const seriesCenterSelection$ = createSeriesSelection({ selection, pluginName, separateSeries$, seriesLabels$ })
@@ -65,18 +65,11 @@ export const TreeLegend = defineTreePlugin(pluginConfig)(({ selection, rootSelec
65
65
 
66
66
  const destroy$ = new Subject()
67
67
 
68
- const categoryLabels$: Observable<string[]> = observer.CategoryDataMap$.pipe(
69
- takeUntil(destroy$),
70
- map(data => {
71
- return Array.from(data.keys())
72
- })
73
- )
74
-
75
68
  // 全部列點矩型使用相同樣式參數
76
69
  const fullParams$ = observer.fullParams$.pipe(
77
70
  takeUntil(destroy$),
78
71
  map(d => {
79
- const seriesList = [
72
+ const labelList = [
80
73
  {
81
74
  listRectWidth: d.listRectWidth,
82
75
  listRectHeight: d.listRectHeight,
@@ -85,14 +78,14 @@ export const TreeLegend = defineTreePlugin(pluginConfig)(({ selection, rootSelec
85
78
  ]
86
79
  return {
87
80
  ...d,
88
- seriesList
81
+ labelList
89
82
  }
90
83
  })
91
84
  )
92
85
 
93
86
  const unsubscribeBaseLegend = createBaseLegend(pluginName, {
94
87
  rootSelection,
95
- seriesLabels$: categoryLabels$,
88
+ legendLabels$: observer.categoryLabels$,
96
89
  fullParams$,
97
90
  layout$: observer.layout$,
98
91
  fullChartParams$: observer.fullChartParams$,
@@ -58,7 +58,8 @@ export function makeD3Arc ({ axisWidth, innerRadius, outerRadius, padAngle, corn
58
58
 
59
59
  export const parseTickFormatValue = (value: any, tickFormat: string | ((text: d3.NumberValue) => string)) => {
60
60
  if (tickFormat! instanceof Function == true) {
61
- return (tickFormat as ((text: d3.NumberValue) => string))(value)
61
+ const v = (tickFormat as ((text: d3.NumberValue) => string))(value)
62
+ return String(v ?? '')
62
63
  }
63
64
  return d3.format(tickFormat as string)!(value)
64
65
  }
@@ -3,10 +3,10 @@ import { Observable, merge, distinctUntilChanged, fromEvent } from 'rxjs'
3
3
 
4
4
  export function d3EventObservable(selection: d3.Selection<any, any, any, any>, event: any) {
5
5
  // Start with an observable that will never emit
6
- let obs = new Observable(() => {});
6
+ let obs: Observable<MouseEvent> = new Observable(() => {});
7
7
  selection.each(function () {
8
8
  // Create observables from each of the elements
9
- const events = fromEvent(this as any, event);
9
+ const events: Observable<MouseEvent> = fromEvent(this, event);
10
10
  // Merge the observables into one
11
11
  obs = merge(obs, events);
12
12
  });
@@ -3,12 +3,13 @@ import type {
3
3
  ColorType,
4
4
  ChartParams,
5
5
  ComputedDatumBase,
6
- ComputedDatumSeriesValue,
7
- ComputedDatumCategoryValue } from '../../lib/core-types'
6
+ ComputedDatumBaseValue,
7
+ ComputedDatumBaseSeries,
8
+ ComputedDatumBaseCategory } from '../../lib/core-types'
8
9
  import { getMinAndMax } from './commonUtils'
9
10
 
10
11
  // 取得最小及最大值 - datum格式陣列資料
11
- export function getMinAndMaxValue (data: ComputedDatumBase[]): [number, number] {
12
+ export function getMinAndMaxValue (data: (ComputedDatumBase & ComputedDatumBaseValue)[]): [number, number] {
12
13
  const arr = data
13
14
  .filter(d => d.value != null && d.visible != false)
14
15
  .map(d => d.value as number)
@@ -37,7 +38,7 @@ export function getSeriesValueColor () {
37
38
 
38
39
  }
39
40
 
40
- export function getCategoryValueColor ({ datum, colorType, fullChartParams }: { datum: ComputedDatumCategoryValue, colorType: ColorType, fullChartParams: ChartParams }) {
41
+ export function getCategoryValueColor ({ datum, colorType, fullChartParams }: { datum: ComputedDatumBaseCategory, colorType: ColorType, fullChartParams: ChartParams }) {
41
42
 
42
43
  }
43
44
 
@@ -53,8 +54,8 @@ export function getCategoryValueColor ({ datum, colorType, fullChartParams }: {
53
54
  export function getDatumColor ({ datum, colorType, fullChartParams }: { datum: ComputedDatumBase, colorType: ColorType, fullChartParams: ChartParams }) {
54
55
  // 對應series資料中的顏色
55
56
  if (colorType === 'series') {
56
- if ((datum as unknown as ComputedDatumSeriesValue).color) {
57
- return (datum as unknown as ComputedDatumSeriesValue).color
57
+ if ((datum as unknown as ComputedDatumBaseSeries).color) {
58
+ return (datum as unknown as ComputedDatumBaseSeries).color
58
59
  } else {
59
60
  // 非series類型的資料則回傳陣列中第1個顏色
60
61
  return fullChartParams.colors[fullChartParams.colorScheme].series[0]
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes