@orbcharts/plugins-basic 3.0.0-alpha.42 → 3.0.0-alpha.44
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/orbcharts-plugins-basic.es.js +6647 -6556
- package/dist/orbcharts-plugins-basic.umd.js +8 -8
- package/dist/src/base/BaseBarStack.d.ts +1 -1
- package/dist/src/base/BaseBars.d.ts +1 -1
- package/dist/src/base/BaseBarsTriangle.d.ts +1 -1
- package/dist/src/base/BaseDots.d.ts +1 -1
- package/dist/src/base/BaseLegend.d.ts +1 -0
- package/dist/src/base/BaseLineAreas.d.ts +1 -1
- package/dist/src/base/BaseLines.d.ts +1 -1
- package/dist/src/multiGrid/defaults.d.ts +2 -1
- package/dist/src/multiGrid/index.d.ts +1 -0
- package/dist/src/multiGrid/plugins/MultiLineAreas.d.ts +1 -0
- package/dist/src/multiGrid/types.d.ts +4 -4
- package/package.json +2 -2
- package/src/base/BaseBarStack.ts +4 -2
- package/src/base/BaseBars.ts +4 -2
- package/src/base/BaseBarsTriangle.ts +4 -2
- package/src/base/BaseDots.ts +6 -4
- package/src/base/BaseGroupAxis.ts +3 -3
- package/src/base/BaseLegend.ts +18 -13
- package/src/base/BaseLineAreas.ts +4 -7
- package/src/base/BaseLines.ts +4 -7
- package/src/base/BaseValueAxis.ts +3 -3
- package/src/grid/plugins/GridLegend.ts +2 -1
- package/src/grid/plugins/GroupAux.ts +7 -4
- package/src/multiGrid/defaults.ts +7 -0
- package/src/multiGrid/index.ts +1 -0
- package/src/multiGrid/multiGridObservables.ts +14 -3
- package/src/multiGrid/plugins/MultiGridLegend.ts +2 -1
- package/src/multiGrid/plugins/MultiLineAreas.ts +59 -0
- package/src/multiGrid/plugins/OverlappingValueAxes.ts +0 -1
- package/src/multiGrid/types.ts +5 -5
- package/src/noneData/plugins/Tooltip.ts +9 -3
- package/src/series/plugins/Bubbles.ts +4 -2
- package/src/series/plugins/Pie.ts +3 -1
- package/src/series/plugins/PieLabels.ts +4 -1
- package/src/series/plugins/SeriesLegend.ts +2 -1
- package/src/tree/plugins/TreeLegend.ts +2 -1
- package/src/tree/plugins/TreeMap.ts +11 -6
@@ -61,7 +61,6 @@ export const OverlappingValueAxes = defineMultiGridPlugin(pluginName, DEFAULT_OV
|
|
61
61
|
} else if (fullDataFormatter.gridList[data.firstGridIndex].valueAxis.position === 'right') {
|
62
62
|
reversePosition = 'left'
|
63
63
|
}
|
64
|
-
console.log('reversePosition', reversePosition)
|
65
64
|
return <DataFormatterGrid>{
|
66
65
|
type: 'grid',
|
67
66
|
grid: {
|
package/src/multiGrid/types.ts
CHANGED
@@ -2,17 +2,13 @@ import type { BaseBarsParams } from '../base/BaseBars'
|
|
2
2
|
import type { BaseBarStackParams } from '../base/BaseBarStack'
|
3
3
|
import type { BaseBarsTriangleParams } from '../base/BaseBarsTriangle'
|
4
4
|
import type { BaseLinesParams } from '../base/BaseLines'
|
5
|
+
import type { BaseLineAreasParams } from '../base/BaseLineAreas'
|
5
6
|
import type { BaseDotsParams } from '../base/BaseDots'
|
6
7
|
import type { BaseGroupAxisParams } from '../base/BaseGroupAxis'
|
7
8
|
import type { BaseValueAxisParams } from '../base/BaseValueAxis'
|
8
9
|
import type {
|
9
10
|
ChartParams, Layout, ColorType } from '@orbcharts/core'
|
10
11
|
|
11
|
-
export interface BarsAndLinesParams {
|
12
|
-
bars: BaseBarsParams
|
13
|
-
lines: BaseLinesParams
|
14
|
-
}
|
15
|
-
|
16
12
|
export interface MultiGridLegendParams {
|
17
13
|
position: 'top' | 'bottom' | 'left' | 'right'
|
18
14
|
justify: 'start' | 'center' | 'end'
|
@@ -56,6 +52,10 @@ export interface MultiLinesParams extends BaseLinesParams {
|
|
56
52
|
gridIndexes: number[]
|
57
53
|
}
|
58
54
|
|
55
|
+
export interface MultiLineAreasParams extends BaseLineAreasParams {
|
56
|
+
gridIndexes: number[]
|
57
|
+
}
|
58
|
+
|
59
59
|
export interface MultiDotsParams extends BaseDotsParams {
|
60
60
|
gridIndexes: number[]
|
61
61
|
}
|
@@ -17,6 +17,7 @@ import { defineNoneDataPlugin } from '@orbcharts/core'
|
|
17
17
|
import { getSvgGElementSize, appendSvg } from '../../utils/d3Utils'
|
18
18
|
import { getColor, getClassName } from '../../utils/orbchartsUtils'
|
19
19
|
import { TOOLTIP_PARAMS } from '../defaults'
|
20
|
+
import { textSizePxObservable } from '@orbcharts/core'
|
20
21
|
|
21
22
|
interface TooltipStyle {
|
22
23
|
backgroundColor: string
|
@@ -25,7 +26,8 @@ interface TooltipStyle {
|
|
25
26
|
offset: [number, number]
|
26
27
|
padding: number
|
27
28
|
textColor: string
|
28
|
-
textSize: number
|
29
|
+
textSize: number | string // chartParams上的設定
|
30
|
+
textSizePx: number
|
29
31
|
}
|
30
32
|
|
31
33
|
const pluginName = 'Tooltip'
|
@@ -33,7 +35,7 @@ const gClassName = getClassName(pluginName, 'g')
|
|
33
35
|
const boxClassName = getClassName(pluginName, 'box')
|
34
36
|
|
35
37
|
function textToSvg (textArr: string[], textStyle: TooltipStyle) {
|
36
|
-
const lineHeight = textStyle.
|
38
|
+
const lineHeight = textStyle.textSizePx * 1.5
|
37
39
|
return textArr
|
38
40
|
.filter(d => d != '')
|
39
41
|
.map((text, i) => {
|
@@ -203,9 +205,12 @@ export const Tooltip: PluginConstructor<any, string, any> = defineNoneDataPlugin
|
|
203
205
|
// map(d => d as EventTypeMap<typeof chartType>)
|
204
206
|
)
|
205
207
|
|
208
|
+
const textSizePx$ = textSizePxObservable(observer.fullChartParams$)
|
209
|
+
|
206
210
|
const tooltipStyle$: Observable<TooltipStyle> = combineLatest({
|
207
211
|
fullChartParams: observer.fullChartParams$,
|
208
|
-
fullParams: observer.fullParams
|
212
|
+
fullParams: observer.fullParams$,
|
213
|
+
textSizePx: textSizePx$
|
209
214
|
}).pipe(
|
210
215
|
takeUntil(destroy$),
|
211
216
|
switchMap(async d => d),
|
@@ -217,6 +222,7 @@ export const Tooltip: PluginConstructor<any, string, any> = defineNoneDataPlugin
|
|
217
222
|
offset: data.fullParams.offset,
|
218
223
|
padding: data.fullParams.padding,
|
219
224
|
textSize: data.fullChartParams.styles.textSize,
|
225
|
+
textSizePx: data.textSizePx,
|
220
226
|
textColor: getColor(data.fullParams.textColorType, data.fullChartParams),
|
221
227
|
}
|
222
228
|
})
|
@@ -148,7 +148,7 @@ function renderBubbles ({ graphicSelection, bubblesData, fullParams }: {
|
|
148
148
|
.append<SVGGElement>("g")
|
149
149
|
.attr('cursor', 'pointer')
|
150
150
|
enter
|
151
|
-
.
|
151
|
+
.attr('font-size', 12)
|
152
152
|
.style('fill', '#ffffff')
|
153
153
|
.attr("text-anchor", "middle")
|
154
154
|
.attr("transform", (d) => {
|
@@ -509,7 +509,9 @@ export const Bubbles = defineSeriesPlugin('Bubbles', DEFAULT_BUBBLES_PARAMS)(({
|
|
509
509
|
combineLatest({
|
510
510
|
bubblesSelection: bubblesSelection$,
|
511
511
|
bubblesData: bubblesData$,
|
512
|
-
highlight: observer.seriesHighlight
|
512
|
+
highlight: observer.seriesHighlight$.pipe(
|
513
|
+
map(data => data.map(d => d.id))
|
514
|
+
),
|
513
515
|
fullChartParams: observer.fullChartParams$,
|
514
516
|
fullParams: observer.fullParams$,
|
515
517
|
layout: observer.layout$
|
@@ -511,7 +511,9 @@ export const Pie = defineSeriesPlugin(pluginName, DEFAULT_PIE_PARAMS)(({ selecti
|
|
511
511
|
|
512
512
|
combineLatest({
|
513
513
|
pathSelection: pathSelection$,
|
514
|
-
highlight: observer.seriesHighlight
|
514
|
+
highlight: observer.seriesHighlight$.pipe(
|
515
|
+
map(data => data.map(d => d.id))
|
516
|
+
),
|
515
517
|
fullChartParams: observer.fullChartParams$,
|
516
518
|
arc: arc$,
|
517
519
|
arcMouseover: arcMouseover$
|
@@ -3,6 +3,7 @@ import {
|
|
3
3
|
combineLatest,
|
4
4
|
switchMap,
|
5
5
|
first,
|
6
|
+
map,
|
6
7
|
takeUntil,
|
7
8
|
Subject,
|
8
9
|
BehaviorSubject } from 'rxjs'
|
@@ -266,7 +267,9 @@ export const PieLabels = defineSeriesPlugin(pluginName, DEFAULT_PIE_LABELS_PARAM
|
|
266
267
|
|
267
268
|
combineLatest({
|
268
269
|
labelSelection: labelSelection$,
|
269
|
-
highlight: observer.seriesHighlight
|
270
|
+
highlight: observer.seriesHighlight$.pipe(
|
271
|
+
map(data => data.map(d => d.id))
|
272
|
+
),
|
270
273
|
fullChartParams: observer.fullChartParams$,
|
271
274
|
}).pipe(
|
272
275
|
takeUntil(destroy$),
|
@@ -47,7 +47,8 @@ export const SeriesLegend = defineSeriesPlugin(pluginName, DEFAULT_SERIES_LEGEND
|
|
47
47
|
seriesLabels$,
|
48
48
|
fullParams$,
|
49
49
|
layout$: observer.layout$,
|
50
|
-
fullChartParams$: observer.fullChartParams
|
50
|
+
fullChartParams$: observer.fullChartParams$,
|
51
|
+
textSizePx$: observer.textSizePx$
|
51
52
|
})
|
52
53
|
|
53
54
|
return () => {
|
@@ -47,7 +47,8 @@ export const TreeLegend = defineTreePlugin(pluginName, DEFAULT_TREE_LEGEND_PARAM
|
|
47
47
|
seriesLabels$: categoryLabels$,
|
48
48
|
fullParams$,
|
49
49
|
layout$: observer.layout$,
|
50
|
-
fullChartParams$: observer.fullChartParams
|
50
|
+
fullChartParams$: observer.fullChartParams$,
|
51
|
+
textSizePx$: observer.textSizePx$
|
51
52
|
})
|
52
53
|
|
53
54
|
return () => {
|
@@ -20,13 +20,15 @@ const pluginName = 'TreeMap'
|
|
20
20
|
const treeClassName = getClassName(pluginName, 'tree')
|
21
21
|
const tileClassName = getClassName(pluginName, 'tile')
|
22
22
|
|
23
|
-
function renderTree ({ selection, treeData, fullParams, fullChartParams }: {
|
23
|
+
function renderTree ({ selection, treeData, fullParams, fullChartParams, textSizePx }: {
|
24
24
|
selection: d3.Selection<any, any, any, any>
|
25
25
|
treeData: d3.HierarchyRectangularNode<ComputedDataTree>[]
|
26
26
|
fullParams: TreeMapParams
|
27
27
|
fullChartParams: ChartParams
|
28
|
+
textSizePx: number
|
28
29
|
}) {
|
29
|
-
const padding =
|
30
|
+
const padding = textSizePx / 2
|
31
|
+
const lineHeight = textSizePx // 行高
|
30
32
|
|
31
33
|
const cell = selection.selectAll<SVGGElement, d3.HierarchyRectangularNode<ComputedDataTree>>(`g.${treeClassName}`)
|
32
34
|
.data(treeData, d => d.data.id)
|
@@ -75,7 +77,6 @@ function renderTree ({ selection, treeData, fullParams, fullChartParams }: {
|
|
75
77
|
const words = d.data.label.split(/\s+/).reverse() // 以空隔分割字串
|
76
78
|
let word;
|
77
79
|
let line: string[] = []
|
78
|
-
const lineHeight = fullChartParams.styles.textSize // 行高
|
79
80
|
const x = textElement.attr("x")
|
80
81
|
let y = textElement.attr("y")
|
81
82
|
let dy = 0
|
@@ -180,7 +181,8 @@ export const TreeMap = defineTreePlugin(pluginName, DEFAULT_TREE_MAP_PARAMS)(({
|
|
180
181
|
selection: of(selection),
|
181
182
|
treeData: treeData$,
|
182
183
|
fullParams: observer.fullParams$,
|
183
|
-
fullChartParams: observer.fullChartParams
|
184
|
+
fullChartParams: observer.fullChartParams$,
|
185
|
+
textSizePx: observer.textSizePx$
|
184
186
|
}).pipe(
|
185
187
|
takeUntil(destroy$),
|
186
188
|
switchMap(async d => d),
|
@@ -189,7 +191,8 @@ export const TreeMap = defineTreePlugin(pluginName, DEFAULT_TREE_MAP_PARAMS)(({
|
|
189
191
|
selection,
|
190
192
|
treeData: data.treeData,
|
191
193
|
fullParams: data.fullParams,
|
192
|
-
fullChartParams: data.fullChartParams
|
194
|
+
fullChartParams: data.fullChartParams,
|
195
|
+
textSizePx: data.textSizePx
|
193
196
|
})
|
194
197
|
})
|
195
198
|
)
|
@@ -281,7 +284,9 @@ export const TreeMap = defineTreePlugin(pluginName, DEFAULT_TREE_MAP_PARAMS)(({
|
|
281
284
|
|
282
285
|
combineLatest({
|
283
286
|
cellSelection: cellSelection$,
|
284
|
-
highlight: observer.treeHighlight
|
287
|
+
highlight: observer.treeHighlight$.pipe(
|
288
|
+
map(data => data.map(d => d.id))
|
289
|
+
),
|
285
290
|
fullChartParams: observer.fullChartParams$
|
286
291
|
}).pipe(
|
287
292
|
takeUntil(destroy$),
|