@orbcharts/plugins-basic 3.0.7 → 3.0.8
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.
- package/dist/orbcharts-plugins-basic.es.js +1608 -1600
- package/dist/orbcharts-plugins-basic.umd.js +25 -25
- package/dist/src/base/BaseStackedBars.d.ts +2 -0
- package/package.json +3 -3
- package/src/base/BaseStackedBars.ts +37 -26
- package/src/grid/plugins/StackedBars.ts +2 -0
- package/src/grid/plugins/StackedValueAxis.ts +2 -1
- package/src/multiGrid/plugins/MultiStackedBars.ts +3 -0
- package/src/multiGrid/plugins/MultiStackedValueAxis.ts +2 -1
@@ -9,6 +9,8 @@ interface BaseStackedBarsContext {
|
|
9
9
|
computedAxesData$: Observable<ComputedAxesDataGrid>;
|
10
10
|
visibleComputedData$: Observable<ComputedDatumGrid[][]>;
|
11
11
|
visibleComputedAxesData$: Observable<ComputedAxesDataGrid>;
|
12
|
+
filteredMinMaxValue$: Observable<[number, number]>;
|
13
|
+
filteredStackedMinMaxValue$: Observable<[number, number]>;
|
12
14
|
seriesLabels$: Observable<string[]>;
|
13
15
|
SeriesDataMap$: Observable<Map<string, ComputedDatumGrid[]>>;
|
14
16
|
GroupDataMap$: Observable<Map<string, ComputedDatumGrid[]>>;
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@orbcharts/plugins-basic",
|
3
|
-
"version": "3.0.
|
3
|
+
"version": "3.0.8",
|
4
4
|
"description": "Plugins for OrbCharts",
|
5
5
|
"author": "Blue Planet Inc.",
|
6
6
|
"license": "Apache-2.0",
|
@@ -39,8 +39,8 @@
|
|
39
39
|
"vite-plugin-dts": "^3.7.3"
|
40
40
|
},
|
41
41
|
"dependencies": {
|
42
|
-
"@orbcharts/core": "^3.0.
|
43
|
-
"@orbcharts/core-types": "^3.0.
|
42
|
+
"@orbcharts/core": "^3.0.6",
|
43
|
+
"@orbcharts/core-types": "^3.0.4",
|
44
44
|
"@orbcharts/plugins-basic-types": "^3.0.3",
|
45
45
|
"d3": "^7.8.5",
|
46
46
|
"rxjs": "^7.8.1"
|
@@ -38,6 +38,8 @@ interface BaseStackedBarsContext {
|
|
38
38
|
computedAxesData$: Observable<ComputedAxesDataGrid>
|
39
39
|
visibleComputedData$: Observable<ComputedDatumGrid[][]>
|
40
40
|
visibleComputedAxesData$: Observable<ComputedAxesDataGrid>
|
41
|
+
filteredMinMaxValue$: Observable<[number, number]>
|
42
|
+
filteredStackedMinMaxValue$: Observable<[number, number]>
|
41
43
|
seriesLabels$: Observable<string[]>
|
42
44
|
SeriesDataMap$: Observable<Map<string, ComputedDatumGrid[]>>
|
43
45
|
GroupDataMap$: Observable<Map<string, ComputedDatumGrid[]>>
|
@@ -162,8 +164,9 @@ function renderRectBars ({ graphicGSelection, rectClassName, barData, zeroY, gro
|
|
162
164
|
.ease(getD3TransitionEase(chartParams.transitionEase))
|
163
165
|
.delay((d, i) => d.groupIndex * delayGroup)
|
164
166
|
.attr('y', d => d._barStartY)
|
165
|
-
.attr('height', d => Math.abs(d._barHeight)
|
167
|
+
.attr('height', d => d._barHeight > 0 ? Math.abs(d._barHeight) : 1) // 無值還是給一個 1 的高度
|
166
168
|
})
|
169
|
+
|
167
170
|
|
168
171
|
// const barGroup = graphicGSelection
|
169
172
|
// .selectAll<SVGGElement, ComputedDatumGrid[]>(`g.${gClassName}`)
|
@@ -298,6 +301,8 @@ export const createBaseStackedBars: BasePluginFn<BaseStackedBarsContext> = (plug
|
|
298
301
|
computedAxesData$,
|
299
302
|
visibleComputedData$,
|
300
303
|
visibleComputedAxesData$,
|
304
|
+
filteredMinMaxValue$,
|
305
|
+
filteredStackedMinMaxValue$,
|
301
306
|
seriesLabels$,
|
302
307
|
SeriesDataMap$,
|
303
308
|
GroupDataMap$,
|
@@ -502,37 +507,40 @@ export const createBaseStackedBars: BasePluginFn<BaseStackedBarsContext> = (plug
|
|
502
507
|
|
503
508
|
// 堆疊後的高度對應圖軸的比例(最大值/最大值所在group的總和)
|
504
509
|
const yRatio$ = combineLatest({
|
505
|
-
visibleComputedAxesData: visibleComputedAxesData$,
|
506
|
-
groupScaleDomain: groupScaleDomain$
|
510
|
+
// visibleComputedAxesData: visibleComputedAxesData$,
|
511
|
+
// groupScaleDomain: groupScaleDomain$
|
512
|
+
filteredMinMaxValue: filteredMinMaxValue$,
|
513
|
+
filteredStackedMinMaxValue: filteredStackedMinMaxValue$
|
507
514
|
}).pipe(
|
508
515
|
takeUntil(destroy$),
|
509
516
|
switchMap(async d => d),
|
510
517
|
map(data => {
|
511
|
-
const groupScaleDomainMin = data.groupScaleDomain[0]
|
512
|
-
const groupScaleDomainMax = data.groupScaleDomain[1]
|
513
|
-
// 只選取group篩選範圍內的資料
|
514
|
-
const filteredData = data.visibleComputedAxesData
|
515
|
-
|
516
|
-
|
517
|
-
|
518
|
-
|
519
|
-
|
518
|
+
// const groupScaleDomainMin = data.groupScaleDomain[0]
|
519
|
+
// const groupScaleDomainMax = data.groupScaleDomain[1]
|
520
|
+
// // 只選取group篩選範圍內的資料
|
521
|
+
// const filteredData = data.visibleComputedAxesData
|
522
|
+
// .map(d => {
|
523
|
+
// return d.filter((_d, i) => {
|
524
|
+
// return _d.groupIndex >= groupScaleDomainMin && _d.groupIndex <= groupScaleDomainMax
|
525
|
+
// })
|
526
|
+
// })
|
520
527
|
|
521
|
-
const filteredDataList = filteredData.flat()
|
522
|
-
if (filteredDataList.length <= 1) {
|
523
|
-
|
524
|
-
}
|
528
|
+
// const filteredDataList = filteredData.flat()
|
529
|
+
// if (filteredDataList.length <= 1) {
|
530
|
+
// return 1
|
531
|
+
// }
|
525
532
|
|
526
|
-
const maxValueDatum = filteredDataList.reduce((max, current) => {
|
527
|
-
|
528
|
-
}, filteredDataList[0])
|
529
|
-
const maxValueGroupIndex = maxValueDatum.groupIndex
|
530
|
-
const maxValueGroupSum = filteredDataList
|
531
|
-
|
532
|
-
|
533
|
-
|
534
|
-
|
535
|
-
return maxValueDatum.value / maxValueGroupSum
|
533
|
+
// const maxValueDatum = filteredDataList.reduce((max, current) => {
|
534
|
+
// return current.value > max.value ? current : max;
|
535
|
+
// }, filteredDataList[0])
|
536
|
+
// const maxValueGroupIndex = maxValueDatum.groupIndex
|
537
|
+
// const maxValueGroupSum = filteredDataList
|
538
|
+
// .filter(d => d.groupIndex === maxValueGroupIndex)
|
539
|
+
// .reduce((sum, current) => {
|
540
|
+
// return sum + current.value
|
541
|
+
// }, 0)
|
542
|
+
// return maxValueDatum.value / maxValueGroupSum
|
543
|
+
return data.filteredMinMaxValue[1] / data.filteredStackedMinMaxValue[1]
|
536
544
|
})
|
537
545
|
)
|
538
546
|
|
@@ -548,6 +556,9 @@ export const createBaseStackedBars: BasePluginFn<BaseStackedBarsContext> = (plug
|
|
548
556
|
: []
|
549
557
|
return data.computedAxesData.map((series, seriesIndex) => {
|
550
558
|
return series.map((datum, groupIndex) => {
|
559
|
+
if (!accYArr[groupIndex]) {
|
560
|
+
accYArr[groupIndex] = 0
|
561
|
+
}
|
551
562
|
const _barStartY = accYArr[groupIndex] // 前一次的累加高度
|
552
563
|
let _barHeight = 0
|
553
564
|
if (datum.visible) {
|
@@ -42,6 +42,8 @@ export const StackedBars = defineGridPlugin(pluginConfig)(({ selection, name, su
|
|
42
42
|
computedAxesData$: observer.computedAxesData$,
|
43
43
|
visibleComputedData$: observer.visibleComputedData$,
|
44
44
|
visibleComputedAxesData$: observer.visibleComputedAxesData$,
|
45
|
+
filteredMinMaxValue$: observer.filteredMinMaxValue$,
|
46
|
+
filteredStackedMinMaxValue$: observer.filteredStackedMinMaxValue$,
|
45
47
|
seriesLabels$: observer.seriesLabels$,
|
46
48
|
SeriesDataMap$: observer.SeriesDataMap$,
|
47
49
|
GroupDataMap$: observer.GroupDataMap$,
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import {
|
2
|
+
of,
|
2
3
|
takeUntil,
|
3
4
|
map,
|
4
5
|
distinctUntilChanged,
|
@@ -79,7 +80,7 @@ export const StackedValueAxis = defineGridPlugin(pluginConfig)(({ selection, nam
|
|
79
80
|
const unsubscribeBaseValueAxis = createBaseValueAxis(pluginName, {
|
80
81
|
selection,
|
81
82
|
computedData$: observer.computedStackedData$, // 計算疊加value的資料
|
82
|
-
filteredMinMaxValue$: observer.
|
83
|
+
filteredMinMaxValue$: observer.filteredStackedMinMaxValue$,
|
83
84
|
fullParams$: observer.fullParams$,
|
84
85
|
fullDataFormatter$: observer.fullDataFormatter$,
|
85
86
|
fullChartParams$: observer.fullChartParams$,
|
@@ -81,6 +81,9 @@ export const MultiStackedBars = defineMultiGridPlugin(pluginConfig)(({ selection
|
|
81
81
|
visibleComputedData$: d.visibleComputedData$,
|
82
82
|
computedAxesData$: d.computedAxesData$,
|
83
83
|
visibleComputedAxesData$: d.visibleComputedAxesData$,
|
84
|
+
filteredMinMaxValue$: d.filteredMinMaxValue$, // 目前grid的資料
|
85
|
+
// filteredStackedMinMaxValue$: observer.filteredStackedMinMaxValue$, // 計算比例用的,使用全部資料當基底
|
86
|
+
filteredStackedMinMaxValue$: d.filteredStackedMinMaxValue$,
|
84
87
|
seriesLabels$: d.seriesLabels$,
|
85
88
|
SeriesDataMap$: d.SeriesDataMap$,
|
86
89
|
GroupDataMap$: d.GroupDataMap$,
|
@@ -114,7 +114,8 @@ export const MultiStackedValueAxis = defineMultiGridPlugin(pluginConfig)(({ sele
|
|
114
114
|
unsubscribeFnArr[i] = createBaseValueAxis(pluginName, {
|
115
115
|
selection: gridSelection,
|
116
116
|
computedData$: d.computedStackedData$, // 計算疊加value的資料
|
117
|
-
filteredMinMaxValue$:
|
117
|
+
// filteredMinMaxValue$: observer.filteredStackedMinMaxValue$, // 使用全部資料當比例尺
|
118
|
+
filteredMinMaxValue$: d.filteredStackedMinMaxValue$,
|
118
119
|
fullParams$: observer.fullParams$,
|
119
120
|
fullDataFormatter$: d.dataFormatter$,
|
120
121
|
fullChartParams$: observer.fullChartParams$,
|