@orbcharts/plugins-basic 3.0.0-beta.8 → 3.0.0
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 +13170 -10984
- package/dist/orbcharts-plugins-basic.umd.js +266 -98
- package/dist/{orbcharts-plugins-basic/src → src}/base/BaseBars.d.ts +3 -3
- package/dist/{orbcharts-plugins-basic/src → src}/base/BaseBarsTriangle.d.ts +3 -3
- package/dist/{orbcharts-plugins-basic/src → src}/base/BaseDots.d.ts +3 -3
- package/dist/{orbcharts-plugins-basic/src → src}/base/BaseLineAreas.d.ts +3 -3
- package/dist/{orbcharts-plugins-basic/src → src}/base/BaseLines.d.ts +3 -3
- package/dist/src/base/BaseRacingBars.d.ts +23 -0
- package/dist/src/base/BaseRacingLabels.d.ts +20 -0
- package/dist/src/base/BaseRacingValueLabels.d.ts +20 -0
- package/dist/{orbcharts-plugins-basic/src/base/BaseStackedBar.d.ts → src/base/BaseStackedBars.d.ts} +7 -7
- package/dist/{orbcharts-plugins-basic/src → src}/base/BaseValueAxis.d.ts +4 -7
- package/dist/src/base/BaseXAxis.d.ts +20 -0
- package/dist/src/base/BaseYAxis.d.ts +18 -0
- package/dist/{orbcharts-plugins-basic/src → src}/grid/defaults.d.ts +3 -3
- package/dist/{orbcharts-plugins-basic/src → src}/grid/gridObservables.d.ts +8 -1
- package/dist/{orbcharts-plugins-basic/src → src}/grid/index.d.ts +2 -2
- package/dist/src/grid/plugins/GroupZoom.d.ts +1 -0
- package/dist/src/grid/plugins/StackedBars.d.ts +1 -0
- package/dist/src/index.d.ts +7 -1
- package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/defaults.d.ts +2 -2
- package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/index.d.ts +1 -1
- package/dist/src/multiGrid/plugins/MultiStackedBars.d.ts +1 -0
- package/dist/src/multiValue/defaults.d.ts +13 -0
- package/dist/{orbcharts-plugins-basic/src → src}/multiValue/index.d.ts +5 -1
- package/dist/src/multiValue/multiValueObservables.d.ts +56 -0
- package/dist/src/multiValue/plugins/RacingBars.d.ts +1 -0
- package/dist/src/multiValue/plugins/RacingCounterTexts.d.ts +3 -0
- package/dist/src/multiValue/plugins/RacingValueAxis.d.ts +1 -0
- package/dist/src/multiValue/plugins/XAxis.d.ts +1 -0
- package/dist/src/multiValue/plugins/XYAxes.d.ts +1 -0
- package/dist/src/multiValue/plugins/XZoom.d.ts +1 -0
- package/dist/{orbcharts-plugins-basic/src → src}/relationship/defaults.d.ts +2 -1
- package/dist/{orbcharts-plugins-basic/src → src}/relationship/index.d.ts +1 -0
- package/dist/src/relationship/plugins/ForceDirectedBubbles.d.ts +3 -0
- package/dist/{orbcharts-plugins-basic/src → src}/utils/commonUtils.d.ts +1 -0
- package/dist/{orbcharts-plugins-basic/src → src}/utils/d3Graphics.d.ts +2 -1
- package/dist/{orbcharts-plugins-basic/src → src}/utils/d3Utils.d.ts +1 -0
- package/lib/core.ts +1 -1
- package/package.json +4 -4
- package/src/base/BaseBars.ts +15 -15
- package/src/base/BaseBarsTriangle.ts +15 -15
- package/src/base/BaseDots.ts +14 -14
- package/src/base/BaseGroupAxis.ts +18 -6
- package/src/base/BaseLineAreas.ts +12 -12
- package/src/base/BaseLines.ts +11 -11
- package/src/base/BaseRacingBars.ts +552 -0
- package/src/base/BaseRacingLabels.ts +396 -0
- package/src/base/BaseRacingValueLabels.ts +403 -0
- package/src/base/{BaseStackedBar.ts → BaseStackedBars.ts} +26 -26
- package/src/base/BaseTooltip.ts +2 -1
- package/src/base/BaseValueAxis.ts +70 -53
- package/src/base/BaseXAxis.ts +427 -0
- package/src/base/BaseYAxis.ts +389 -0
- package/src/grid/defaults.ts +44 -77
- package/src/grid/gridObservables.ts +58 -0
- package/src/grid/index.ts +2 -2
- package/src/grid/plugins/Bars.ts +2 -2
- package/src/grid/plugins/BarsPN.ts +2 -2
- package/src/grid/plugins/BarsTriangle.ts +2 -2
- package/src/grid/plugins/Dots.ts +2 -2
- package/src/grid/plugins/GridLegend.ts +7 -7
- package/src/grid/plugins/GroupAux.ts +41 -24
- package/src/grid/plugins/GroupAxis.ts +0 -24
- package/src/grid/plugins/{GridZoom.ts → GroupZoom.ts} +5 -5
- package/src/grid/plugins/LineAreas.ts +2 -2
- package/src/grid/plugins/Lines.ts +2 -2
- package/src/grid/plugins/{StackedBar.ts → StackedBars.ts} +9 -9
- package/src/multiGrid/defaults.ts +44 -24
- package/src/multiGrid/index.ts +1 -1
- package/src/multiGrid/multiGridObservables.ts +1 -0
- package/src/multiGrid/plugins/MultiBars.ts +3 -3
- package/src/multiGrid/plugins/MultiBarsTriangle.ts +3 -3
- package/src/multiGrid/plugins/MultiDots.ts +3 -3
- package/src/multiGrid/plugins/MultiGridLegend.ts +20 -10
- package/src/multiGrid/plugins/MultiLineAreas.ts +3 -3
- package/src/multiGrid/plugins/MultiLines.ts +3 -3
- package/src/multiGrid/plugins/{MultiStackedBar.ts → MultiStackedBars.ts} +10 -10
- package/src/multiGrid/plugins/OverlappingStackedValueAxes.ts +1 -0
- package/src/multiValue/defaults.ts +277 -12
- package/src/multiValue/index.ts +5 -1
- package/src/multiValue/multiValueObservables.ts +414 -44
- package/src/multiValue/plugins/OrdinalXAxis.ts +0 -0
- package/src/multiValue/plugins/RacingBars.ts +373 -0
- package/src/multiValue/plugins/RacingCounterAxis.ts +0 -0
- package/src/multiValue/plugins/RacingCounterTexts.ts +300 -0
- package/src/multiValue/plugins/RacingValueAxis.ts +115 -0
- package/src/multiValue/plugins/RankingAxis_legacy.ts +109 -0
- package/src/multiValue/plugins/Scatter.ts +13 -13
- package/src/multiValue/plugins/ScatterBubbles.ts +13 -13
- package/src/multiValue/plugins/XAxis.ts +108 -0
- package/src/multiValue/plugins/XYAux.ts +15 -14
- package/src/multiValue/plugins/XYAxes.ts +38 -528
- package/src/multiValue/plugins/XYAxes_legacy.ts +684 -0
- package/src/multiValue/plugins/{XYZoom.ts → XZoom.ts} +17 -17
- package/src/relationship/defaults.ts +129 -20
- package/src/relationship/index.ts +1 -0
- package/src/relationship/plugins/ForceDirected.ts +113 -87
- package/src/relationship/plugins/ForceDirectedBubbles.ts +1412 -0
- package/src/series/defaults.ts +52 -37
- package/src/series/plugins/Bubbles.ts +71 -39
- package/src/series/plugins/Pie.ts +5 -5
- package/src/series/plugins/PieEventTexts.ts +3 -3
- package/src/series/plugins/PieLabels.ts +5 -5
- package/src/series/plugins/Rose.ts +11 -11
- package/src/series/plugins/RoseLabels.ts +9 -9
- package/src/tree/defaults.ts +46 -22
- package/src/tree/plugins/TreeMap.ts +11 -3
- package/src/utils/commonUtils.ts +10 -1
- package/src/utils/d3Graphics.ts +4 -2
- package/src/utils/d3Utils.ts +18 -0
- package/src/utils/orbchartsUtils.ts +30 -16
- package/dist/orbcharts-plugins-basic/src/grid/plugins/GridZoom.d.ts +0 -1
- package/dist/orbcharts-plugins-basic/src/grid/plugins/StackedBar.d.ts +0 -1
- package/dist/orbcharts-plugins-basic/src/index.d.ts +0 -7
- package/dist/orbcharts-plugins-basic/src/multiGrid/plugins/MultiStackedBar.d.ts +0 -1
- package/dist/orbcharts-plugins-basic/src/multiValue/defaults.d.ts +0 -9
- package/dist/orbcharts-plugins-basic/src/multiValue/multiValueObservables.d.ts +0 -33
- package/dist/orbcharts-plugins-basic/src/multiValue/plugins/XYZoom.d.ts +0 -1
- /package/dist/{orbcharts-plugins-basic/lib → lib}/core-types.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/lib → lib}/core.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/lib → lib}/plugins-basic-types.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/base/BaseGroupAxis.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/base/BaseLegend.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/base/BaseTooltip.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/base/types.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/const.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/Bars.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/BarsPN.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/BarsTriangle.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/Dots.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/GridLegend.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/GridTooltip.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/GroupAux.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/GroupAxis.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/LineAreas.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/Lines.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/StackedValueAxis.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/grid/plugins/ValueAxis.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/multiGridObservables.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/MultiBars.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/MultiBarsTriangle.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/MultiDots.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/MultiGridLegend.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/MultiGridTooltip.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/MultiGroupAxis.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/MultiLineAreas.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/MultiLines.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/MultiStackedValueAxis.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/MultiValueAxis.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/OverlappingStackedValueAxes.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/OverlappingValueAxes.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiValue/plugins/MultiValueLegend.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiValue/plugins/MultiValueTooltip.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src/multiValue/plugins/Ranking.d.ts → src/multiValue/plugins/OrdinalBubbles.d.ts} +0 -0
- /package/dist/{orbcharts-plugins-basic/src/multiValue/plugins/RankingAxis.d.ts → src/multiValue/plugins/OrdinalXAxis.d.ts} +0 -0
- /package/dist/{orbcharts-plugins-basic/src/noneData/plugins/Container.d.ts → src/multiValue/plugins/RacingCounterAxis.d.ts} +0 -0
- /package/dist/{orbcharts-plugins-basic/src/noneData/plugins/Tooltip.d.ts → src/multiValue/plugins/RankingAxis_legacy.d.ts} +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiValue/plugins/Scatter.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiValue/plugins/ScatterBubbles.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/multiValue/plugins/XYAux.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src/multiValue/plugins/XYAxes.d.ts → src/multiValue/plugins/XYAxes_legacy.d.ts} +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/noneData/defaults.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/noneData/index.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src/relationship/plugins/ForceDirectedBubbles.d.ts → src/noneData/plugins/Container.d.ts} +0 -0
- /package/dist/{orbcharts-plugins-basic/src/series/plugins/Waffle.d.ts → src/noneData/plugins/Tooltip.d.ts} +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/relationship/plugins/ForceDirected.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/relationship/plugins/RelationshipLegend.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/relationship/plugins/RelationshipTooltip.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/relationship/relationshipObservables.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/series/defaults.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/series/index.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/series/plugins/Bubbles.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/series/plugins/Pie.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/series/plugins/PieEventTexts.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/series/plugins/PieLabels.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/series/plugins/Rose.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/series/plugins/RoseLabels.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/series/plugins/SeriesLegend.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/series/plugins/SeriesTooltip.d.ts +0 -0
- /package/{src/multiValue/plugins/Ranking.ts → dist/src/series/plugins/Waffle.d.ts} +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/series/seriesObservables.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/series/seriesUtils.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/tree/defaults.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/tree/index.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/tree/plugins/TreeLegend.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/tree/plugins/TreeMap.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/tree/plugins/TreeTooltip.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/utils/observables.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/src → src}/utils/orbchartsUtils.d.ts +0 -0
- /package/dist/{orbcharts-plugins-basic/vite.config.d.ts → vite.config.d.ts} +0 -0
- /package/src/multiValue/plugins/{RankingAxis.ts → OrdinalBubbles.ts} +0 -0
@@ -406,8 +406,8 @@ function highlight ({ textSelection, lineSelection, ids, fullChartParams }: {
|
|
406
406
|
function createEachPieLabel (pluginName: string, context: {
|
407
407
|
containerSelection: d3.Selection<SVGGElement, any, any, unknown>
|
408
408
|
// computedData$: Observable<ComputedDatumSeries[][]>
|
409
|
-
|
410
|
-
|
409
|
+
visibleComputedSortedData$: Observable<ComputedDatumSeries[][]>
|
410
|
+
containerVisibleComputedSortedData$: Observable<ComputedDatumSeries[]>
|
411
411
|
// SeriesDataMap$: Observable<Map<string, ComputedDatumSeries[]>>
|
412
412
|
fullParams$: Observable<RoseLabelsParams>
|
413
413
|
fullChartParams$: Observable<ChartParams>
|
@@ -435,7 +435,7 @@ function createEachPieLabel (pluginName: string, context: {
|
|
435
435
|
distinctUntilChanged()
|
436
436
|
)
|
437
437
|
|
438
|
-
const maxValue$ = context.
|
438
|
+
const maxValue$ = context.visibleComputedSortedData$.pipe(
|
439
439
|
map(data => Math.max(...data.flat().map(d => d.value))),
|
440
440
|
distinctUntilChanged()
|
441
441
|
)
|
@@ -453,7 +453,7 @@ function createEachPieLabel (pluginName: string, context: {
|
|
453
453
|
combineLatest({
|
454
454
|
// layout: context.seriesContainerPosition$,
|
455
455
|
shorterSideWith: shorterSideWith$,
|
456
|
-
|
456
|
+
containerVisibleComputedSortedData: context.containerVisibleComputedSortedData$,
|
457
457
|
maxValue: maxValue$,
|
458
458
|
fullParams: context.fullParams$,
|
459
459
|
fullChartParams: context.fullChartParams$,
|
@@ -464,9 +464,9 @@ function createEachPieLabel (pluginName: string, context: {
|
|
464
464
|
switchMap(async (d) => d),
|
465
465
|
).subscribe(data => {
|
466
466
|
|
467
|
-
const eachAngle = Math.PI * 2 / data.
|
467
|
+
const eachAngle = Math.PI * 2 / data.containerVisibleComputedSortedData.length
|
468
468
|
|
469
|
-
const pieData = data.
|
469
|
+
const pieData = data.containerVisibleComputedSortedData.map((d, i) => {
|
470
470
|
return {
|
471
471
|
id: d.id,
|
472
472
|
data: d,
|
@@ -567,7 +567,7 @@ export const RoseLabels = defineSeriesPlugin(pluginConfig)(({ selection, observe
|
|
567
567
|
|
568
568
|
const containerSelection = d3.select(g[containerIndex])
|
569
569
|
|
570
|
-
const
|
570
|
+
const containerVisibleComputedSortedData$ = observer.visibleComputedSortedData$.pipe(
|
571
571
|
takeUntil(destroy$),
|
572
572
|
map(data => JSON.parse(JSON.stringify(data[containerIndex] ?? data[0])))
|
573
573
|
)
|
@@ -580,8 +580,8 @@ export const RoseLabels = defineSeriesPlugin(pluginConfig)(({ selection, observe
|
|
580
580
|
unsubscribeFnArr[containerIndex] = createEachPieLabel(pluginName, {
|
581
581
|
containerSelection: containerSelection,
|
582
582
|
// computedData$: observer.computedData$,
|
583
|
-
|
584
|
-
|
583
|
+
visibleComputedSortedData$: observer.visibleComputedSortedData$,
|
584
|
+
containerVisibleComputedSortedData$: containerVisibleComputedSortedData$,
|
585
585
|
// SeriesDataMap$: observer.SeriesDataMap$,
|
586
586
|
fullParams$: observer.fullParams$,
|
587
587
|
fullChartParams$: observer.fullChartParams$,
|
package/src/tree/defaults.ts
CHANGED
@@ -3,7 +3,7 @@ import type { TreeMapParams, TreeLegendParams, TreeTooltipParams } from '../../l
|
|
3
3
|
export const DEFAULT_TREE_MAP_PARAMS: TreeMapParams = {
|
4
4
|
paddingInner: 2,
|
5
5
|
paddingOuter: 2,
|
6
|
-
labelColorType: '
|
6
|
+
labelColorType: 'labelContrast',
|
7
7
|
squarifyRatio: 1.618034, // 黃金比例
|
8
8
|
sort: (a, b) => b.value - a.value
|
9
9
|
}
|
@@ -33,6 +33,7 @@ export const DEFAULT_TREE_TOOLTIP_PARAMS: TreeTooltipParams = {
|
|
33
33
|
renderFn: (eventData, { styles, utils }) => {
|
34
34
|
const hasCategoryLabel = eventData.categoryLabel ? true : false
|
35
35
|
const hasDatumLabel = eventData.datum.label ? true : false
|
36
|
+
const valueText = utils.toCurrency(eventData.datum.value)
|
36
37
|
const bulletWidth = styles.textSizePx * 0.7
|
37
38
|
const offset = (styles.textSizePx / 2) - (bulletWidth / 2)
|
38
39
|
const categorySvg = hasCategoryLabel
|
@@ -44,8 +45,19 @@ export const DEFAULT_TREE_TOOLTIP_PARAMS: TreeTooltipParams = {
|
|
44
45
|
const datumLabelSvg = hasDatumLabel
|
45
46
|
? `<tspan>${eventData.datum.label}</tspan> `
|
46
47
|
: ''
|
48
|
+
const categoryLabelTextWidth = hasCategoryLabel
|
49
|
+
? utils.measureTextWidth(`${eventData.categoryLabel}${valueText}`, styles.textSizePx) + styles.textSizePx * 1.5
|
50
|
+
: 0
|
51
|
+
const datumLabelTextWidth = hasDatumLabel
|
52
|
+
? utils.measureTextWidth(`${eventData.datum.label}${valueText}`, styles.textSizePx)
|
53
|
+
: 0
|
54
|
+
const maxTextWidth = Math.max(categoryLabelTextWidth, datumLabelTextWidth)
|
55
|
+
const lineEndX = hasDatumLabel
|
56
|
+
? maxTextWidth + styles.textSizePx * 0.5
|
57
|
+
: 0
|
58
|
+
const valueTextAnchor = hasDatumLabel ? 'end' : 'start'
|
47
59
|
const datumSvg = `<text font-size="${styles.textSizePx}" dominant-baseline="hanging" fill="${styles.textColor}">
|
48
|
-
${datumLabelSvg}<tspan font-weight="bold">${
|
60
|
+
${datumLabelSvg}<tspan font-weight="bold" text-anchor="${valueTextAnchor}" x="${lineEndX}">${valueText}</tspan>
|
49
61
|
</text>`
|
50
62
|
|
51
63
|
return `${categorySvg}
|
@@ -55,25 +67,37 @@ export const DEFAULT_TREE_TOOLTIP_PARAMS: TreeTooltipParams = {
|
|
55
67
|
},
|
56
68
|
}
|
57
69
|
DEFAULT_TREE_TOOLTIP_PARAMS.renderFn.toString = () => `(eventData, { styles, utils }) => {
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
</
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
70
|
+
const hasCategoryLabel = eventData.categoryLabel ? true : false
|
71
|
+
const hasDatumLabel = eventData.datum.label ? true : false
|
72
|
+
const valueText = utils.toCurrency(eventData.datum.value)
|
73
|
+
const bulletWidth = styles.textSizePx * 0.7
|
74
|
+
const offset = (styles.textSizePx / 2) - (bulletWidth / 2)
|
75
|
+
const categorySvg = hasCategoryLabel
|
76
|
+
? \`<rect width="\${bulletWidth}" height="\${bulletWidth}" x="\${offset}" y="\${offset - 1}" rx="\${bulletWidth / 2}" fill="\${eventData.datum.color}"></rect>
|
77
|
+
<text x="\${styles.textSizePx * 1.5}" font-size="\${styles.textSizePx}" dominant-baseline="hanging" fill="\${styles.textColor}">
|
78
|
+
<tspan>\${eventData.categoryLabel}</tspan>
|
79
|
+
</text>\`
|
80
|
+
: ''
|
81
|
+
const datumLabelSvg = hasDatumLabel
|
82
|
+
? \`<tspan>\${eventData.datum.label}</tspan> \`
|
83
|
+
: ''
|
84
|
+
const categoryLabelTextWidth = hasCategoryLabel
|
85
|
+
? utils.measureTextWidth(\`\${eventData.categoryLabel}\${valueText}\`, styles.textSizePx) + styles.textSizePx * 1.5
|
86
|
+
: 0
|
87
|
+
const datumLabelTextWidth = hasDatumLabel
|
88
|
+
? utils.measureTextWidth(\`\${eventData.datum.label}\${valueText}\`, styles.textSizePx)
|
89
|
+
: 0
|
90
|
+
const maxTextWidth = Math.max(categoryLabelTextWidth, datumLabelTextWidth)
|
91
|
+
const lineEndX = hasDatumLabel
|
92
|
+
? maxTextWidth + styles.textSizePx * 0.5
|
93
|
+
: 0
|
94
|
+
const valueTextAnchor = hasDatumLabel ? 'end' : 'start'
|
95
|
+
const datumSvg = \`<text font-size="\${styles.textSizePx}" dominant-baseline="hanging" fill="\${styles.textColor}">
|
96
|
+
\${datumLabelSvg}<tspan font-weight="bold" text-anchor="\${valueTextAnchor}" x="\${lineEndX}">\${valueText}</tspan>
|
97
|
+
</text>\`
|
74
98
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
99
|
+
return \`\${categorySvg}
|
100
|
+
<g \${hasCategoryLabel ? \`transform="translate(0, \${styles.textSizePx * 2})"\` : ''}>
|
101
|
+
\${datumSvg}
|
102
|
+
</g>\`
|
79
103
|
}`
|
@@ -15,7 +15,7 @@ import {
|
|
15
15
|
import type { Layout, ComputedDataTree, DataFormatterTree, ChartParams } from '../../../lib/core-types'
|
16
16
|
import type { TreeMapParams } from '../../../lib/plugins-basic-types'
|
17
17
|
import { DEFAULT_TREE_MAP_PARAMS } from '../defaults'
|
18
|
-
import { getClassName,
|
18
|
+
import { getClassName, getDatumColor } from '../../utils/orbchartsUtils'
|
19
19
|
import { LAYER_INDEX_OF_GRAPHIC } from '../../const'
|
20
20
|
|
21
21
|
const pluginName = 'TreeMap'
|
@@ -112,7 +112,11 @@ function renderTree ({ selection, treeData, fullParams, fullChartParams, textSiz
|
|
112
112
|
.text(null)
|
113
113
|
.append("tspan")
|
114
114
|
.attr('cursor', 'pointer')
|
115
|
-
.attr('fill',
|
115
|
+
.attr('fill', getDatumColor({
|
116
|
+
colorType: fullParams.labelColorType,
|
117
|
+
datum: d.data,
|
118
|
+
fullChartParams
|
119
|
+
}))
|
116
120
|
.attr('font-size', fullChartParams.styles.textSize)
|
117
121
|
.attr("x", x)
|
118
122
|
.attr("y", y)
|
@@ -128,7 +132,11 @@ function renderTree ({ selection, treeData, fullParams, fullChartParams, textSiz
|
|
128
132
|
tspan = textElement
|
129
133
|
.append("tspan")
|
130
134
|
.attr('cursor', 'pointer')
|
131
|
-
.attr('fill',
|
135
|
+
.attr('fill', getDatumColor({
|
136
|
+
colorType: fullParams.labelColorType,
|
137
|
+
datum: d.data,
|
138
|
+
fullChartParams
|
139
|
+
}))
|
132
140
|
.attr('font-size', fullChartParams.styles.textSize)
|
133
141
|
.attr("x", x)
|
134
142
|
.attr("y", y)
|
package/src/utils/commonUtils.ts
CHANGED
@@ -19,4 +19,13 @@ export function getMinMax (data: number[]): [number, number] {
|
|
19
19
|
]
|
20
20
|
}, [data[0], data[0]])
|
21
21
|
return minMax
|
22
|
-
}
|
22
|
+
}
|
23
|
+
|
24
|
+
export function toCurrency (num: number | null): string {
|
25
|
+
if (num === null || Number.isNaN(num) == true) {
|
26
|
+
return String(num || 0)
|
27
|
+
}
|
28
|
+
const parts = num.toString().split('.')
|
29
|
+
parts[0] = parts[0].replace(/\B(?=(\d{3})+(?!\d))/g, ',')
|
30
|
+
return parts.join('.')
|
31
|
+
}
|
package/src/utils/d3Graphics.ts
CHANGED
@@ -128,18 +128,20 @@ export function renderCircleText (selection: d3.Selection<any, any, any, any>, {
|
|
128
128
|
export function renderTspansOnAxis (textSelection: d3.Selection<d3.BaseType, unknown, null, undefined>, {
|
129
129
|
textArr,
|
130
130
|
textSizePx,
|
131
|
-
groupAxisPosition
|
131
|
+
groupAxisPosition,
|
132
|
+
isContainerRotated // 外層是否有變形處理
|
132
133
|
}: {
|
133
134
|
textArr: string[]
|
134
135
|
textSizePx: number
|
135
136
|
groupAxisPosition: 'top' | 'right' | 'bottom' | 'left'
|
137
|
+
isContainerRotated: boolean
|
136
138
|
}) {
|
137
139
|
// -- 將原本單行文字改為多行文字 --
|
138
140
|
textSelection.text(null) // 先清空原本的 text
|
139
141
|
|
140
142
|
const textX = Number(textSelection.attr('x'))
|
141
143
|
let textY = Number(textSelection.attr('y'))
|
142
|
-
if (groupAxisPosition === 'top') {
|
144
|
+
if (isContainerRotated && groupAxisPosition === 'top') {
|
143
145
|
// 當文字在上方時,要往上偏移第一行的高度
|
144
146
|
textY -= (textArr.length - 1) * textSizePx
|
145
147
|
}
|
package/src/utils/d3Utils.ts
CHANGED
@@ -71,4 +71,22 @@ export const parseDateTickFormatValue = (value: any, tickFormat: string | ((text
|
|
71
71
|
return d3.timeFormat(tickFormat as string)!(value)
|
72
72
|
}
|
73
73
|
|
74
|
+
export function isLightColor (color: string) {
|
75
|
+
// 1. 用 HSL 的亮度(較符合數學)
|
76
|
+
// const hslColor = d3.hsl(color) // 轉換為 HSL 格式
|
77
|
+
// const lightness = hslColor.l // 取得亮度值 (0 ~ 1)
|
78
|
+
// 2. 用 LAB 的明度(較符合人眼感知)
|
79
|
+
const labColor = d3.lab(color) // 轉換為 LAB 格式
|
80
|
+
const lightness = labColor.l // 取得明度值 (0 ~ 100)
|
74
81
|
|
82
|
+
// console.log(`顏色的亮度為: ${lightness}`);
|
83
|
+
|
84
|
+
// 判斷顏色深淺
|
85
|
+
if (lightness <= 60) {
|
86
|
+
// console.log("這是一個深色系");
|
87
|
+
return false
|
88
|
+
} else {
|
89
|
+
// console.log("這是一個淺色系");
|
90
|
+
return true
|
91
|
+
}
|
92
|
+
}
|
@@ -7,6 +7,7 @@ import type {
|
|
7
7
|
ComputedDatumBaseSeries,
|
8
8
|
ComputedDatumBaseCategory } from '../../lib/core-types'
|
9
9
|
import { getMinMax } from './commonUtils'
|
10
|
+
import { isLightColor } from './d3Utils'
|
10
11
|
|
11
12
|
// 取得最小及最大值 - datum格式陣列資料
|
12
13
|
export function getMinMaxValue (data: (ComputedDatumBase & ComputedDatumBaseValue)[]): [number, number] {
|
@@ -19,14 +20,13 @@ export function getMinMaxValue (data: (ComputedDatumBase & ComputedDatumBaseValu
|
|
19
20
|
// 取得colorType顏色
|
20
21
|
export function getColor (colorType: ColorType, fullChartParams: ChartParams) {
|
21
22
|
const colors = fullChartParams.colors[fullChartParams.colorScheme]
|
22
|
-
// 對應series資料中第1個顏色
|
23
23
|
if (colorType === 'label') {
|
24
|
-
return colors.label[0]
|
24
|
+
return colors.label[0] // default label color
|
25
|
+
} else if (colorType === 'labelContrast') {
|
26
|
+
return isLightColor(colors.label[0]) // default label color
|
27
|
+
? colors.labelContrast[1]
|
28
|
+
: colors.labelContrast[0]
|
25
29
|
}
|
26
|
-
// 對應colorType設定的顏色
|
27
|
-
// return colors[colorType] != null
|
28
|
-
// ? colors[colorType]
|
29
|
-
// : colors.primary
|
30
30
|
return colorType == 'none'
|
31
31
|
? 'none'
|
32
32
|
: colors[colorType] != undefined
|
@@ -42,7 +42,7 @@ export function getCategoryValueColor ({ datum, colorType, fullChartParams }: {
|
|
42
42
|
|
43
43
|
}
|
44
44
|
|
45
|
-
// // 取得Series顏色
|
45
|
+
// // 取得Series顏色
|
46
46
|
// export function getSeriesColor (seriesIndex: number, fullChartParams: ChartParams) {
|
47
47
|
// const colorIndex = seriesIndex < fullChartParams.colors[fullChartParams.colorScheme].series.length
|
48
48
|
// ? seriesIndex
|
@@ -50,23 +50,37 @@ export function getCategoryValueColor ({ datum, colorType, fullChartParams }: {
|
|
50
50
|
// return fullChartParams.colors[fullChartParams.colorScheme].series[colorIndex]
|
51
51
|
// }
|
52
52
|
|
53
|
-
// 取得Datum顏色
|
53
|
+
// 取得Datum顏色
|
54
54
|
export function getDatumColor ({ datum, colorType, fullChartParams }: { datum: ComputedDatumBase, colorType: ColorType, fullChartParams: ChartParams }) {
|
55
|
-
|
55
|
+
const colors = fullChartParams.colors[fullChartParams.colorScheme]
|
56
|
+
|
56
57
|
if (colorType === 'label') {
|
57
|
-
|
58
|
-
|
58
|
+
const datumColor: string | undefined = (datum as unknown as ComputedDatumBaseSeries).color
|
59
|
+
if (datumColor) {
|
60
|
+
return datumColor
|
59
61
|
} else {
|
60
|
-
//
|
61
|
-
return
|
62
|
+
// default label color
|
63
|
+
return colors.label[0]
|
64
|
+
}
|
65
|
+
} else if (colorType === 'labelContrast') {
|
66
|
+
const datumColor: string | undefined = (datum as unknown as ComputedDatumBaseSeries).color
|
67
|
+
if (datumColor) {
|
68
|
+
return isLightColor(datumColor)
|
69
|
+
? colors.labelContrast[1]
|
70
|
+
: colors.labelContrast[0]
|
71
|
+
} else {
|
72
|
+
// default label color
|
73
|
+
return isLightColor(colors.label[0])
|
74
|
+
? colors.labelContrast[1]
|
75
|
+
: colors.labelContrast[0]
|
62
76
|
}
|
63
77
|
}
|
64
78
|
// 對應colorType設定的顏色
|
65
79
|
return colorType == 'none'
|
66
80
|
? 'none'
|
67
|
-
:
|
68
|
-
?
|
69
|
-
:
|
81
|
+
: colors[colorType] != undefined
|
82
|
+
? colors[colorType]
|
83
|
+
: colors.primary
|
70
84
|
}
|
71
85
|
|
72
86
|
export function getClassName (pluginName: string, elementName: string, modifier?: string) {
|
@@ -1 +0,0 @@
|
|
1
|
-
export declare const GridZoom: import('@orbcharts/core-types/dist/src/types/Plugin').PluginConstructor<"grid", "GridZoom", import('@orbcharts/plugins-basic-types').GridZoomParams>;
|
@@ -1 +0,0 @@
|
|
1
|
-
export declare const StackedBar: import('@orbcharts/core-types/dist/src/types/Plugin').PluginConstructor<"grid", "StackedBar", import('@orbcharts/plugins-basic-types').StackedBarParams>;
|
@@ -1 +0,0 @@
|
|
1
|
-
export declare const MultiStackedBar: import('@orbcharts/core-types/dist/src/types/Plugin').PluginConstructor<"multiGrid", "MultiStackedBar", import('@orbcharts/plugins-basic-types').MultiStackedBarParams>;
|
@@ -1,9 +0,0 @@
|
|
1
|
-
import { MultiValueLegendParams, MultiValueTooltipParams, ScatterParams, ScatterBubblesParams, XYAuxParams, XYAxesParams, XYZoomParams } from '../../lib/plugins-basic-types';
|
2
|
-
|
3
|
-
export declare const DEFAULT_MULTI_VALUE_LEGEND_PARAMS: MultiValueLegendParams;
|
4
|
-
export declare const DEFAULT_MULTI_VALUE_TOOLTIP_PARAMS: MultiValueTooltipParams;
|
5
|
-
export declare const DEFAULT_SCATTER_PARAMS: ScatterParams;
|
6
|
-
export declare const DEFAULT_SCATTER_BUBBLES_PARAMS: ScatterBubblesParams;
|
7
|
-
export declare const DEFAULT_X_Y_AUX_PARAMS: XYAuxParams;
|
8
|
-
export declare const DEFAULT_X_Y_AXES_PARAMS: XYAxesParams;
|
9
|
-
export declare const DEFAULT_X_Y_ZOOM_PARAMS: XYZoomParams;
|
@@ -1,33 +0,0 @@
|
|
1
|
-
import { Observable } from 'rxjs';
|
2
|
-
import { DataFormatterMultiValue, ComputedLayoutDatumMultiValue, TransformData, ContainerPositionScaled, Layout } from '../../lib/core-types';
|
3
|
-
import * as d3 from 'd3';
|
4
|
-
export declare const multiValueSelectionsObservable: ({ selection, pluginName, clipPathID, categoryLabels$, multiValueContainerPosition$, multiValueGraphicTransform$ }: {
|
5
|
-
selection: d3.Selection<any, unknown, any, unknown>;
|
6
|
-
pluginName: string;
|
7
|
-
clipPathID: string;
|
8
|
-
categoryLabels$: Observable<string[]>;
|
9
|
-
multiValueContainerPosition$: Observable<ContainerPositionScaled[]>;
|
10
|
-
multiValueGraphicTransform$: Observable<TransformData>;
|
11
|
-
}) => {
|
12
|
-
categorySelection$: Observable<d3.Selection<SVGGElement, string, any, unknown>>;
|
13
|
-
axesSelection$: Observable<d3.Selection<SVGGElement, string, any, unknown>>;
|
14
|
-
defsSelection$: Observable<d3.Selection<SVGDefsElement, string, any, unknown>>;
|
15
|
-
graphicGSelection$: Observable<d3.Selection<SVGGElement, string, any, unknown>>;
|
16
|
-
};
|
17
|
-
export declare const multiValueXYPositionObservable: ({ rootSelection, fullDataFormatter$, filteredMinMaxXYData$, multiValueContainerPosition$, layout$ }: {
|
18
|
-
rootSelection: d3.Selection<any, unknown, any, unknown>;
|
19
|
-
fullDataFormatter$: Observable<DataFormatterMultiValue>;
|
20
|
-
filteredMinMaxXYData$: Observable<{
|
21
|
-
minXDatum: ComputedLayoutDatumMultiValue;
|
22
|
-
maxXDatum: ComputedLayoutDatumMultiValue;
|
23
|
-
minYDatum: ComputedLayoutDatumMultiValue;
|
24
|
-
maxYDatum: ComputedLayoutDatumMultiValue;
|
25
|
-
}>;
|
26
|
-
multiValueContainerPosition$: Observable<ContainerPositionScaled[]>;
|
27
|
-
layout$: Observable<Layout>;
|
28
|
-
}) => Observable<{
|
29
|
-
x: number;
|
30
|
-
y: number;
|
31
|
-
xValue: number;
|
32
|
-
yValue: number;
|
33
|
-
}>;
|
@@ -1 +0,0 @@
|
|
1
|
-
export declare const XYZoom: import('@orbcharts/core-types/dist/src/types/Plugin').PluginConstructor<"multiValue", "XYZoom", import('@orbcharts/plugins-basic-types').XYZoomParams>;
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
/package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/MultiStackedValueAxis.d.ts
RENAMED
File without changes
|
File without changes
|
/package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/OverlappingStackedValueAxes.d.ts
RENAMED
File without changes
|
/package/dist/{orbcharts-plugins-basic/src → src}/multiGrid/plugins/OverlappingValueAxes.d.ts
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
/package/dist/{orbcharts-plugins-basic/src → src}/relationship/plugins/RelationshipLegend.d.ts
RENAMED
File without changes
|
/package/dist/{orbcharts-plugins-basic/src → src}/relationship/plugins/RelationshipTooltip.d.ts
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|