@orbcharts/plugins-basic 3.0.0-alpha.53 → 3.0.0-alpha.55

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.
@@ -2,7 +2,7 @@ import { Observable } from 'rxjs';
2
2
  import { ContextObserverMultiGrid, ContextObserverMultiGridDetail } from '@orbcharts/core';
3
3
 
4
4
  interface MultiGridPluginParams {
5
- gridIndexes: number[];
5
+ gridIndexes: number[] | 'all';
6
6
  }
7
7
  export declare const multiGridPluginDetailObservables: (observer: ContextObserverMultiGrid<MultiGridPluginParams>) => Observable<ContextObserverMultiGridDetail[]>;
8
8
  export {};
@@ -26,31 +26,31 @@ export interface MultiGridLegendParams {
26
26
  textColorType: ColorType;
27
27
  }
28
28
  export interface MultiGroupAxisParams extends BaseGroupAxisParams {
29
- gridIndexes: number[];
29
+ gridIndexes: number[] | 'all';
30
30
  }
31
31
  export interface MultiValueAxisParams extends BaseValueAxisParams {
32
- gridIndexes: number[];
32
+ gridIndexes: number[] | 'all';
33
33
  }
34
34
  export interface MultiValueStackAxisParams extends BaseValueAxisParams {
35
- gridIndexes: number[];
35
+ gridIndexes: number[] | 'all';
36
36
  }
37
37
  export interface MultiBarsParams extends BaseBarsParams {
38
- gridIndexes: number[];
38
+ gridIndexes: number[] | 'all';
39
39
  }
40
40
  export interface MultiBarStackParams extends BaseBarStackParams {
41
- gridIndexes: number[];
41
+ gridIndexes: number[] | 'all';
42
42
  }
43
43
  export interface MultiBarsTriangleParams extends BaseBarsTriangleParams {
44
- gridIndexes: number[];
44
+ gridIndexes: number[] | 'all';
45
45
  }
46
46
  export interface MultiLinesParams extends BaseLinesParams {
47
- gridIndexes: number[];
47
+ gridIndexes: number[] | 'all';
48
48
  }
49
49
  export interface MultiLineAreasParams extends BaseLineAreasParams {
50
- gridIndexes: number[];
50
+ gridIndexes: number[] | 'all';
51
51
  }
52
52
  export interface MultiDotsParams extends BaseDotsParams {
53
- gridIndexes: number[];
53
+ gridIndexes: number[] | 'all';
54
54
  }
55
55
  export interface OverlappingValueAxesParams {
56
56
  firstAxis: BaseValueAxisParams;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orbcharts/plugins-basic",
3
- "version": "3.0.0-alpha.53",
3
+ "version": "3.0.0-alpha.55",
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.49",
38
+ "@orbcharts/core": "^3.0.0-alpha.51",
39
39
  "d3": "^7.8.5",
40
40
  "rxjs": "^7.8.1"
41
41
  }
@@ -41,6 +41,7 @@ export const DEFAULT_GROUP_AREA_PARAMS: GroupAuxParams = {
41
41
  labelTextFormat: text => text,
42
42
  labelPadding: 24,
43
43
  }
44
+ DEFAULT_GROUP_AREA_PARAMS.labelTextFormat.toString = () => `text => text`
44
45
 
