@orbcharts/plugins-basic 3.0.0-beta.6 → 3.0.0-beta.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/src/base/{BaseBarStack.d.ts → BaseStackedBar.d.ts} +4 -4
- package/dist/orbcharts-plugins-basic/src/grid/defaults.d.ts +3 -3
- package/dist/orbcharts-plugins-basic/src/grid/index.d.ts +2 -2
- package/dist/orbcharts-plugins-basic/src/grid/plugins/StackedBar.d.ts +1 -0
- package/dist/orbcharts-plugins-basic/src/grid/plugins/StackedValueAxis.d.ts +1 -0
- package/dist/orbcharts-plugins-basic/src/index.d.ts +1 -0
- package/dist/orbcharts-plugins-basic/src/multiGrid/defaults.d.ts +4 -4
- package/dist/orbcharts-plugins-basic/src/multiGrid/index.d.ts +3 -3
- package/dist/orbcharts-plugins-basic/src/multiGrid/plugins/MultiStackedBar.d.ts +1 -0
- package/dist/orbcharts-plugins-basic/src/multiGrid/plugins/MultiStackedValueAxis.d.ts +1 -0
- package/dist/orbcharts-plugins-basic/src/multiGrid/plugins/OverlappingStackedValueAxes.d.ts +1 -0
- package/dist/orbcharts-plugins-basic/src/noneData/plugins/Container.d.ts +0 -1
- package/dist/orbcharts-plugins-basic/src/noneData/plugins/Tooltip.d.ts +0 -3
- package/dist/orbcharts-plugins-basic/src/relationship/defaults.d.ts +5 -0
- package/dist/orbcharts-plugins-basic/src/relationship/index.d.ts +4 -0
- package/dist/orbcharts-plugins-basic/src/relationship/plugins/ForceDirected.d.ts +3 -0
- package/dist/orbcharts-plugins-basic/src/relationship/plugins/RelationshipLegend.d.ts +1 -0
- package/dist/orbcharts-plugins-basic/src/relationship/plugins/RelationshipTooltip.d.ts +1 -0
- package/dist/orbcharts-plugins-basic/src/relationship/relationshipObservables.d.ts +1 -0
- package/dist/orbcharts-plugins-basic/src/utils/commonUtils.d.ts +1 -1
- package/dist/orbcharts-plugins-basic/src/utils/d3Utils.d.ts +2 -2
- package/dist/orbcharts-plugins-basic/src/utils/orbchartsUtils.d.ts +1 -1
- package/dist/orbcharts-plugins-basic.es.js +8088 -7413
- package/dist/orbcharts-plugins-basic.umd.js +45 -32
- package/package.json +4 -4
- package/src/base/BaseBars.ts +4 -4
- package/src/base/BaseBarsTriangle.ts +4 -2
- package/src/base/BaseDots.ts +1 -1
- package/src/base/BaseGroupAxis.ts +47 -47
- package/src/base/BaseLegend.ts +4 -4
- package/src/base/BaseLineAreas.ts +1 -1
- package/src/base/{BaseBarStack.ts → BaseStackedBar.ts} +20 -18
- package/src/base/BaseTooltip.ts +1 -1
- package/src/base/BaseValueAxis.ts +55 -55
- package/src/grid/defaults.ts +8 -6
- package/src/grid/gridObservables.ts +32 -32
- package/src/grid/index.ts +2 -2
- package/src/grid/plugins/GridZoom.ts +6 -6
- package/src/grid/plugins/GroupAux.ts +23 -23
- package/src/grid/plugins/{BarStack.ts → StackedBar.ts} +7 -7
- package/src/grid/plugins/{ValueStackAxis.ts → StackedValueAxis.ts} +5 -5
- package/src/index.ts +1 -5
- package/src/multiGrid/defaults.ts +7 -7
- package/src/multiGrid/index.ts +3 -3
- package/src/multiGrid/plugins/MultiBars.ts +1 -1
- package/src/multiGrid/plugins/MultiBarsTriangle.ts +1 -1
- package/src/multiGrid/plugins/MultiGroupAxis.ts +1 -1
- package/src/multiGrid/plugins/{MultiBarStack.ts → MultiStackedBar.ts} +8 -8
- package/src/multiGrid/plugins/{MultiValueStackAxis.ts → MultiStackedValueAxis.ts} +3 -3
- package/src/multiGrid/plugins/MultiValueAxis.ts +1 -1
- package/src/multiGrid/plugins/{OverlappingValueStackAxes.ts → OverlappingStackedValueAxes.ts} +8 -8
- package/src/multiGrid/plugins/OverlappingValueAxes.ts +3 -3
- package/src/multiValue/defaults.ts +10 -6
- package/src/multiValue/multiValueObservables.ts +50 -11
- package/src/multiValue/plugins/ScatterBubbles.ts +6 -3
- package/src/multiValue/plugins/XYAxes.ts +36 -28
- package/src/noneData/plugins/Container.ts +23 -23
- package/src/noneData/plugins/Tooltip.ts +365 -365
- package/src/relationship/defaults.ts +113 -0
- package/src/relationship/index.ts +4 -0
- package/src/relationship/plugins/ForceDirected.ts +1148 -0
- package/src/relationship/plugins/RelationshipLegend.ts +100 -0
- package/src/relationship/plugins/RelationshipTooltip.ts +66 -0
- package/src/relationship/relationshipObservables.ts +50 -0
- package/src/series/defaults.ts +8 -8
- package/src/series/plugins/Bubbles.ts +14 -13
- package/src/series/plugins/PieEventTexts.ts +20 -19
- package/src/tree/defaults.ts +1 -1
- package/src/utils/commonUtils.ts +5 -5
- package/src/utils/d3Utils.ts +2 -2
- package/src/utils/orbchartsUtils.ts +22 -7
- package/dist/orbcharts-plugins-basic/src/grid/plugins/BarStack.d.ts +0 -1
- package/dist/orbcharts-plugins-basic/src/grid/plugins/ValueStackAxis.d.ts +0 -1
- package/dist/orbcharts-plugins-basic/src/multiGrid/plugins/MultiBarStack.d.ts +0 -1
- package/dist/orbcharts-plugins-basic/src/multiGrid/plugins/MultiValueStackAxis.d.ts +0 -1
- package/dist/orbcharts-plugins-basic/src/multiGrid/plugins/OverlappingValueStackAxes.d.ts +0 -1
- /package/dist/orbcharts-plugins-basic/src/relationship/plugins/{Relationship.d.ts → ForceDirectedBubbles.d.ts} +0 -0
- /package/src/relationship/plugins/{Relationship.ts → ForceDirectedBubbles.ts} +0 -0
@@ -22,7 +22,7 @@ import type {
|
|
22
22
|
} from '../../lib/core-types'
|
23
23
|
import type { BaseValueAxisParams } from '../../lib/plugins-basic-types'
|
24
24
|
import { parseTickFormatValue } from '../utils/d3Utils'
|
25
|
-
import { getColor,
|
25
|
+
import { getColor, getMinMaxValue, getClassName, getUniID } from '../utils/orbchartsUtils'
|
26
26
|
|
27
27
|
// export interface BaseValueAxisParams {
|
28
28
|
// labelOffset: [number, number]
|
@@ -83,35 +83,35 @@ function renderAxisLabel ({ selection, textClassName, fullParams, axisLabelAlign
|
|
83
83
|
const offsetY = fullParams.tickPadding + fullParams.labelOffset[1]
|
84
84
|
let labelX = 0
|
85
85
|
let labelY = 0
|
86
|
-
if (fullDataFormatter.
|
86
|
+
if (fullDataFormatter.groupAxis.position === 'bottom') {
|
87
87
|
// labelY = - gridAxesSize.height - offsetY
|
88
88
|
labelY = - offsetY
|
89
|
-
if (fullDataFormatter.
|
89
|
+
if (fullDataFormatter.valueAxis.position === 'left') {
|
90
90
|
labelX = - offsetX
|
91
|
-
} else if (fullDataFormatter.
|
91
|
+
} else if (fullDataFormatter.valueAxis.position === 'right') {
|
92
92
|
labelX = offsetX
|
93
93
|
}
|
94
|
-
} else if (fullDataFormatter.
|
94
|
+
} else if (fullDataFormatter.groupAxis.position === 'top') {
|
95
95
|
// labelY = gridAxesSize.height + offsetY
|
96
96
|
labelY = offsetY
|
97
|
-
if (fullDataFormatter.
|
97
|
+
if (fullDataFormatter.valueAxis.position === 'left') {
|
98
98
|
labelX = - offsetX
|
99
|
-
} else if (fullDataFormatter.
|
99
|
+
} else if (fullDataFormatter.valueAxis.position === 'right') {
|
100
100
|
labelX = offsetX
|
101
101
|
}
|
102
|
-
} else if (fullDataFormatter.
|
102
|
+
} else if (fullDataFormatter.groupAxis.position === 'left') {
|
103
103
|
// labelX = gridAxesSize.width + offsetX
|
104
104
|
labelX = offsetX
|
105
|
-
if (fullDataFormatter.
|
105
|
+
if (fullDataFormatter.valueAxis.position === 'bottom') {
|
106
106
|
labelY = offsetY
|
107
|
-
} else if (fullDataFormatter.
|
107
|
+
} else if (fullDataFormatter.valueAxis.position === 'top') {
|
108
108
|
labelY = - offsetY
|
109
109
|
}
|
110
|
-
} else if (fullDataFormatter.
|
110
|
+
} else if (fullDataFormatter.groupAxis.position === 'right') {
|
111
111
|
labelX = - offsetX
|
112
|
-
if (fullDataFormatter.
|
112
|
+
if (fullDataFormatter.valueAxis.position === 'bottom') {
|
113
113
|
labelY = offsetY
|
114
|
-
} else if (fullDataFormatter.
|
114
|
+
} else if (fullDataFormatter.valueAxis.position === 'top') {
|
115
115
|
labelY = - offsetY
|
116
116
|
}
|
117
117
|
}
|
@@ -142,7 +142,7 @@ function renderAxisLabel ({ selection, textClassName, fullParams, axisLabelAlign
|
|
142
142
|
// 偏移使用 x, y 而非 transform 才不會受到外層 scale 變形影響
|
143
143
|
.attr('x', labelX)
|
144
144
|
.attr('y', labelY)
|
145
|
-
.text(d => fullDataFormatter.
|
145
|
+
.text(d => fullDataFormatter.valueAxis.label)
|
146
146
|
})
|
147
147
|
.attr('transform', d => `translate(0, ${gridAxesSize.height})`)
|
148
148
|
// .attr('transform', d => `translate(${- fullParams.tickPadding + fullParams.labelOffset[0]}, ${gridAxesSize.height + fullParams.tickPadding + fullParams.labelOffset[1]})`)
|
@@ -169,8 +169,6 @@ function renderAxis ({ selection, yAxisClassName, fullParams, tickTextAlign, gri
|
|
169
169
|
.join('g')
|
170
170
|
.classed(yAxisClassName, true)
|
171
171
|
|
172
|
-
const valueLength = filteredMinMaxValue[1] - filteredMinMaxValue[0]
|
173
|
-
|
174
172
|
// const _valueScale = d3.scaleLinear()
|
175
173
|
// .domain([0, 150])
|
176
174
|
// .range([416.5, 791.349])
|
@@ -178,16 +176,16 @@ function renderAxis ({ selection, yAxisClassName, fullParams, tickTextAlign, gri
|
|
178
176
|
// 刻度文字偏移
|
179
177
|
let tickPadding = 0
|
180
178
|
let textY = 0
|
181
|
-
if (fullDataFormatter.
|
179
|
+
if (fullDataFormatter.valueAxis.position === 'left') {
|
182
180
|
tickPadding = fullParams.tickPadding
|
183
181
|
textY = 0
|
184
|
-
} else if (fullDataFormatter.
|
182
|
+
} else if (fullDataFormatter.valueAxis.position === 'right') {
|
185
183
|
tickPadding = - fullParams.tickPadding
|
186
184
|
textY = 0
|
187
|
-
} else if (fullDataFormatter.
|
185
|
+
} else if (fullDataFormatter.valueAxis.position === 'bottom') {
|
188
186
|
tickPadding = 0
|
189
187
|
textY = fullParams.tickPadding
|
190
|
-
} else if (fullDataFormatter.
|
188
|
+
} else if (fullDataFormatter.valueAxis.position === 'top') {
|
191
189
|
tickPadding = 0
|
192
190
|
textY = - fullParams.tickPadding
|
193
191
|
}
|
@@ -195,11 +193,7 @@ function renderAxis ({ selection, yAxisClassName, fullParams, tickTextAlign, gri
|
|
195
193
|
// 設定Y軸刻度
|
196
194
|
const yAxis = d3.axisLeft(valueScale)
|
197
195
|
.scale(valueScale)
|
198
|
-
.ticks(
|
199
|
-
? fullParams.ticks
|
200
|
-
: ((filteredMinMaxValue[0] === 0 && filteredMinMaxValue[1] === 0)
|
201
|
-
? 1
|
202
|
-
: Math.ceil(valueLength))) // 刻度分段數量
|
196
|
+
.ticks(fullParams.ticks) // 刻度分段數量
|
203
197
|
.tickFormat(d => parseTickFormatValue(d, fullParams.tickFormat))
|
204
198
|
.tickSize(fullParams.tickFullLine == true
|
205
199
|
? -gridAxesSize.width
|
@@ -236,7 +230,7 @@ function renderAxis ({ selection, yAxisClassName, fullParams, tickTextAlign, gri
|
|
236
230
|
yText.style('transform', textReverseTransformWithRotate)
|
237
231
|
|
238
232
|
// 抵消掉預設的偏移
|
239
|
-
if (fullDataFormatter.
|
233
|
+
if (fullDataFormatter.valueAxis.position === 'bottom' || fullDataFormatter.valueAxis.position === 'top') {
|
240
234
|
yText.attr('dy', 0)
|
241
235
|
}
|
242
236
|
|
@@ -413,7 +407,7 @@ export const createBaseValueAxis: BasePluginFn<BaseLinesContext> = (pluginName:
|
|
413
407
|
})
|
414
408
|
)
|
415
409
|
|
416
|
-
// const
|
410
|
+
// const minMax$: Observable<[number, number]> = new Observable(subscriber => {
|
417
411
|
// combineLatest({
|
418
412
|
// fullDataFormatter: fullDataFormatter$,
|
419
413
|
// computedData: computedData$
|
@@ -423,13 +417,13 @@ export const createBaseValueAxis: BasePluginFn<BaseLinesContext> = (pluginName:
|
|
423
417
|
// ).subscribe(data => {
|
424
418
|
// const groupMin = 0
|
425
419
|
// const groupMax = data.computedData[0] ? data.computedData[0].length - 1 : 0
|
426
|
-
// // const groupScaleDomainMin = data.fullDataFormatter.
|
427
|
-
// // ? groupMin - data.fullDataFormatter.
|
428
|
-
// // : data.fullDataFormatter.
|
429
|
-
// const groupScaleDomainMin = data.fullDataFormatter.
|
430
|
-
// const groupScaleDomainMax = data.fullDataFormatter.
|
431
|
-
// ? groupMax + data.fullDataFormatter.
|
432
|
-
// : data.fullDataFormatter.
|
420
|
+
// // const groupScaleDomainMin = data.fullDataFormatter.groupAxis.scaleDomain[0] === 'auto'
|
421
|
+
// // ? groupMin - data.fullDataFormatter.groupAxis.scalePadding
|
422
|
+
// // : data.fullDataFormatter.groupAxis.scaleDomain[0] as number - data.fullDataFormatter.groupAxis.scalePadding
|
423
|
+
// const groupScaleDomainMin = data.fullDataFormatter.groupAxis.scaleDomain[0] - data.fullDataFormatter.groupAxis.scalePadding
|
424
|
+
// const groupScaleDomainMax = data.fullDataFormatter.groupAxis.scaleDomain[1] === 'max'
|
425
|
+
// ? groupMax + data.fullDataFormatter.groupAxis.scalePadding
|
426
|
+
// : data.fullDataFormatter.groupAxis.scaleDomain[1] as number + data.fullDataFormatter.groupAxis.scalePadding
|
433
427
|
|
434
428
|
// const filteredData = data.computedData.map((d, i) => {
|
435
429
|
// return d.filter((_d, _i) => {
|
@@ -437,11 +431,11 @@ export const createBaseValueAxis: BasePluginFn<BaseLinesContext> = (pluginName:
|
|
437
431
|
// })
|
438
432
|
// })
|
439
433
|
|
440
|
-
// const
|
441
|
-
// if (
|
442
|
-
//
|
434
|
+
// const filteredMinMax = getMinMaxValue(filteredData.flat())
|
435
|
+
// if (filteredMinMax[0] === filteredMinMax[1]) {
|
436
|
+
// filteredMinMax[0] = filteredMinMax[1] - 1 // 避免最大及最小值相同造成無法計算scale
|
443
437
|
// }
|
444
|
-
// subscriber.next(
|
438
|
+
// subscriber.next(filteredMinMax)
|
445
439
|
// })
|
446
440
|
// })
|
447
441
|
|
@@ -449,19 +443,25 @@ export const createBaseValueAxis: BasePluginFn<BaseLinesContext> = (pluginName:
|
|
449
443
|
combineLatest({
|
450
444
|
fullDataFormatter: fullDataFormatter$,
|
451
445
|
gridAxesSize: gridAxesSize$,
|
452
|
-
//
|
446
|
+
// minMax: minMax$
|
453
447
|
filteredMinMaxValue: filteredMinMaxValue$
|
454
448
|
}).pipe(
|
455
449
|
takeUntil(destroy$),
|
456
450
|
switchMap(async (d) => d),
|
457
451
|
).subscribe(data => {
|
452
|
+
let maxValue = data.filteredMinMaxValue[1]
|
453
|
+
let minValue = data.filteredMinMaxValue[0]
|
454
|
+
if (maxValue === minValue && maxValue === 0) {
|
455
|
+
// 避免最大及最小值同等於 0 造成無法計算scale
|
456
|
+
maxValue = 1
|
457
|
+
}
|
458
458
|
|
459
459
|
const valueScale: d3.ScaleLinear<number, number> = createValueToAxisScale({
|
460
|
-
maxValue
|
461
|
-
minValue
|
460
|
+
maxValue,
|
461
|
+
minValue,
|
462
462
|
axisWidth: data.gridAxesSize.height,
|
463
|
-
scaleDomain: data.fullDataFormatter.
|
464
|
-
scaleRange: data.fullDataFormatter.
|
463
|
+
scaleDomain: data.fullDataFormatter.valueAxis.scaleDomain,
|
464
|
+
scaleRange: data.fullDataFormatter.valueAxis.scaleRange
|
465
465
|
})
|
466
466
|
|
467
467
|
subscriber.next(valueScale)
|
@@ -478,18 +478,18 @@ export const createBaseValueAxis: BasePluginFn<BaseLinesContext> = (pluginName:
|
|
478
478
|
let textAnchor: 'start' | 'middle' | 'end' = 'start'
|
479
479
|
let dominantBaseline: 'auto' | 'middle' | 'hanging' = 'hanging'
|
480
480
|
|
481
|
-
if (data.fullDataFormatter.
|
481
|
+
if (data.fullDataFormatter.valueAxis.position === 'left') {
|
482
482
|
textAnchor = 'end'
|
483
483
|
dominantBaseline = 'middle'
|
484
|
-
} else if (data.fullDataFormatter.
|
484
|
+
} else if (data.fullDataFormatter.valueAxis.position === 'right') {
|
485
485
|
textAnchor = 'start'
|
486
486
|
dominantBaseline = 'middle'
|
487
|
-
} else if (data.fullDataFormatter.
|
487
|
+
} else if (data.fullDataFormatter.valueAxis.position === 'bottom') {
|
488
488
|
textAnchor = data.fullParams.tickTextRotate
|
489
489
|
? 'end'
|
490
490
|
: 'middle'
|
491
491
|
dominantBaseline = 'hanging'
|
492
|
-
} else if (data.fullDataFormatter.
|
492
|
+
} else if (data.fullDataFormatter.valueAxis.position === 'top') {
|
493
493
|
textAnchor = data.fullParams.tickTextRotate
|
494
494
|
? 'start'
|
495
495
|
: 'middle'
|
@@ -508,22 +508,22 @@ export const createBaseValueAxis: BasePluginFn<BaseLinesContext> = (pluginName:
|
|
508
508
|
let textAnchor: 'start' | 'middle' | 'end' = 'start'
|
509
509
|
let dominantBaseline: 'auto' | 'middle' | 'hanging' = 'hanging'
|
510
510
|
|
511
|
-
if (d.
|
511
|
+
if (d.groupAxis.position === 'bottom') {
|
512
512
|
dominantBaseline = 'auto'
|
513
|
-
} else if (d.
|
513
|
+
} else if (d.groupAxis.position === 'top') {
|
514
514
|
dominantBaseline = 'hanging'
|
515
|
-
} else if (d.
|
515
|
+
} else if (d.groupAxis.position === 'left') {
|
516
516
|
textAnchor = 'start'
|
517
|
-
} else if (d.
|
517
|
+
} else if (d.groupAxis.position === 'right') {
|
518
518
|
textAnchor = 'end'
|
519
519
|
}
|
520
|
-
if (d.
|
520
|
+
if (d.valueAxis.position === 'left') {
|
521
521
|
textAnchor = 'end'
|
522
|
-
} else if (d.
|
522
|
+
} else if (d.valueAxis.position === 'right') {
|
523
523
|
textAnchor = 'start'
|
524
|
-
} else if (d.
|
524
|
+
} else if (d.valueAxis.position === 'bottom') {
|
525
525
|
dominantBaseline = 'hanging'
|
526
|
-
} else if (d.
|
526
|
+
} else if (d.valueAxis.position === 'top') {
|
527
527
|
dominantBaseline = 'auto'
|
528
528
|
}
|
529
529
|
return {
|
package/src/grid/defaults.ts
CHANGED
@@ -4,11 +4,11 @@ import type {
|
|
4
4
|
GroupAuxParams,
|
5
5
|
DotsParams,
|
6
6
|
BarsParams,
|
7
|
-
|
7
|
+
StackedBarParams,
|
8
8
|
BarsTriangleParams,
|
9
9
|
GroupAxisParams,
|
10
10
|
ValueAxisParams,
|
11
|
-
|
11
|
+
StackedValueAxisParams,
|
12
12
|
GridTooltipParams,
|
13
13
|
GridZoomParams,
|
14
14
|
GridLegendParams
|
@@ -28,7 +28,7 @@ export const DEFAULT_LINE_AREAS_PARAMS: LineAreasParams = {
|
|
28
28
|
export const DEFAULT_DOTS_PARAMS: DotsParams = {
|
29
29
|
radius: 4,
|
30
30
|
fillColorType: 'white',
|
31
|
-
strokeColorType: '
|
31
|
+
strokeColorType: 'label',
|
32
32
|
strokeWidth: 2,
|
33
33
|
// strokeWidthWhileHighlight: 3,
|
34
34
|
onlyShowHighlighted: false
|
@@ -59,7 +59,7 @@ export const DEFAULT_BARS_DIVERGING_PARAMS: BarsParams = {
|
|
59
59
|
...DEFAULT_BARS_PARAMS
|
60
60
|
}
|
61
61
|
|
62
|
-
export const
|
62
|
+
export const DEFAULT_STACKED_BAR_PARAMS: StackedBarParams = {
|
63
63
|
barWidth: 0,
|
64
64
|
barGroupPadding: 10,
|
65
65
|
barRadius: false,
|
@@ -97,7 +97,8 @@ export const DEFAULT_VALUE_AXIS_PARAMS: ValueAxisParams = {
|
|
97
97
|
axisLineVisible: false,
|
98
98
|
axisLineColorType: 'primary',
|
99
99
|
ticks: null,
|
100
|
-
tickFormat: ',.0f',
|
100
|
+
// tickFormat: ',.0f',
|
101
|
+
tickFormat: v => v,
|
101
102
|
tickLineVisible: true,
|
102
103
|
tickPadding: 20,
|
103
104
|
tickFullLine: true,
|
@@ -106,8 +107,9 @@ export const DEFAULT_VALUE_AXIS_PARAMS: ValueAxisParams = {
|
|
106
107
|
tickTextRotate: 0,
|
107
108
|
tickTextColorType: 'primary'
|
108
109
|
}
|
110
|
+
DEFAULT_VALUE_AXIS_PARAMS.tickFormat.toString = () => 'v => v'
|
109
111
|
|
110
|
-
export const
|
112
|
+
export const DEFAULT_STACKED_VALUE_AXIS_PARAMS: StackedValueAxisParams = {
|
111
113
|
...DEFAULT_VALUE_AXIS_PARAMS
|
112
114
|
}
|
113
115
|
|
@@ -180,18 +180,18 @@ export const gridGroupPositionFnObservable = ({ fullDataFormatter$, gridAxesSize
|
|
180
180
|
// ).subscribe(data => {
|
181
181
|
// const groupMin = 0
|
182
182
|
// const groupMax = data.computedData[0] ? data.computedData[0].length - 1 : 0
|
183
|
-
// const groupScaleDomainMin = data.dataFormatter.
|
184
|
-
// ? groupMin - data.dataFormatter.
|
185
|
-
// : data.dataFormatter.
|
186
|
-
// const groupScaleDomainMax = data.dataFormatter.
|
187
|
-
// ? groupMax + data.dataFormatter.
|
188
|
-
// : data.dataFormatter.
|
183
|
+
// const groupScaleDomainMin = data.dataFormatter.groupAxis.scaleDomain[0] === 'auto'
|
184
|
+
// ? groupMin - data.dataFormatter.groupAxis.scalePadding
|
185
|
+
// : data.dataFormatter.groupAxis.scaleDomain[0] as number - data.dataFormatter.groupAxis.scalePadding
|
186
|
+
// const groupScaleDomainMax = data.dataFormatter.groupAxis.scaleDomain[1] === 'auto'
|
187
|
+
// ? groupMax + data.dataFormatter.groupAxis.scalePadding
|
188
|
+
// : data.dataFormatter.groupAxis.scaleDomain[1] as number + data.dataFormatter.groupAxis.scalePadding
|
189
189
|
|
190
190
|
// // const groupingAmount = data.computedData[0]
|
191
191
|
// // ? data.computedData[0].length
|
192
192
|
// // : 0
|
193
193
|
|
194
|
-
// let _labels = data.dataFormatter.
|
194
|
+
// let _labels = data.dataFormatter.seriesDirection === 'row'
|
195
195
|
// ? (data.computedData[0] ?? []).map(d => d.groupLabel)
|
196
196
|
// : data.computedData.map(d => d[0].groupLabel)
|
197
197
|
|
@@ -218,13 +218,13 @@ export const gridGroupPositionFnObservable = ({ fullDataFormatter$, gridAxesSize
|
|
218
218
|
map(data => {
|
219
219
|
const groupMin = 0
|
220
220
|
const groupMax = data.computedData[0] ? data.computedData[0].length - 1 : 0
|
221
|
-
// const groupScaleDomainMin = data.fullDataFormatter.
|
222
|
-
// ? groupMin - data.fullDataFormatter.
|
223
|
-
// : data.fullDataFormatter.
|
224
|
-
const groupScaleDomainMin = data.fullDataFormatter.
|
225
|
-
const groupScaleDomainMax = data.fullDataFormatter.
|
226
|
-
? groupMax + data.fullDataFormatter.
|
227
|
-
: data.fullDataFormatter.
|
221
|
+
// const groupScaleDomainMin = data.fullDataFormatter.groupAxis.scaleDomain[0] === 'auto'
|
222
|
+
// ? groupMin - data.fullDataFormatter.groupAxis.scalePadding
|
223
|
+
// : data.fullDataFormatter.groupAxis.scaleDomain[0] as number - data.fullDataFormatter.groupAxis.scalePadding
|
224
|
+
const groupScaleDomainMin = data.fullDataFormatter.groupAxis.scaleDomain[0] - data.fullDataFormatter.groupAxis.scalePadding
|
225
|
+
const groupScaleDomainMax = data.fullDataFormatter.groupAxis.scaleDomain[1] === 'max'
|
226
|
+
? groupMax + data.fullDataFormatter.groupAxis.scalePadding
|
227
|
+
: data.fullDataFormatter.groupAxis.scaleDomain[1] as number + data.fullDataFormatter.groupAxis.scalePadding
|
228
228
|
|
229
229
|
return [groupScaleDomainMin, groupScaleDomainMax]
|
230
230
|
}),
|
@@ -237,7 +237,7 @@ export const gridGroupPositionFnObservable = ({ fullDataFormatter$, gridAxesSize
|
|
237
237
|
}).pipe(
|
238
238
|
switchMap(async d => d),
|
239
239
|
map(data => {
|
240
|
-
return data.fullDataFormatter.
|
240
|
+
return data.fullDataFormatter.seriesDirection === 'row'
|
241
241
|
? (data.computedData[0] ?? []).map(d => d.groupLabel)
|
242
242
|
: data.computedData.map(d => d[0].groupLabel)
|
243
243
|
})
|
@@ -293,22 +293,22 @@ export const gridGroupPositionFnObservable = ({ fullDataFormatter$, gridAxesSize
|
|
293
293
|
switchMap(async (d) => d),
|
294
294
|
).subscribe(data => {
|
295
295
|
|
296
|
-
const reverse = data.dataFormatter.
|
297
|
-
|| data.dataFormatter.
|
296
|
+
const reverse = data.dataFormatter.valueAxis.position === 'right'
|
297
|
+
|| data.dataFormatter.valueAxis.position === 'bottom'
|
298
298
|
? true : false
|
299
299
|
|
300
300
|
// 比例尺座標對應非連續資料索引
|
301
301
|
const xIndexScale = createAxisToLabelIndexScale({
|
302
302
|
axisLabels: data.scaleRangeGroupLabels,
|
303
303
|
axisWidth: data.axisSize.width,
|
304
|
-
padding: data.dataFormatter.
|
304
|
+
padding: data.dataFormatter.groupAxis.scalePadding,
|
305
305
|
reverse
|
306
306
|
})
|
307
307
|
|
308
308
|
// 依比例尺位置計算座標
|
309
309
|
const axisValuePredicate = (event: any) => {
|
310
|
-
return data.dataFormatter.
|
311
|
-
|| data.dataFormatter.
|
310
|
+
return data.dataFormatter.groupAxis.position === 'bottom'
|
311
|
+
|| data.dataFormatter.groupAxis.position === 'top'
|
312
312
|
? event.offsetX - data.fullChartParams.padding.left
|
313
313
|
: event.offsetY - data.fullChartParams.padding.top
|
314
314
|
}
|
@@ -364,13 +364,13 @@ export const gridGroupPositionObservable = ({ rootSelection, fullDataFormatter$,
|
|
364
364
|
map(data => {
|
365
365
|
const groupMin = 0
|
366
366
|
const groupMax = data.computedData[0] ? data.computedData[0].length - 1 : 0
|
367
|
-
// const groupScaleDomainMin = data.fullDataFormatter.
|
368
|
-
// ? groupMin - data.fullDataFormatter.
|
369
|
-
// : data.fullDataFormatter.
|
370
|
-
const groupScaleDomainMin = data.fullDataFormatter.
|
371
|
-
const groupScaleDomainMax = data.fullDataFormatter.
|
372
|
-
? groupMax + data.fullDataFormatter.
|
373
|
-
: data.fullDataFormatter.
|
367
|
+
// const groupScaleDomainMin = data.fullDataFormatter.groupAxis.scaleDomain[0] === 'auto'
|
368
|
+
// ? groupMin - data.fullDataFormatter.groupAxis.scalePadding
|
369
|
+
// : data.fullDataFormatter.groupAxis.scaleDomain[0] as number - data.fullDataFormatter.groupAxis.scalePadding
|
370
|
+
const groupScaleDomainMin = data.fullDataFormatter.groupAxis.scaleDomain[0] - data.fullDataFormatter.groupAxis.scalePadding
|
371
|
+
const groupScaleDomainMax = data.fullDataFormatter.groupAxis.scaleDomain[1] === 'max'
|
372
|
+
? groupMax + data.fullDataFormatter.groupAxis.scalePadding
|
373
|
+
: data.fullDataFormatter.groupAxis.scaleDomain[1] as number + data.fullDataFormatter.groupAxis.scalePadding
|
374
374
|
|
375
375
|
return [groupScaleDomainMin, groupScaleDomainMax]
|
376
376
|
}),
|
@@ -383,7 +383,7 @@ export const gridGroupPositionObservable = ({ rootSelection, fullDataFormatter$,
|
|
383
383
|
}).pipe(
|
384
384
|
switchMap(async d => d),
|
385
385
|
map(data => {
|
386
|
-
return data.fullDataFormatter.
|
386
|
+
return data.fullDataFormatter.seriesDirection === 'row'
|
387
387
|
? (data.computedData[0] ?? []).map(d => d.groupLabel)
|
388
388
|
: data.computedData.map(d => d[0].groupLabel)
|
389
389
|
})
|
@@ -404,7 +404,7 @@ export const gridGroupPositionObservable = ({ rootSelection, fullDataFormatter$,
|
|
404
404
|
|
405
405
|
const reverse$ = fullDataFormatter$.pipe(
|
406
406
|
map(d => {
|
407
|
-
return d.
|
407
|
+
return d.valueAxis.position === 'right' || d.valueAxis.position === 'bottom'
|
408
408
|
? true
|
409
409
|
: false
|
410
410
|
})
|
@@ -422,7 +422,7 @@ export const gridGroupPositionObservable = ({ rootSelection, fullDataFormatter$,
|
|
422
422
|
return createAxisToLabelIndexScale({
|
423
423
|
axisLabels: data.scaleRangeGroupLabels,
|
424
424
|
axisWidth: data.gridAxesSize.width,
|
425
|
-
padding: data.fullDataFormatter.
|
425
|
+
padding: data.fullDataFormatter.groupAxis.scalePadding,
|
426
426
|
reverse: data.reverse
|
427
427
|
})
|
428
428
|
})
|
@@ -463,8 +463,8 @@ export const gridGroupPositionObservable = ({ rootSelection, fullDataFormatter$,
|
|
463
463
|
offsetX: data.rootMousemove.offsetX * data.columnAmount % data.layout.rootWidth,
|
464
464
|
offsetY: data.rootMousemove.offsetY * data.rowAmount % data.layout.rootHeight
|
465
465
|
}
|
466
|
-
return data.fullDataFormatter.
|
467
|
-
|| data.fullDataFormatter.
|
466
|
+
return data.fullDataFormatter.groupAxis.position === 'bottom'
|
467
|
+
|| data.fullDataFormatter.groupAxis.position === 'top'
|
468
468
|
? eventData.offsetX - data.fullChartParams.padding.left
|
469
469
|
: eventData.offsetY - data.fullChartParams.padding.top
|
470
470
|
})
|
package/src/grid/index.ts
CHANGED
@@ -4,13 +4,13 @@ export { Lines } from './plugins/Lines'
|
|
4
4
|
export { LineAreas } from './plugins/LineAreas'
|
5
5
|
export { Bars } from './plugins/Bars'
|
6
6
|
export { BarsPN } from './plugins/BarsPN'
|
7
|
-
export {
|
7
|
+
export { StackedBar } from './plugins/StackedBar'
|
8
8
|
export { BarsTriangle } from './plugins/BarsTriangle'
|
9
9
|
export { Dots } from './plugins/Dots'
|
10
10
|
export { GridLegend } from './plugins/GridLegend'
|
11
11
|
export { GroupAxis } from './plugins/GroupAxis'
|
12
12
|
export { ValueAxis } from './plugins/ValueAxis'
|
13
|
-
export {
|
13
|
+
export { StackedValueAxis } from './plugins/StackedValueAxis'
|
14
14
|
export { GridTooltip } from './plugins/GridTooltip'
|
15
15
|
export { GridZoom } from './plugins/GridZoom'
|
16
16
|
export { GroupAux } from './plugins/GroupAux'
|
@@ -76,7 +76,7 @@ export const GridZoom = defineGridPlugin(pluginConfig)(({ selection, rootSelecti
|
|
76
76
|
// })
|
77
77
|
|
78
78
|
const initGroupAxis$ = observer.fullDataFormatter$.pipe(
|
79
|
-
map(d => d.
|
79
|
+
map(d => d.groupAxis),
|
80
80
|
// 只用第一次資料來計算scale才不會造成每次變動都受到影響
|
81
81
|
first()
|
82
82
|
)
|
@@ -156,7 +156,7 @@ export const GridZoom = defineGridPlugin(pluginConfig)(({ selection, rootSelecti
|
|
156
156
|
return Math.min(data.groupMaxIndex, Math.max(groupMinIndex, n));
|
157
157
|
}
|
158
158
|
|
159
|
-
const zoomedDomain = data.fullDataFormatter.
|
159
|
+
const zoomedDomain = data.fullDataFormatter.groupAxis.position === 'bottom' || data.fullDataFormatter.groupAxis.position === 'top'
|
160
160
|
? t.rescaleX(shadowScale)
|
161
161
|
.domain()
|
162
162
|
.map(mapGroupindex)
|
@@ -193,13 +193,13 @@ export const GridZoom = defineGridPlugin(pluginConfig)(({ selection, rootSelecti
|
|
193
193
|
|
194
194
|
const newDataFormatter: DataFormatterGrid = {
|
195
195
|
...data.fullDataFormatter,
|
196
|
-
grid: {
|
197
|
-
...data.fullDataFormatter.grid,
|
196
|
+
// grid: {
|
197
|
+
// ...data.fullDataFormatter.grid,
|
198
198
|
groupAxis: {
|
199
|
-
...data.fullDataFormatter.
|
199
|
+
...data.fullDataFormatter.groupAxis,
|
200
200
|
scaleDomain: zoomedDomain
|
201
201
|
}
|
202
|
-
}
|
202
|
+
// }
|
203
203
|
}
|
204
204
|
subject.dataFormatter$.next(newDataFormatter)
|
205
205
|
})
|
@@ -225,18 +225,18 @@ function renderLabel ({ selection, labelData, fullParams, fullDataFormatter, ful
|
|
225
225
|
// -- label偏移位置 --
|
226
226
|
let rectX = - rectWidth / 2
|
227
227
|
let rectY = -2
|
228
|
-
if (fullDataFormatter.
|
228
|
+
if (fullDataFormatter.groupAxis.position === 'bottom') {
|
229
229
|
rectX = fullParams.labelRotate
|
230
230
|
? - rectWidth + rectHeight // 有傾斜時以末端對齊(+height是為了修正移動太多)
|
231
231
|
: - rectWidth / 2
|
232
232
|
rectY = 2
|
233
|
-
} else if (fullDataFormatter.
|
233
|
+
} else if (fullDataFormatter.groupAxis.position === 'left') {
|
234
234
|
rectX = - rectWidth + 2
|
235
235
|
rectY = - rectHeight / 2
|
236
|
-
} else if (fullDataFormatter.
|
236
|
+
} else if (fullDataFormatter.groupAxis.position === 'right') {
|
237
237
|
rectX = - 2
|
238
238
|
rectY = - rectHeight / 2
|
239
|
-
} else if (fullDataFormatter.
|
239
|
+
} else if (fullDataFormatter.groupAxis.position === 'top') {
|
240
240
|
rectX = fullParams.labelRotate
|
241
241
|
? - rectWidth + rectHeight // 有傾斜時以末端對齊(+height是為了修正移動太多)
|
242
242
|
: - rectWidth / 2
|
@@ -301,7 +301,7 @@ function renderLabel ({ selection, labelData, fullParams, fullDataFormatter, ful
|
|
301
301
|
renderTspansOnAxis(d3.select(n[i]), {
|
302
302
|
textArr: datum.textArr,
|
303
303
|
textSizePx,
|
304
|
-
groupAxisPosition: fullDataFormatter.
|
304
|
+
groupAxisPosition: fullDataFormatter.groupAxis.position
|
305
305
|
})
|
306
306
|
})
|
307
307
|
|
@@ -327,7 +327,7 @@ function renderLabel ({ selection, labelData, fullParams, fullDataFormatter, ful
|
|
327
327
|
// renderTspansOnAxis(d3.select(n[i]), {
|
328
328
|
// textArr: datum.textArr,
|
329
329
|
// textSizePx,
|
330
|
-
// groupAxisPosition: fullDataFormatter.
|
330
|
+
// groupAxisPosition: fullDataFormatter.groupAxis.position
|
331
331
|
// })
|
332
332
|
// })
|
333
333
|
})
|
@@ -488,20 +488,20 @@ export const GroupAux = defineGridPlugin(pluginConfig)(({ selection, rootSelecti
|
|
488
488
|
// ).subscribe(data => {
|
489
489
|
// const groupMin = 0
|
490
490
|
// const groupMax = data.computedData[0] ? data.computedData[0].length - 1 : 0
|
491
|
-
// const groupScaleDomainMin = data.fullDataFormatter.
|
492
|
-
// ? groupMin - data.fullDataFormatter.
|
493
|
-
// : data.fullDataFormatter.
|
494
|
-
// const groupScaleDomainMax = data.fullDataFormatter.
|
495
|
-
// ? groupMax + data.fullDataFormatter.
|
496
|
-
// : data.fullDataFormatter.
|
491
|
+
// const groupScaleDomainMin = data.fullDataFormatter.groupAxis.scaleDomain[0] === 'auto'
|
492
|
+
// ? groupMin - data.fullDataFormatter.groupAxis.scalePadding
|
493
|
+
// : data.fullDataFormatter.groupAxis.scaleDomain[0] as number - data.fullDataFormatter.groupAxis.scalePadding
|
494
|
+
// const groupScaleDomainMax = data.fullDataFormatter.groupAxis.scaleDomain[1] === 'auto'
|
495
|
+
// ? groupMax + data.fullDataFormatter.groupAxis.scalePadding
|
496
|
+
// : data.fullDataFormatter.groupAxis.scaleDomain[1] as number + data.fullDataFormatter.groupAxis.scalePadding
|
497
497
|
|
498
498
|
// const groupingLength = data.computedData[0]
|
499
499
|
// ? data.computedData[0].length
|
500
500
|
// : 0
|
501
501
|
|
502
|
-
// let _labels = data.fullDataFormatter.
|
503
|
-
// // ? data.fullDataFormatter.
|
504
|
-
// // : data.fullDataFormatter.
|
502
|
+
// let _labels = data.fullDataFormatter.seriesDirection === 'row'
|
503
|
+
// // ? data.fullDataFormatter.columnLabels
|
504
|
+
// // : data.fullDataFormatter.rowLabels
|
505
505
|
// ? (data.computedData[0] ?? []).map(d => d.groupLabel)
|
506
506
|
// : data.computedData.map(d => d[0].groupLabel)
|
507
507
|
|
@@ -516,7 +516,7 @@ export const GroupAux = defineGridPlugin(pluginConfig)(({ selection, rootSelecti
|
|
516
516
|
// })
|
517
517
|
|
518
518
|
|
519
|
-
// const padding = data.fullDataFormatter.
|
519
|
+
// const padding = data.fullDataFormatter.groupAxis.scalePadding
|
520
520
|
|
521
521
|
// const groupScale = createLabelToAxisScale({
|
522
522
|
// axisLabels,
|
@@ -538,13 +538,13 @@ export const GroupAux = defineGridPlugin(pluginConfig)(({ selection, rootSelecti
|
|
538
538
|
// map(data => {
|
539
539
|
// const groupMin = 0
|
540
540
|
// const groupMax = data.computedData[0] ? data.computedData[0].length - 1 : 0
|
541
|
-
// // const groupScaleDomainMin = data.fullDataFormatter.
|
542
|
-
// // ? groupMin - data.fullDataFormatter.
|
543
|
-
// // : data.fullDataFormatter.
|
544
|
-
// const groupScaleDomainMin = data.fullDataFormatter.
|
545
|
-
// const groupScaleDomainMax = data.fullDataFormatter.
|
546
|
-
// ? groupMax + data.fullDataFormatter.
|
547
|
-
// : data.fullDataFormatter.
|
541
|
+
// // const groupScaleDomainMin = data.fullDataFormatter.groupAxis.scaleDomain[0] === 'auto'
|
542
|
+
// // ? groupMin - data.fullDataFormatter.groupAxis.scalePadding
|
543
|
+
// // : data.fullDataFormatter.groupAxis.scaleDomain[0] as number - data.fullDataFormatter.groupAxis.scalePadding
|
544
|
+
// const groupScaleDomainMin = data.fullDataFormatter.groupAxis.scaleDomain[0] - data.fullDataFormatter.groupAxis.scalePadding
|
545
|
+
// const groupScaleDomainMax = data.fullDataFormatter.groupAxis.scaleDomain[1] === 'max'
|
546
|
+
// ? groupMax + data.fullDataFormatter.groupAxis.scalePadding
|
547
|
+
// : data.fullDataFormatter.groupAxis.scaleDomain[1] as number + data.fullDataFormatter.groupAxis.scalePadding
|
548
548
|
|
549
549
|
// return [groupScaleDomainMin, groupScaleDomainMax]
|
550
550
|
// }),
|
@@ -7,15 +7,15 @@ import {
|
|
7
7
|
Observable } from 'rxjs'
|
8
8
|
import type { DefinePluginConfig } from '../../../lib/core-types'
|
9
9
|
import { defineGridPlugin } from '../../../lib/core'
|
10
|
-
import {
|
10
|
+
import { DEFAULT_STACKED_BAR_PARAMS } from '../defaults'
|
11
11
|
import { LAYER_INDEX_OF_GRAPHIC } from '../../const'
|
12
|
-
import {
|
12
|
+
import { createBaseStackedBar } from '../../base/BaseStackedBar'
|
13
13
|
|
14
|
-
const pluginName = '
|
14
|
+
const pluginName = 'StackedBar'
|
15
15
|
|
16
|
-
const pluginConfig: DefinePluginConfig<typeof pluginName, typeof
|
16
|
+
const pluginConfig: DefinePluginConfig<typeof pluginName, typeof DEFAULT_STACKED_BAR_PARAMS> = {
|
17
17
|
name: pluginName,
|
18
|
-
defaultParams:
|
18
|
+
defaultParams: DEFAULT_STACKED_BAR_PARAMS,
|
19
19
|
layerIndex: 5,
|
20
20
|
validator: (params, { validateColumns }) => {
|
21
21
|
const result = validateColumns(params, {
|
@@ -33,10 +33,10 @@ const pluginConfig: DefinePluginConfig<typeof pluginName, typeof DEFAULT_BAR_STA
|
|
33
33
|
}
|
34
34
|
}
|
35
35
|
|
36
|
-
export const
|
36
|
+
export const StackedBar = defineGridPlugin(pluginConfig)(({ selection, name, subject, observer }) => {
|
37
37
|
const destroy$ = new Subject()
|
38
38
|
|
39
|
-
const unsubscribeBaseBars =
|
39
|
+
const unsubscribeBaseBars = createBaseStackedBar(pluginName, {
|
40
40
|
selection,
|
41
41
|
computedData$: observer.computedData$,
|
42
42
|
computedLayoutData$: observer.computedLayoutData$,
|