@orbcharts/plugins-basic 3.0.0-alpha.36 → 3.0.0-alpha.38
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/{src → orbcharts-plugins-basic/src}/grid/defaults.d.ts +1 -0
- package/dist/{src → orbcharts-plugins-basic/src}/grid/index.d.ts +1 -0
- package/dist/orbcharts-plugins-basic/src/grid/plugins/BarsDiverging.d.ts +1 -0
- package/dist/{src → orbcharts-plugins-basic/src}/grid/types.d.ts +2 -0
- package/dist/orbcharts-plugins-basic/src/index.d.ts +5 -0
- package/dist/orbcharts-plugins-basic/src/tree/defaults.d.ts +4 -0
- package/dist/orbcharts-plugins-basic/src/tree/index.d.ts +4 -0
- package/dist/orbcharts-plugins-basic/src/tree/plugins/TreeLegend.d.ts +1 -0
- package/dist/orbcharts-plugins-basic/src/tree/plugins/TreeMap.d.ts +3 -0
- package/dist/orbcharts-plugins-basic/src/tree/types.d.ts +21 -0
- package/dist/orbcharts-plugins-basic.es.js +5857 -5639
- package/dist/orbcharts-plugins-basic.umd.js +7 -7
- package/dist/src/index.d.ts +1 -4
- package/package.json +2 -2
- package/src/base/BaseValueAxis.ts +5 -0
- package/src/grid/defaults.ts +4 -0
- package/src/grid/index.ts +1 -0
- package/src/grid/plugins/BarsDiverging.ts +39 -0
- package/src/grid/types.ts +2 -0
- package/src/index.ts +2 -1
- package/src/tree/defaults.ts +21 -0
- package/src/tree/index.ts +4 -0
- package/src/tree/plugins/TreeLegend.ts +58 -0
- package/src/tree/plugins/TreeMap.ts +298 -0
- package/src/tree/types.ts +23 -0
- package/dist/src/multiGrid/plugins/Diverging.d.ts +0 -0
- package/dist/src/multiGrid/plugins/DivergingValueAxes.d.ts +0 -0
- package/dist/src/tree/index.d.ts +0 -0
- package/dist/src/tree/plugins/TreeMap.d.ts +0 -0
- package/src/multiGrid/plugins/Diverging.ts +0 -0
- package/src/multiGrid/plugins/DivergingValueAxes.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/base/BaseBarStack.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/base/BaseBars.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/base/BaseBarsTriangle.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/base/BaseDots.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/base/BaseGroupArea.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/base/BaseGroupAxis.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/base/BaseLegend.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/base/BaseLines.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/base/BaseValueAxis.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/base/types.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/grid/gridObservables.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/BarStack.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/Bars.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/BarsTriangle.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/Dots.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/GridLegend.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/GroupAux.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/GroupAxis.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/Lines.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/Ranking.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/RankingAxis.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/ScalingArea.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/ValueAxis.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/grid/plugins/ValueStackAxis.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/defaults.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/index.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/multiGridObservables.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/plugins/MultiBarStack.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/plugins/MultiBars.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/plugins/MultiBarsTriangle.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/plugins/MultiDots.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/plugins/MultiGridLegend.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/plugins/MultiGroupAxis.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/plugins/MultiLines.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/plugins/MultiValueAxis.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/plugins/OverlappingValueAxes.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/multiGrid/types.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/multiValue/index.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/multiValue/plugins/Scatter.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/multiValue/plugins/ScatterAxes.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/noneData/defaults.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/noneData/index.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/noneData/plugins/Container.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/noneData/plugins/Tooltip.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/noneData/types.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/relationship/index.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/relationship/plugins/Relationship.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/series/defaults.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/series/index.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/series/plugins/Bubbles.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/series/plugins/Pie.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/series/plugins/PieEventTexts.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/series/plugins/PieLabels.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/series/plugins/SeriesLegend.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/series/plugins/Waffle.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/series/seriesUtils.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/series/types.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/utils/commonUtils.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/utils/d3Graphics.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/utils/d3Utils.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/utils/observables.d.ts +0 -0
- /package/dist/{src → orbcharts-plugins-basic/src}/utils/orbchartsUtils.d.ts +0 -0
- /package/dist/{vite.config.d.ts → orbcharts-plugins-basic/vite.config.d.ts} +0 -0
package/dist/src/index.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orbcharts/plugins-basic",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.38",
|
|
4
4
|
"description": "plugins for OrbCharts",
|
|
5
5
|
"author": "Blue Planet Inc.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"vite-plugin-dts": "^3.7.3"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@orbcharts/core": "^3.0.0-alpha.
|
|
38
|
+
"@orbcharts/core": "^3.0.0-alpha.37",
|
|
39
39
|
"d3": "^7.8.5",
|
|
40
40
|
"rxjs": "^7.8.1"
|
|
41
41
|
}
|
|
@@ -116,6 +116,10 @@ function renderLinearAxis ({ selection, yAxisClassName, textClassName, fullParam
|
|
|
116
116
|
|
|
117
117
|
const valueLength = minAndMax[1] - minAndMax[0]
|
|
118
118
|
|
|
119
|
+
// const _valueScale = d3.scaleLinear()
|
|
120
|
+
// .domain([0, 150])
|
|
121
|
+
// .range([416.5, 791.349])
|
|
122
|
+
|
|
119
123
|
// 設定Y軸刻度
|
|
120
124
|
const yAxis = d3.axisLeft(valueScale)
|
|
121
125
|
.scale(valueScale)
|
|
@@ -365,6 +369,7 @@ export const createBaseValueAxis: BasePluginFn<BaseLinesContext> = (pluginName:
|
|
|
365
369
|
// 轉換後會退訂前一個未完成的訂閱事件,因此可以取到「同時間」最後一次的訂閱事件
|
|
366
370
|
switchMap(async (d) => d),
|
|
367
371
|
).subscribe(data => {
|
|
372
|
+
console.log(data)
|
|
368
373
|
|
|
369
374
|
const valueScale: d3.ScaleLinear<number, number> = createAxisLinearScale({
|
|
370
375
|
maxValue: data.minAndMax[1],
|
package/src/grid/defaults.ts
CHANGED
|
@@ -43,6 +43,10 @@ export const DEFAULT_BARS_PARAMS: BarsParams = {
|
|
|
43
43
|
barRadius: false,
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
+
export const DEFAULT_BARS_DIVERGING_PARAMS: BarsParams = {
|
|
47
|
+
...DEFAULT_BARS_PARAMS
|
|
48
|
+
}
|
|
49
|
+
|
|
46
50
|
export const DEFAULT_BAR_STACK_PARAMS: BarStackParams = {
|
|
47
51
|
barWidth: 0,
|
|
48
52
|
barGroupPadding: 10,
|
package/src/grid/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from './defaults'
|
|
|
2
2
|
export * from './types'
|
|
3
3
|
export { Lines } from './plugins/Lines'
|
|
4
4
|
export { Bars } from './plugins/Bars'
|
|
5
|
+
export { BarsDiverging } from './plugins/BarsDiverging'
|
|
5
6
|
export { BarStack } from './plugins/BarStack'
|
|
6
7
|
export { BarsTriangle } from './plugins/BarsTriangle'
|
|
7
8
|
export { Dots } from './plugins/Dots'
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import {
|
|
2
|
+
of,
|
|
3
|
+
Subject,
|
|
4
|
+
Observable } from 'rxjs'
|
|
5
|
+
import {
|
|
6
|
+
defineGridPlugin } from '@orbcharts/core'
|
|
7
|
+
import { DEFAULT_BARS_PARAMS } from '../defaults'
|
|
8
|
+
import { createBaseBars } from '../../base/BaseBars'
|
|
9
|
+
|
|
10
|
+
const pluginName = 'BarsDiverging'
|
|
11
|
+
|
|
12
|
+
export const BarsDiverging = defineGridPlugin(pluginName, DEFAULT_BARS_PARAMS)(({ selection, name, subject, observer }) => {
|
|
13
|
+
const destroy$ = new Subject()
|
|
14
|
+
|
|
15
|
+
const unsubscribeBaseBars = createBaseBars(pluginName, {
|
|
16
|
+
selection,
|
|
17
|
+
computedData$: observer.computedData$,
|
|
18
|
+
visibleComputedData$: observer.visibleComputedData$,
|
|
19
|
+
existedSeriesLabels$: observer.existedSeriesLabels$,
|
|
20
|
+
SeriesDataMap$: observer.SeriesDataMap$,
|
|
21
|
+
GroupDataMap$: observer.GroupDataMap$,
|
|
22
|
+
fullParams$: observer.fullParams$,
|
|
23
|
+
fullChartParams$: observer.fullChartParams$,
|
|
24
|
+
gridAxesTransform$: observer.gridAxesTransform$,
|
|
25
|
+
gridGraphicTransform$: observer.gridGraphicTransform$,
|
|
26
|
+
gridGraphicReverseScale$: observer.gridGraphicReverseScale$,
|
|
27
|
+
gridAxesSize$: observer.gridAxesSize$,
|
|
28
|
+
gridHighlight$: observer.gridHighlight$,
|
|
29
|
+
gridContainer$: observer.gridContainer$,
|
|
30
|
+
// isSeriesPositionSeprate$: observer.isSeriesPositionSeprate$,
|
|
31
|
+
isSeriesPositionSeprate$: of(true), // hack: 永遠為true,可以強制讓每組series的bars的x位置都是一樣的
|
|
32
|
+
event$: subject.event$,
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
return () => {
|
|
36
|
+
destroy$.next(undefined)
|
|
37
|
+
unsubscribeBaseBars()
|
|
38
|
+
}
|
|
39
|
+
})
|
package/src/grid/types.ts
CHANGED
package/src/index.ts
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { TreeMapParams, TreeLegendParams } from './types'
|
|
2
|
+
|
|
3
|
+
export const DEFAULT_TREE_MAP_PARAMS: TreeMapParams = {
|
|
4
|
+
paddingInner: 2,
|
|
5
|
+
paddingOuter: 2,
|
|
6
|
+
labelColorType: 'primary',
|
|
7
|
+
squarifyRatio: 1.618034, // 黃金比例
|
|
8
|
+
sort: (a, b) => b.value - a.value
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const DEFAULT_TREE_LEGEND_PARAMS: TreeLegendParams = {
|
|
12
|
+
position: 'right',
|
|
13
|
+
justify: 'end',
|
|
14
|
+
padding: 28,
|
|
15
|
+
backgroundFill: 'none',
|
|
16
|
+
backgroundStroke: 'none',
|
|
17
|
+
gap: 10,
|
|
18
|
+
listRectWidth: 14,
|
|
19
|
+
listRectHeight: 14,
|
|
20
|
+
listRectRadius: 0,
|
|
21
|
+
}
|
package/src/tree/index.ts
CHANGED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import * as d3 from 'd3'
|
|
2
|
+
import {
|
|
3
|
+
combineLatest,
|
|
4
|
+
map,
|
|
5
|
+
switchMap,
|
|
6
|
+
takeUntil,
|
|
7
|
+
Observable,
|
|
8
|
+
Subject } from 'rxjs'
|
|
9
|
+
import {
|
|
10
|
+
defineTreePlugin } from '@orbcharts/core'
|
|
11
|
+
import { DEFAULT_TREE_LEGEND_PARAMS } from '../defaults'
|
|
12
|
+
import { createBaseLegend } from '../../base/BaseLegend'
|
|
13
|
+
|
|
14
|
+
const pluginName = 'TreeLegend'
|
|
15
|
+
|
|
16
|
+
export const TreeLegend = defineTreePlugin(pluginName, DEFAULT_TREE_LEGEND_PARAMS)(({ selection, rootSelection, observer, subject }) => {
|
|
17
|
+
|
|
18
|
+
const destroy$ = new Subject()
|
|
19
|
+
|
|
20
|
+
const categoryLabels$: Observable<string[]> = observer.CategoryDataMap$.pipe(
|
|
21
|
+
takeUntil(destroy$),
|
|
22
|
+
map(data => {
|
|
23
|
+
return Array.from(data.keys())
|
|
24
|
+
})
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
// 全部列點矩型使用相同樣式參數
|
|
28
|
+
const fullParams$ = observer.fullParams$.pipe(
|
|
29
|
+
takeUntil(destroy$),
|
|
30
|
+
map(d => {
|
|
31
|
+
const seriesList = [
|
|
32
|
+
{
|
|
33
|
+
listRectWidth: d.listRectWidth,
|
|
34
|
+
listRectHeight: d.listRectHeight,
|
|
35
|
+
listRectRadius: d.listRectRadius,
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
return {
|
|
39
|
+
...d,
|
|
40
|
+
seriesList
|
|
41
|
+
}
|
|
42
|
+
})
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
const unsubscribeBaseLegend = createBaseLegend(pluginName, {
|
|
46
|
+
rootSelection,
|
|
47
|
+
seriesLabels$: categoryLabels$,
|
|
48
|
+
fullParams$,
|
|
49
|
+
layout$: observer.layout$,
|
|
50
|
+
fullChartParams$: observer.fullChartParams$
|
|
51
|
+
})
|
|
52
|
+
|
|
53
|
+
return () => {
|
|
54
|
+
destroy$.next(undefined)
|
|
55
|
+
unsubscribeBaseLegend()
|
|
56
|
+
}
|
|
57
|
+
})
|
|
58
|
+
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import * as d3 from 'd3'
|
|
2
|
+
import {
|
|
3
|
+
Subject,
|
|
4
|
+
Observable,
|
|
5
|
+
of,
|
|
6
|
+
takeUntil,
|
|
7
|
+
map,
|
|
8
|
+
switchMap,
|
|
9
|
+
combineLatest,
|
|
10
|
+
debounceTime,
|
|
11
|
+
distinctUntilChanged } from 'rxjs'
|
|
12
|
+
import {
|
|
13
|
+
defineTreePlugin } from '@orbcharts/core'
|
|
14
|
+
import type { Layout, ComputedDataTree, DataFormatterTree, ChartParams } from '../../../../orbcharts-core/src'
|
|
15
|
+
import type { TreeMapParams } from '../types'
|
|
16
|
+
import { DEFAULT_TREE_MAP_PARAMS } from '../defaults'
|
|
17
|
+
import { getClassName, getColor } from '../../utils/orbchartsUtils'
|
|
18
|
+
|
|
19
|
+
const pluginName = 'TreeMap'
|
|
20
|
+
const treeClassName = getClassName(pluginName, 'tree')
|
|
21
|
+
|
|
22
|
+
function renderTree ({ selection, treeData, fullParams, fullChartParams }: {
|
|
23
|
+
selection: d3.Selection<any, any, any, any>
|
|
24
|
+
treeData: d3.HierarchyRectangularNode<ComputedDataTree>[]
|
|
25
|
+
fullParams: TreeMapParams
|
|
26
|
+
fullChartParams: ChartParams
|
|
27
|
+
}) {
|
|
28
|
+
const padding = fullChartParams.styles.textSize / 2
|
|
29
|
+
|
|
30
|
+
const cell = selection.selectAll<SVGGElement, d3.HierarchyRectangularNode<ComputedDataTree>>(`g.${treeClassName}`)
|
|
31
|
+
.data(treeData, d => d.data.id)
|
|
32
|
+
.join('g')
|
|
33
|
+
.attr('class', treeClassName)
|
|
34
|
+
|
|
35
|
+
cell
|
|
36
|
+
// .transition()
|
|
37
|
+
// .duration(fullChartParams.transitionDuration)
|
|
38
|
+
.attr('transform', (d) => !d.x0 || !d.y0 ? null : `translate(${d.x0},${d.y0})`)
|
|
39
|
+
.each((d, i, nodes) => {
|
|
40
|
+
const eachCell = d3.select(nodes[i])
|
|
41
|
+
|
|
42
|
+
const tile = eachCell
|
|
43
|
+
.selectAll<SVGRectElement, d3.HierarchyRectangularNode<ComputedDataTree>>('rect')
|
|
44
|
+
.data([d], d => d.data.id)
|
|
45
|
+
.join('rect')
|
|
46
|
+
.attr("id", d => d.data.id)
|
|
47
|
+
.attr("class", "tile")
|
|
48
|
+
.attr("width", (d) => d.x1 - d.x0)
|
|
49
|
+
.attr("height", (d) => d.y1 - d.y0)
|
|
50
|
+
.attr('fill', d => d.data.color)
|
|
51
|
+
.attr('data-name', d => d.data.label)
|
|
52
|
+
.attr('data-category', d => d.data.categoryLabel)
|
|
53
|
+
.attr('data-value', d => d.data.value)
|
|
54
|
+
|
|
55
|
+
const label = eachCell
|
|
56
|
+
.selectAll('g')
|
|
57
|
+
.data([d])
|
|
58
|
+
.join('g')
|
|
59
|
+
.each((d, i, nodes) => {
|
|
60
|
+
const eachLabel = d3.select(nodes[i])
|
|
61
|
+
const text = eachLabel
|
|
62
|
+
.selectAll('text')
|
|
63
|
+
.data([d])
|
|
64
|
+
.join('text')
|
|
65
|
+
.text(d => d.data.label)
|
|
66
|
+
.attr('dominant-baseline', 'hanging')
|
|
67
|
+
.attr("x", padding)
|
|
68
|
+
.attr("y", padding)
|
|
69
|
+
.attr('font-size', fullChartParams.styles.textSize)
|
|
70
|
+
.each(function(d) {
|
|
71
|
+
// -- tspan(自動斷行) --
|
|
72
|
+
const textElement = d3.select(this);
|
|
73
|
+
const words = d.data.label.split(/\s+/).reverse() // 以空隔分割字串
|
|
74
|
+
let word;
|
|
75
|
+
let line: string[] = []
|
|
76
|
+
const lineHeight = fullChartParams.styles.textSize // 行高
|
|
77
|
+
const x = textElement.attr("x")
|
|
78
|
+
let y = textElement.attr("y")
|
|
79
|
+
let dy = 0
|
|
80
|
+
let tspan = textElement
|
|
81
|
+
.text(null)
|
|
82
|
+
.append("tspan")
|
|
83
|
+
.attr('cursor', 'default')
|
|
84
|
+
.attr('fill', getColor(fullParams.labelColorType, fullChartParams))
|
|
85
|
+
.attr('font-size', fullChartParams.styles.textSize)
|
|
86
|
+
.attr("x", x)
|
|
87
|
+
.attr("y", y)
|
|
88
|
+
|
|
89
|
+
while (word = words.pop()) {
|
|
90
|
+
line.push(word)
|
|
91
|
+
tspan.text(line.join(" "))
|
|
92
|
+
if (tspan.node().getComputedTextLength() > (d.x1 - d.x0 - padding)) {
|
|
93
|
+
line.pop()
|
|
94
|
+
tspan.text(line.join(" "))
|
|
95
|
+
line = [word]
|
|
96
|
+
dy += lineHeight
|
|
97
|
+
tspan = textElement
|
|
98
|
+
.append("tspan")
|
|
99
|
+
.attr('cursor', 'default')
|
|
100
|
+
.attr('fill', getColor(fullParams.labelColorType, fullChartParams))
|
|
101
|
+
.attr('font-size', fullChartParams.styles.textSize)
|
|
102
|
+
.attr("x", x)
|
|
103
|
+
.attr("y", y)
|
|
104
|
+
.attr("dy", dy + "px")
|
|
105
|
+
.text(word)
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
})
|
|
109
|
+
})
|
|
110
|
+
|
|
111
|
+
})
|
|
112
|
+
|
|
113
|
+
return cell
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
function highlight ({ selection, ids, fullChartParams }: {
|
|
117
|
+
selection: d3.Selection<any, d3.HierarchyRectangularNode<ComputedDataTree>, any, any>
|
|
118
|
+
ids: string[]
|
|
119
|
+
fullChartParams: ChartParams
|
|
120
|
+
}) {
|
|
121
|
+
selection.interrupt('highlight')
|
|
122
|
+
|
|
123
|
+
if (!ids.length) {
|
|
124
|
+
// remove highlight
|
|
125
|
+
selection
|
|
126
|
+
.transition('highlight')
|
|
127
|
+
.duration(200)
|
|
128
|
+
.style('opacity', 1)
|
|
129
|
+
return
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
selection
|
|
133
|
+
.each((d, i, n) => {
|
|
134
|
+
if (ids.includes(d.data.id)) {
|
|
135
|
+
d3.select(n[i])
|
|
136
|
+
.style('opacity', 1)
|
|
137
|
+
} else {
|
|
138
|
+
d3.select(n[i])
|
|
139
|
+
.style('opacity', fullChartParams.styles.unhighlightedOpacity)
|
|
140
|
+
}
|
|
141
|
+
})
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
export const TreeMap = defineTreePlugin(pluginName, DEFAULT_TREE_MAP_PARAMS)(({ selection, name, subject, observer }) => {
|
|
145
|
+
const destroy$ = new Subject()
|
|
146
|
+
|
|
147
|
+
const treeData$ = combineLatest({
|
|
148
|
+
layout: observer.layout$,
|
|
149
|
+
visibleComputedData: observer.visibleComputedData$,
|
|
150
|
+
fullParams: observer.fullParams$,
|
|
151
|
+
fullDataFormatter: observer.fullDataFormatter$,
|
|
152
|
+
fullChartParams: observer.fullChartParams$
|
|
153
|
+
}).pipe(
|
|
154
|
+
takeUntil(destroy$),
|
|
155
|
+
switchMap(async d => d),
|
|
156
|
+
map(data => {
|
|
157
|
+
const treemap = d3.treemap()
|
|
158
|
+
.size([data.layout.width, data.layout.height])
|
|
159
|
+
.paddingInner(data.fullParams.paddingInner)
|
|
160
|
+
.paddingOuter(data.fullParams.paddingOuter)
|
|
161
|
+
.round(true)
|
|
162
|
+
.tile(d3.treemapSquarify.ratio(data.fullParams.squarifyRatio))
|
|
163
|
+
|
|
164
|
+
const root = d3.hierarchy(data.visibleComputedData)
|
|
165
|
+
.sum(d => d.value)
|
|
166
|
+
.sort(data.fullParams.sort as (a: any, b: any) => number)
|
|
167
|
+
|
|
168
|
+
//call treemap
|
|
169
|
+
treemap(root)
|
|
170
|
+
|
|
171
|
+
const treeData: d3.HierarchyRectangularNode<ComputedDataTree>[] = root.leaves() as any
|
|
172
|
+
|
|
173
|
+
return treeData
|
|
174
|
+
})
|
|
175
|
+
)
|
|
176
|
+
|
|
177
|
+
const cellSelection$ = combineLatest({
|
|
178
|
+
selection: of(selection),
|
|
179
|
+
treeData: treeData$,
|
|
180
|
+
fullParams: observer.fullParams$,
|
|
181
|
+
fullChartParams: observer.fullChartParams$
|
|
182
|
+
}).pipe(
|
|
183
|
+
takeUntil(destroy$),
|
|
184
|
+
switchMap(async d => d),
|
|
185
|
+
map(data => {
|
|
186
|
+
return renderTree({
|
|
187
|
+
selection,
|
|
188
|
+
treeData: data.treeData,
|
|
189
|
+
fullParams: data.fullParams,
|
|
190
|
+
fullChartParams: data.fullChartParams
|
|
191
|
+
})
|
|
192
|
+
})
|
|
193
|
+
)
|
|
194
|
+
|
|
195
|
+
const highlightTarget$ = observer.fullChartParams$.pipe(
|
|
196
|
+
takeUntil(destroy$),
|
|
197
|
+
map(d => d.highlightTarget),
|
|
198
|
+
distinctUntilChanged()
|
|
199
|
+
)
|
|
200
|
+
|
|
201
|
+
combineLatest({
|
|
202
|
+
cellSelection: cellSelection$,
|
|
203
|
+
computedData: observer.computedData$,
|
|
204
|
+
treeData: treeData$,
|
|
205
|
+
fullParams: observer.fullParams$,
|
|
206
|
+
fullChartParams: observer.fullChartParams$,
|
|
207
|
+
highlightTarget: highlightTarget$,
|
|
208
|
+
CategoryDataMap: observer.CategoryDataMap$,
|
|
209
|
+
}).pipe(
|
|
210
|
+
takeUntil(destroy$),
|
|
211
|
+
switchMap(async d => d)
|
|
212
|
+
).subscribe(data => {
|
|
213
|
+
data.cellSelection
|
|
214
|
+
.on('mouseover', (event, datum) => {
|
|
215
|
+
event.stopPropagation()
|
|
216
|
+
|
|
217
|
+
subject.event$.next({
|
|
218
|
+
type: 'tree',
|
|
219
|
+
eventName: 'mouseover',
|
|
220
|
+
pluginName,
|
|
221
|
+
highlightTarget: data.highlightTarget,
|
|
222
|
+
datum: datum.data,
|
|
223
|
+
category: data.CategoryDataMap.get(datum.data.categoryLabel)!,
|
|
224
|
+
categoryIndex: datum.data.categoryIndex,
|
|
225
|
+
categoryLabel: datum.data.categoryLabel,
|
|
226
|
+
event,
|
|
227
|
+
data: data.computedData
|
|
228
|
+
})
|
|
229
|
+
})
|
|
230
|
+
.on('mousemove', (event, datum) => {
|
|
231
|
+
event.stopPropagation()
|
|
232
|
+
|
|
233
|
+
subject.event$.next({
|
|
234
|
+
type: 'tree',
|
|
235
|
+
eventName: 'mousemove',
|
|
236
|
+
pluginName,
|
|
237
|
+
highlightTarget: data.highlightTarget,
|
|
238
|
+
datum: datum.data,
|
|
239
|
+
category: data.CategoryDataMap.get(datum.data.categoryLabel)!,
|
|
240
|
+
categoryIndex: datum.data.categoryIndex,
|
|
241
|
+
categoryLabel: datum.data.categoryLabel,
|
|
242
|
+
event,
|
|
243
|
+
data: data.computedData
|
|
244
|
+
})
|
|
245
|
+
})
|
|
246
|
+
.on('mouseout', (event, datum) => {
|
|
247
|
+
event.stopPropagation()
|
|
248
|
+
|
|
249
|
+
subject.event$.next({
|
|
250
|
+
type: 'tree',
|
|
251
|
+
eventName: 'mouseout',
|
|
252
|
+
pluginName,
|
|
253
|
+
highlightTarget: data.highlightTarget,
|
|
254
|
+
datum: datum.data,
|
|
255
|
+
category: data.CategoryDataMap.get(datum.data.categoryLabel)!,
|
|
256
|
+
categoryIndex: datum.data.categoryIndex,
|
|
257
|
+
categoryLabel: datum.data.categoryLabel,
|
|
258
|
+
event,
|
|
259
|
+
data: data.computedData
|
|
260
|
+
})
|
|
261
|
+
})
|
|
262
|
+
.on('click', (event, datum) => {
|
|
263
|
+
event.stopPropagation()
|
|
264
|
+
|
|
265
|
+
subject.event$.next({
|
|
266
|
+
type: 'tree',
|
|
267
|
+
eventName: 'click',
|
|
268
|
+
pluginName,
|
|
269
|
+
highlightTarget: data.highlightTarget,
|
|
270
|
+
datum: datum.data,
|
|
271
|
+
category: data.CategoryDataMap.get(datum.data.categoryLabel)!,
|
|
272
|
+
categoryIndex: datum.data.categoryIndex,
|
|
273
|
+
categoryLabel: datum.data.categoryLabel,
|
|
274
|
+
event,
|
|
275
|
+
data: data.computedData
|
|
276
|
+
})
|
|
277
|
+
})
|
|
278
|
+
})
|
|
279
|
+
|
|
280
|
+
combineLatest({
|
|
281
|
+
cellSelection: cellSelection$,
|
|
282
|
+
highlight: observer.treeHighlight$,
|
|
283
|
+
fullChartParams: observer.fullChartParams$
|
|
284
|
+
}).pipe(
|
|
285
|
+
takeUntil(destroy$),
|
|
286
|
+
switchMap(async d => d)
|
|
287
|
+
).subscribe(data => {
|
|
288
|
+
highlight({
|
|
289
|
+
selection: data.cellSelection,
|
|
290
|
+
ids: data.highlight,
|
|
291
|
+
fullChartParams: data.fullChartParams
|
|
292
|
+
})
|
|
293
|
+
})
|
|
294
|
+
|
|
295
|
+
return () => {
|
|
296
|
+
destroy$.next(undefined)
|
|
297
|
+
}
|
|
298
|
+
})
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ColorType } from '@orbcharts/core'
|
|
2
|
+
import type { ComputedDataTree } from '../../../orbcharts-core/src'
|
|
3
|
+
|
|
4
|
+
export interface TreeMapParams {
|
|
5
|
+
paddingInner: number
|
|
6
|
+
paddingOuter: number
|
|
7
|
+
labelColorType: ColorType
|
|
8
|
+
squarifyRatio: number
|
|
9
|
+
sort: (a: ComputedDataTree, b: ComputedDataTree) => number
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface TreeLegendParams {
|
|
13
|
+
position: 'top' | 'bottom' | 'left' | 'right'
|
|
14
|
+
justify: 'start' | 'center' | 'end'
|
|
15
|
+
padding: number
|
|
16
|
+
backgroundFill: ColorType
|
|
17
|
+
backgroundStroke: ColorType
|
|
18
|
+
gap: number
|
|
19
|
+
listRectWidth: number
|
|
20
|
+
listRectHeight: number
|
|
21
|
+
listRectRadius: number
|
|
22
|
+
}
|
|
23
|
+
|
|
File without changes
|
|
File without changes
|
package/dist/src/tree/index.d.ts
DELETED
|
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
|
|
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/{src → orbcharts-plugins-basic/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
|