45
46
  export const DEFAULT_BARS_PARAMS: BarsParams = {
46
47
  // barType: 'rect',
@@ -83,6 +84,7 @@ export const DEFAULT_GROUP_AXIS_PARAMS: GroupAxisParams = {
83
84
  tickTextRotate: 0,
84
85
  tickTextColorType: 'primary',
85
86
  }
87
+ DEFAULT_GROUP_AXIS_PARAMS.tickFormat.toString = () => `text => text`
86
88
 
87
89
  export const DEFAULT_VALUE_AXIS_PARAMS: ValueAxisParams = {
88
90
  // labelAnchor: 'end',
@@ -50,6 +50,7 @@ export const DEFAULT_MULTI_GROUP_AXIS_PARAMS: MultiGroupAxisParams = {
50
50
  tickTextColorType: 'primary',
51
51
  gridIndexes: [0]
52
52
  }
53
+ DEFAULT_MULTI_GROUP_AXIS_PARAMS.tickFormat.toString = () => `text => text`
53
54
 
54
55
  export const DEFAULT_MULTI_VALUE_AXIS_PARAMS: MultiValueAxisParams = {
55
56
  // labelAnchor: 'end',
@@ -19,7 +19,7 @@ import type {
19
19
 
20
20
  // 可設定多個gridIndex的params
21
21
  interface MultiGridPluginParams {
22
- gridIndexes: number[]
22
+ gridIndexes: number[] | 'all'
23
23
  }
24
24
 
25
25
  // 對應grid資料的plugin所需Observable(必須有gridIndexes)
@@ -35,6 +35,11 @@ export const multiGridPluginDetailObservables = (observer: ContextObserverMultiG
35
35
  gridIndexes: gridIndexes$,
36
36
  }).pipe(
37
37
  map(data => {
38
+ // 對應所有grid
39
+ if (data.gridIndexes === 'all') {
40
+ return data.multiGridEachDetail
41
+ }
42
+ // 自訂對應grid
38
43
  return data.gridIndexes.map(gridIndex => {
39
44
  return data.multiGridEachDetail[gridIndex] ?? data.multiGridEachDetail[0]
40
45
  })
@@ -29,39 +29,39 @@ export interface MultiGridLegendParams {
29
29
  }
30
30
 
31
31
  export interface MultiGroupAxisParams extends BaseGroupAxisParams {
32
- gridIndexes: number[]
32
+ gridIndexes: number[] | 'all'
33
33
  }
34
34
 
35
35
  export interface MultiValueAxisParams extends BaseValueAxisParams {
36
- gridIndexes: number[]
36
+ gridIndexes: number[] | 'all'
37
37
  }
38
38
 
39
39
  export interface MultiValueStackAxisParams extends BaseValueAxisParams {
40
- gridIndexes: number[]
40
+ gridIndexes: number[] | 'all'
41
41
  }
42
42
 
43
43
  export interface MultiBarsParams extends BaseBarsParams {
44
- gridIndexes: number[]
44
+ gridIndexes: number[] | 'all'
45
45
  }
46
46
 
47
47
  export interface MultiBarStackParams extends BaseBarStackParams {
48
- gridIndexes: number[]
48
+ gridIndexes: number[] | 'all'
49
49
  }
50
50
 
51
51
  export interface MultiBarsTriangleParams extends BaseBarsTriangleParams {
52
- gridIndexes: number[]
52
+ gridIndexes: number[] | 'all'
53
53
  }
54
54
 
55
55
  export interface MultiLinesParams extends BaseLinesParams {
56
- gridIndexes: number[]
56
+ gridIndexes: number[] | 'all'
57
57
  }
58
58
 
59
59
  export interface MultiLineAreasParams extends BaseLineAreasParams {
60
- gridIndexes: number[]
60
+ gridIndexes: number[] | 'all'
61
61
  }
62
62
 
63
63
  export interface MultiDotsParams extends BaseDotsParams {
64
- gridIndexes: number[]
64
+ gridIndexes: number[] | 'all'
65
65
  }
66
66
 
67
67
  export interface OverlappingValueAxesParams {
@@ -62,3 +62,42 @@ export const TOOLTIP_PARAMS: TooltipParams = {
62
62
  },
63
63
  svgRenderFn: null
64
64
  }
65
+ TOOLTIP_PARAMS.textRenderFn.toString = () => `(eventData) => {
66
+ if (eventData.highlightTarget === 'datum' && eventData.datum) {
67
+ return [\`\${eventData.datum.label}: \${eventData.datum.value}\`]
68
+ } else if (eventData.highlightTarget === 'series') {
69
+ const label = (eventData as EventBaseSeriesValue<any, any>).seriesLabel
70
+ const valueArr = (eventData as EventBaseSeriesValue<any, any>).series
71
+ .filter(d => d.visible == true)
72
+ .map(d => {
73
+ return d.value
74
+ })
75
+ const value = valueArr.length > 5
76
+ ? valueArr.slice(0, 5).join(',') + '...'
77
+ : valueArr.join(',')
78
+ return [label, value]
79
+ } else if (eventData.highlightTarget === 'group') {
80
+ const label = (eventData as EventBaseGridValue<any, any>).groupLabel
81
+ const valueArr = (eventData as EventBaseGridValue<any, any>).series
82
+ .filter(d => d.visible == true)
83
+ .map(d => {
84
+ return d.value
85
+ })
86
+ const value = valueArr.length > 5
87
+ ? valueArr.slice(0, 5).join(',') + '...'
88
+ : valueArr.join(',')
89
+ return [label, value]
90
+ } else if (eventData.highlightTarget === 'category') {
91
+ const label = (eventData as EventBaseCategoryValue<any, any>).categoryLabel
92
+ const valueArr = (eventData as EventBaseCategoryValue<any, any>).category
93
+ .filter(d => d.visible == true)
94
+ .map(d => {
95
+ return d.value
96
+ })
97
+ const value = valueArr.length > 5
98
+ ? valueArr.slice(0, 5).join(',') + '...'
99
+ : valueArr.join(',')
100
+ return [label, value]
101
+ }
102
+ return []
103
+ }`
@@ -79,6 +79,22 @@ export const DEFAULT_PIE_EVENT_TEXTS_PARAMS: PieEventTextsParams = {
79
79
  }
80
80
  ]
81
81
  }
82
+ DEFAULT_PIE_EVENT_TEXTS_PARAMS.eventFn.toString = () => `(eventData: EventSeries, eventName: EventName, t: number) => {
83
+ if (eventName === 'mouseover' || eventName === 'mousemove') {
84
+ return [String(eventData.datum!.value)]
85
+ }
86
+ return [
87
+ String(
88
+ Math.round(
89
+ eventData.data.reduce((acc, seriesData) => {
90
+ return acc + seriesData.reduce((_acc, data) => {
91
+ return _acc + (data.value ?? 0)
92
+ }, 0)
93
+ }, 0) * t
94
+ )
95
+ )
96
+ ]
97
+ }`
82
98
 
83
99
  export const DEFAULT_PIE_LABELS_PARAMS: PieLabelsParams = {
84
100
  // solidColor: undefined,
@@ -94,6 +110,7 @@ export const DEFAULT_PIE_LABELS_PARAMS: PieLabelsParams = {
94
110
  labelColorType: 'primary',
95
111
  labelFn: d => String(d.label),
96
112
  }
113
+ DEFAULT_PIE_LABELS_PARAMS.labelFn.toString = () => `d => String(d.label)`
97
114
 
98
115
  export const DEFAULT_ROSE_PARAMS: RoseParams = {
99
116
  outerRadius: 0.95,
@@ -109,6 +126,7 @@ export const DEFAULT_ROSE_LABELS_PARAMS: RoseLabelsParams = {
109
126
  labelColorType: 'primary',
110
127
  arcScaleType: 'area'
111
128
  }
129
+ DEFAULT_ROSE_LABELS_PARAMS.labelFn.toString = () => `d => String(d.label)`
112
130
 
113
131
  export const DEFAULT_SERIES_LEGEND_PARAMS: SeriesLegendParams = {
114
132
  position: 'right',
@@ -7,6 +7,7 @@ export const DEFAULT_TREE_MAP_PARAMS: TreeMapParams = {
7
7
  squarifyRatio: 1.618034, // 黃金比例
8
8
  sort: (a, b) => b.value - a.value
9
9
  }
10
+ DEFAULT_TREE_MAP_PARAMS.sort.toString = () => `(a, b) => b.value - a.value`
10
11
 
11
12
  export const DEFAULT_TREE_LEGEND_PARAMS: TreeLegendParams = {
12
13
  position: 'right',