@react-fabric/chart 1.0.0-beta.55 → 1.0.0-beta.58
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/css/_chart.css +2 -2
- package/dist/cjs/charts/CountSeries.js +3 -3
- package/dist/cjs/charts/TimeSeries.js +1 -1
- package/dist/cjs/wrapper/ChartContainer.js +3 -0
- package/dist/esm/charts/CountSeries.js +3 -3
- package/dist/esm/charts/TimeSeries.js +1 -1
- package/dist/esm/wrapper/ChartContainer.js +3 -0
- package/dist/types/charts/Generic.d.ts +14 -39
- package/dist/types/types/index.d.ts +5 -5
- package/dist/types/wrapper/ChartContainer.d.ts +2 -2
- package/package.json +13 -16
- package/src/charts/ActivityMap.tsx +8 -4
- package/src/charts/CountSeries.tsx +6 -6
- package/src/charts/DataSeries.tsx +4 -4
- package/src/charts/Generic.tsx +19 -47
- package/src/charts/MapSeries.tsx +2 -2
- package/src/charts/TimeSeries.tsx +13 -8
- package/src/charts/TimeSlider.tsx +5 -5
- package/src/charts/WordBubble.tsx +3 -3
- package/src/types/index.ts +5 -5
- package/src/wrapper/ChartContainer.tsx +6 -2
package/css/_chart.css
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
.chartContainer {
|
|
24
|
+
.rf-chartContainer {
|
|
25
25
|
& > div:last-child:not(:first-child) > :last-child {
|
|
26
26
|
top: 0;
|
|
27
27
|
right: unset !important;
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
-
.chartToolbar {
|
|
41
|
+
.rf-chartToolbar {
|
|
42
42
|
input[type="range"] {
|
|
43
43
|
position: relative;
|
|
44
44
|
|
|
@@ -77,7 +77,7 @@ var CountSeriesChart = /*#__PURE__*/react.memo(function (_ref) {
|
|
|
77
77
|
}),
|
|
78
78
|
universalTransition: true
|
|
79
79
|
}] : sorted.map(function (item, index) {
|
|
80
|
-
var _item$
|
|
80
|
+
var _item$name2;
|
|
81
81
|
return {
|
|
82
82
|
id: item.id,
|
|
83
83
|
type: "bar",
|
|
@@ -92,7 +92,7 @@ var CountSeriesChart = /*#__PURE__*/react.memo(function (_ref) {
|
|
|
92
92
|
name: seriesName !== null && seriesName !== void 0 ? seriesName : "Count Series",
|
|
93
93
|
value: item.count
|
|
94
94
|
}],
|
|
95
|
-
name: (_item$
|
|
95
|
+
name: (_item$name2 = item.name) !== null && _item$name2 !== void 0 ? _item$name2 : item.id,
|
|
96
96
|
universalTransition: true
|
|
97
97
|
};
|
|
98
98
|
});
|
|
@@ -102,7 +102,7 @@ var CountSeriesChart = /*#__PURE__*/react.memo(function (_ref) {
|
|
|
102
102
|
xAxis: type === "pie" ? null : type === "bar" ? valueAxis : categoryAxis,
|
|
103
103
|
yAxis: type === "pie" ? null : type === "bar" ? categoryAxis : valueAxis
|
|
104
104
|
});
|
|
105
|
-
}, [_series,
|
|
105
|
+
}, [_series, seriesName, type, optionOverride], "CountChart options");
|
|
106
106
|
return /*#__PURE__*/jsxRuntime.jsxs(ChartContainer.ChartContainer, {
|
|
107
107
|
title: title,
|
|
108
108
|
onExport: onExport,
|
|
@@ -144,7 +144,7 @@ var TimeSeriesChart = /*#__PURE__*/react.memo(function (_ref) {
|
|
|
144
144
|
trigger: "axis",
|
|
145
145
|
confine: true,
|
|
146
146
|
position: "top",
|
|
147
|
-
|
|
147
|
+
appendTo: "body"
|
|
148
148
|
}, optionOverride === null || optionOverride === void 0 ? void 0 : optionOverride.tooltip),
|
|
149
149
|
xAxis: categoryAxis,
|
|
150
150
|
yAxis: valueAxis,
|
|
@@ -112,6 +112,9 @@ var ChartContainer = /*#__PURE__*/react.memo(function (_ref2) {
|
|
|
112
112
|
_chartRef.dispose();
|
|
113
113
|
};
|
|
114
114
|
}
|
|
115
|
+
}, []);
|
|
116
|
+
react.useEffect(function () {
|
|
117
|
+
chartRef === null || chartRef === void 0 || chartRef.setTheme(chartTheme);
|
|
115
118
|
}, [chartTheme]);
|
|
116
119
|
react.useEffect(function () {
|
|
117
120
|
var chart = chartRef;
|
|
@@ -77,7 +77,7 @@ var CountSeriesChart = /*#__PURE__*/memo(function (_ref) {
|
|
|
77
77
|
}),
|
|
78
78
|
universalTransition: true
|
|
79
79
|
}] : sorted.map(function (item, index) {
|
|
80
|
-
var _item$
|
|
80
|
+
var _item$name2;
|
|
81
81
|
return {
|
|
82
82
|
id: item.id,
|
|
83
83
|
type: "bar",
|
|
@@ -92,7 +92,7 @@ var CountSeriesChart = /*#__PURE__*/memo(function (_ref) {
|
|
|
92
92
|
name: seriesName !== null && seriesName !== void 0 ? seriesName : "Count Series",
|
|
93
93
|
value: item.count
|
|
94
94
|
}],
|
|
95
|
-
name: (_item$
|
|
95
|
+
name: (_item$name2 = item.name) !== null && _item$name2 !== void 0 ? _item$name2 : item.id,
|
|
96
96
|
universalTransition: true
|
|
97
97
|
};
|
|
98
98
|
});
|
|
@@ -102,7 +102,7 @@ var CountSeriesChart = /*#__PURE__*/memo(function (_ref) {
|
|
|
102
102
|
xAxis: type === "pie" ? null : type === "bar" ? valueAxis : categoryAxis,
|
|
103
103
|
yAxis: type === "pie" ? null : type === "bar" ? categoryAxis : valueAxis
|
|
104
104
|
});
|
|
105
|
-
}, [_series,
|
|
105
|
+
}, [_series, seriesName, type, optionOverride], "CountChart options");
|
|
106
106
|
return /*#__PURE__*/jsxs(ChartContainer, {
|
|
107
107
|
title: title,
|
|
108
108
|
onExport: onExport,
|
|
@@ -144,7 +144,7 @@ var TimeSeriesChart = /*#__PURE__*/memo(function (_ref) {
|
|
|
144
144
|
trigger: "axis",
|
|
145
145
|
confine: true,
|
|
146
146
|
position: "top",
|
|
147
|
-
|
|
147
|
+
appendTo: "body"
|
|
148
148
|
}, optionOverride === null || optionOverride === void 0 ? void 0 : optionOverride.tooltip),
|
|
149
149
|
xAxis: categoryAxis,
|
|
150
150
|
yAxis: valueAxis,
|
|
@@ -93,6 +93,9 @@ var ChartContainer = /*#__PURE__*/memo(function (_ref2) {
|
|
|
93
93
|
_chartRef.dispose();
|
|
94
94
|
};
|
|
95
95
|
}
|
|
96
|
+
}, []);
|
|
97
|
+
useEffect(function () {
|
|
98
|
+
chartRef === null || chartRef === void 0 || chartRef.setTheme(chartTheme);
|
|
96
99
|
}, [chartTheme]);
|
|
97
100
|
useEffect(function () {
|
|
98
101
|
var chart = chartRef;
|
|
@@ -1,48 +1,23 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type EChartsOption, type EChartsType } from "echarts";
|
|
2
2
|
import { type FC, type Ref } from "react";
|
|
3
|
-
import {
|
|
4
|
-
export interface GenericProps extends
|
|
3
|
+
import { Theme } from "../types";
|
|
4
|
+
export interface GenericProps extends Omit<EChartsOption, "title"> {
|
|
5
5
|
chartRef?: Ref<EChartsType>;
|
|
6
|
-
|
|
7
|
-
toolbox?: EChartOption["toolbox"];
|
|
8
|
-
tooltip?: EChartOption["tooltip"];
|
|
6
|
+
title?: string;
|
|
9
7
|
actions?: JSX.Element;
|
|
10
8
|
/**
|
|
11
|
-
*
|
|
9
|
+
* The theme to be applied to the chart.
|
|
10
|
+
* This can be one of the predefined themes or a custom theme object.
|
|
11
|
+
* Predefined themes include "default", "activity", "cloud", "qualitative", "diverging", "sequential",
|
|
12
|
+
* "spectral", "uber", "fireice", "warming", "sunrise", "ocean", "wine", "red", "green", and "blue".
|
|
12
13
|
*/
|
|
13
|
-
|
|
14
|
+
theme?: Theme;
|
|
14
15
|
/**
|
|
15
|
-
*
|
|
16
|
+
* Whether to show the theme selector in the chart.
|
|
17
|
+
* This is useful for allowing users to switch between different themes.
|
|
18
|
+
* If set to true, the chart will render a toggle button group to select the theme.
|
|
16
19
|
*/
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* chart series
|
|
20
|
-
*/
|
|
21
|
-
series?: EChartOption["series"];
|
|
22
|
-
/**
|
|
23
|
-
* polar series
|
|
24
|
-
*/
|
|
25
|
-
polar?: EChartOption["polar"];
|
|
26
|
-
/**
|
|
27
|
-
* polar axis
|
|
28
|
-
*/
|
|
29
|
-
angleAxis?: EChartOption["angleAxis"];
|
|
30
|
-
/**
|
|
31
|
-
* polar axis
|
|
32
|
-
*/
|
|
33
|
-
radiusAxis?: EChartOption["radiusAxis"];
|
|
34
|
-
/**
|
|
35
|
-
* radar series
|
|
36
|
-
*/
|
|
37
|
-
radar?: EChartOption["radar"];
|
|
38
|
-
/**
|
|
39
|
-
* paarllel series
|
|
40
|
-
*/
|
|
41
|
-
parallel?: EChartOption["parallel"];
|
|
42
|
-
/**
|
|
43
|
-
* parallel axis
|
|
44
|
-
*/
|
|
45
|
-
parallelAxis?: EChartOption["parallelAxis"];
|
|
20
|
+
showThemeSelector?: boolean;
|
|
46
21
|
onClick?: (e: KeyValue) => void;
|
|
47
22
|
onRendered?: (e: KeyValue) => void;
|
|
48
23
|
onBrush?: (e: KeyValue) => void;
|
|
@@ -51,7 +26,7 @@ export interface GenericProps extends BaseChart {
|
|
|
51
26
|
/**
|
|
52
27
|
* Data table renderer that returns HTML string
|
|
53
28
|
*/
|
|
54
|
-
dataTableRenderer?: (chartOption:
|
|
29
|
+
dataTableRenderer?: (chartOption: EChartsOption) => string;
|
|
55
30
|
}
|
|
56
31
|
/**
|
|
57
32
|
* GenericChart component renders a generic chart using ECharts.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { BarSeriesOption, PieSeriesOption, type EChartsOption } from "echarts";
|
|
2
2
|
export type Theme = "default" | "activity" | "cloud" | "qualitative" | "diverging" | "sequential" | "spectral" | "uber" | "fireice" | "warming" | "sunrise" | "ocean" | "wine" | "red" | "green" | "blue";
|
|
3
3
|
export interface BaseChart {
|
|
4
4
|
title?: string;
|
|
@@ -13,7 +13,7 @@ export interface BaseChart {
|
|
|
13
13
|
* Additional options for the chart.
|
|
14
14
|
* This can include any ECharts options to customize the chart's appearance and behavior.
|
|
15
15
|
*/
|
|
16
|
-
options?:
|
|
16
|
+
options?: EChartsOption;
|
|
17
17
|
/**
|
|
18
18
|
* Whether to show the theme selector in the chart.
|
|
19
19
|
* This is useful for allowing users to switch between different themes.
|
|
@@ -32,7 +32,7 @@ export interface BaseChart {
|
|
|
32
32
|
}) => void;
|
|
33
33
|
}
|
|
34
34
|
export interface CountType {
|
|
35
|
-
series: Array<
|
|
35
|
+
series: Array<PieSeriesOption & {
|
|
36
36
|
count: number;
|
|
37
37
|
}>;
|
|
38
38
|
}
|
|
@@ -41,14 +41,14 @@ export interface SeriesType {
|
|
|
41
41
|
valueAxisName?: string;
|
|
42
42
|
valueFormat?: string;
|
|
43
43
|
categories: string[];
|
|
44
|
-
series: Array<
|
|
44
|
+
series: Array<BarSeriesOption & {
|
|
45
45
|
data: number[];
|
|
46
46
|
}>;
|
|
47
47
|
}
|
|
48
48
|
export interface TimeSeriesType {
|
|
49
49
|
categoryAxisName?: string;
|
|
50
50
|
valueAxisName?: string;
|
|
51
|
-
series: Array<
|
|
51
|
+
series: Array<BarSeriesOption & {
|
|
52
52
|
data: Array<[Date, number]>;
|
|
53
53
|
}>;
|
|
54
54
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type EChartsOption, type EChartsType } from "echarts";
|
|
2
2
|
import "echarts-wordcloud";
|
|
3
3
|
import { type Ref } from "react";
|
|
4
4
|
import { type Theme } from "../types";
|
|
@@ -7,7 +7,7 @@ export declare const ChartContainer: import("react").MemoExoticComponent<({ them
|
|
|
7
7
|
theme?: Theme;
|
|
8
8
|
isEmpty?: boolean;
|
|
9
9
|
emptyIcon?: string;
|
|
10
|
-
options:
|
|
10
|
+
options: EChartsOption;
|
|
11
11
|
children?: AnyObject;
|
|
12
12
|
chartRef?: Ref<EChartsType>;
|
|
13
13
|
onClick?: (event: AnyObject) => void;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-fabric/chart",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.58",
|
|
4
4
|
"description": "RUF: Charting package",
|
|
5
5
|
"author": "Adarsh Pastakia <adarshpastakia@outlook.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -35,26 +35,23 @@
|
|
|
35
35
|
"watch": "npm-run-all -p watch:rollup watch:dts"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@react-fabric/core": "^1.0.0-beta.
|
|
39
|
-
"@react-fabric/utilities": "^1.0.0-beta.
|
|
40
|
-
"classnames": "
|
|
41
|
-
"color": "
|
|
42
|
-
"date-fns": "
|
|
43
|
-
"echarts": "
|
|
44
|
-
"echarts-wordcloud": "
|
|
38
|
+
"@react-fabric/core": "^1.0.0-beta.58",
|
|
39
|
+
"@react-fabric/utilities": "^1.0.0-beta.58",
|
|
40
|
+
"classnames": "~2.5.1",
|
|
41
|
+
"color": "~5.0.2",
|
|
42
|
+
"date-fns": "~4.1.0",
|
|
43
|
+
"echarts": "~6.0.0",
|
|
44
|
+
"echarts-wordcloud": "~2.1.0"
|
|
45
45
|
},
|
|
46
46
|
"peerDependencies": {
|
|
47
|
-
"i18next": "
|
|
48
|
-
"react": "
|
|
49
|
-
"react-dom": "
|
|
50
|
-
"react-i18next": "
|
|
51
|
-
},
|
|
52
|
-
"devDependencies": {
|
|
53
|
-
"@types/echarts": "^4.9.22"
|
|
47
|
+
"i18next": "~25.6.0",
|
|
48
|
+
"react": "~19.2.0",
|
|
49
|
+
"react-dom": "~19.2.0",
|
|
50
|
+
"react-i18next": "~16.2.1"
|
|
54
51
|
},
|
|
55
52
|
"engines": {
|
|
56
53
|
"node": ">=18.12.0",
|
|
57
54
|
"npm": ">=8.19.0"
|
|
58
55
|
},
|
|
59
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "7e66f8c498e37a40e410ecafff2ea6b31505dc1a"
|
|
60
57
|
}
|
|
@@ -29,7 +29,11 @@ import {
|
|
|
29
29
|
useMemoDebugger,
|
|
30
30
|
} from "@react-fabric/core";
|
|
31
31
|
import { isArray, isEmpty } from "@react-fabric/utilities";
|
|
32
|
-
import {
|
|
32
|
+
import {
|
|
33
|
+
type EChartsOption,
|
|
34
|
+
type EChartsType,
|
|
35
|
+
type ScatterSeriesOption,
|
|
36
|
+
} from "echarts";
|
|
33
37
|
import { memo, useEffect, useRef, useState, type FC } from "react";
|
|
34
38
|
import { type BaseChart } from "../types";
|
|
35
39
|
import { activityRenderer } from "../types/utils";
|
|
@@ -159,11 +163,11 @@ const ActivityMapChart = memo(
|
|
|
159
163
|
setTheme(chartTheme);
|
|
160
164
|
}, [chartTheme]);
|
|
161
165
|
|
|
162
|
-
const options = useMemoDebugger<
|
|
166
|
+
const options = useMemoDebugger<EChartsOption>(
|
|
163
167
|
() => {
|
|
164
168
|
const defaultMap = time === "day-hour" ? DAY_HOUR : MONTH_DAY;
|
|
165
169
|
|
|
166
|
-
const options:
|
|
170
|
+
const options: EChartsOption = {
|
|
167
171
|
series: [],
|
|
168
172
|
};
|
|
169
173
|
|
|
@@ -203,7 +207,7 @@ const ActivityMapChart = memo(
|
|
|
203
207
|
},
|
|
204
208
|
data: points,
|
|
205
209
|
universalTransition: true,
|
|
206
|
-
} as
|
|
210
|
+
} as ScatterSeriesOption;
|
|
207
211
|
});
|
|
208
212
|
|
|
209
213
|
if (type === "heatmap") {
|
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
useMemoDebugger,
|
|
30
30
|
} from "@react-fabric/core";
|
|
31
31
|
import { compareValues, Format, isEmpty } from "@react-fabric/utilities";
|
|
32
|
-
import { type
|
|
32
|
+
import { type EChartsOption, type EChartsType } from "echarts";
|
|
33
33
|
import { memo, useEffect, useRef, useState, type FC } from "react";
|
|
34
34
|
import { type BaseChart, type CountType } from "../types";
|
|
35
35
|
import { countRenderer } from "../types/utils";
|
|
@@ -67,7 +67,7 @@ const CountSeriesChart: FC<CountSeriesProps> = memo(
|
|
|
67
67
|
setTheme(chartTheme);
|
|
68
68
|
}, [chartTheme]);
|
|
69
69
|
|
|
70
|
-
const options = useMemoDebugger<
|
|
70
|
+
const options = useMemoDebugger<EChartsOption>(
|
|
71
71
|
() => {
|
|
72
72
|
if (isEmpty(_series)) {
|
|
73
73
|
chartRef.current?.clear();
|
|
@@ -87,14 +87,14 @@ const CountSeriesChart: FC<CountSeriesProps> = memo(
|
|
|
87
87
|
show: false,
|
|
88
88
|
},
|
|
89
89
|
data: [],
|
|
90
|
-
} as
|
|
90
|
+
} as EChartsOption["xAxis"],
|
|
91
91
|
);
|
|
92
92
|
const valueAxis: AnyObject = Object.assign({}, optionOverride?.yAxis, {
|
|
93
93
|
type: "value",
|
|
94
94
|
axisLabel: {
|
|
95
95
|
formatter: (val: AnyObject) => Format.number(val),
|
|
96
96
|
},
|
|
97
|
-
} as
|
|
97
|
+
} as EChartsOption["yAxis"]);
|
|
98
98
|
|
|
99
99
|
const series =
|
|
100
100
|
type === "pie"
|
|
@@ -126,7 +126,7 @@ const CountSeriesChart: FC<CountSeriesProps> = memo(
|
|
|
126
126
|
value: item.count,
|
|
127
127
|
},
|
|
128
128
|
],
|
|
129
|
-
name: item.
|
|
129
|
+
name: item.name ?? item.id,
|
|
130
130
|
universalTransition: true,
|
|
131
131
|
}));
|
|
132
132
|
return {
|
|
@@ -139,7 +139,7 @@ const CountSeriesChart: FC<CountSeriesProps> = memo(
|
|
|
139
139
|
type === "pie" ? null : type === "bar" ? categoryAxis : valueAxis,
|
|
140
140
|
};
|
|
141
141
|
},
|
|
142
|
-
[_series,
|
|
142
|
+
[_series, seriesName, type, optionOverride],
|
|
143
143
|
"CountChart options",
|
|
144
144
|
);
|
|
145
145
|
|
|
@@ -29,7 +29,7 @@ import {
|
|
|
29
29
|
useMemoDebugger,
|
|
30
30
|
} from "@react-fabric/core";
|
|
31
31
|
import { isEmpty } from "@react-fabric/utilities";
|
|
32
|
-
import { type
|
|
32
|
+
import { type EChartsOption, type EChartsType } from "echarts";
|
|
33
33
|
import { memo, useEffect, useRef, useState, type FC } from "react";
|
|
34
34
|
import { type BaseChart, type SeriesType } from "../types";
|
|
35
35
|
import { seriesRenderer } from "../types/utils";
|
|
@@ -75,7 +75,7 @@ const DataSeriesChart: FC<DataSeriesProps> = memo(
|
|
|
75
75
|
setTheme(chartTheme);
|
|
76
76
|
}, [chartTheme]);
|
|
77
77
|
|
|
78
|
-
const options = useMemoDebugger<
|
|
78
|
+
const options = useMemoDebugger<EChartsOption>(
|
|
79
79
|
() => {
|
|
80
80
|
if (isEmpty(_series)) {
|
|
81
81
|
chartRef.current?.clear();
|
|
@@ -99,7 +99,7 @@ const DataSeriesChart: FC<DataSeriesProps> = memo(
|
|
|
99
99
|
show: false,
|
|
100
100
|
},
|
|
101
101
|
data: categories,
|
|
102
|
-
} as
|
|
102
|
+
} as EChartsOption["xAxis"]),
|
|
103
103
|
);
|
|
104
104
|
const valueAxis: AnyObject = Object.assign(
|
|
105
105
|
{},
|
|
@@ -111,7 +111,7 @@ const DataSeriesChart: FC<DataSeriesProps> = memo(
|
|
|
111
111
|
type: "value",
|
|
112
112
|
nameGap: 32,
|
|
113
113
|
nameLocation: "center",
|
|
114
|
-
} as
|
|
114
|
+
} as EChartsOption["yAxis"]),
|
|
115
115
|
);
|
|
116
116
|
const radar =
|
|
117
117
|
_type !== "radar"
|
package/src/charts/Generic.tsx
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
import { type
|
|
24
|
+
import { type EChartsOption, type EChartsType } from "echarts";
|
|
25
25
|
import {
|
|
26
26
|
memo,
|
|
27
27
|
useEffect,
|
|
@@ -31,59 +31,31 @@ import {
|
|
|
31
31
|
type FC,
|
|
32
32
|
type Ref,
|
|
33
33
|
} from "react";
|
|
34
|
-
import {
|
|
34
|
+
import { Theme } from "../types";
|
|
35
35
|
import { ChartContainer } from "../wrapper/ChartContainer";
|
|
36
36
|
import { ChartWrapper } from "../wrapper/ChartWrapper";
|
|
37
37
|
import { PaletteSelect } from "../wrapper/PaletteSelect";
|
|
38
38
|
|
|
39
|
-
export interface GenericProps extends
|
|
39
|
+
export interface GenericProps extends Omit<EChartsOption, "title"> {
|
|
40
40
|
chartRef?: Ref<EChartsType>;
|
|
41
41
|
|
|
42
|
-
|
|
43
|
-
toolbox?: EChartOption["toolbox"];
|
|
44
|
-
tooltip?: EChartOption["tooltip"];
|
|
42
|
+
title?: string;
|
|
45
43
|
|
|
46
44
|
actions?: JSX.Element;
|
|
47
45
|
|
|
48
46
|
/**
|
|
49
|
-
*
|
|
47
|
+
* The theme to be applied to the chart.
|
|
48
|
+
* This can be one of the predefined themes or a custom theme object.
|
|
49
|
+
* Predefined themes include "default", "activity", "cloud", "qualitative", "diverging", "sequential",
|
|
50
|
+
* "spectral", "uber", "fireice", "warming", "sunrise", "ocean", "wine", "red", "green", and "blue".
|
|
50
51
|
*/
|
|
51
|
-
|
|
52
|
+
theme?: Theme;
|
|
52
53
|
/**
|
|
53
|
-
*
|
|
54
|
+
* Whether to show the theme selector in the chart.
|
|
55
|
+
* This is useful for allowing users to switch between different themes.
|
|
56
|
+
* If set to true, the chart will render a toggle button group to select the theme.
|
|
54
57
|
*/
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* chart series
|
|
58
|
-
*/
|
|
59
|
-
series?: EChartOption["series"];
|
|
60
|
-
|
|
61
|
-
/**
|
|
62
|
-
* polar series
|
|
63
|
-
*/
|
|
64
|
-
polar?: EChartOption["polar"];
|
|
65
|
-
/**
|
|
66
|
-
* polar axis
|
|
67
|
-
*/
|
|
68
|
-
angleAxis?: EChartOption["angleAxis"];
|
|
69
|
-
/**
|
|
70
|
-
* polar axis
|
|
71
|
-
*/
|
|
72
|
-
radiusAxis?: EChartOption["radiusAxis"];
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* radar series
|
|
76
|
-
*/
|
|
77
|
-
radar?: EChartOption["radar"];
|
|
78
|
-
|
|
79
|
-
/**
|
|
80
|
-
* paarllel series
|
|
81
|
-
*/
|
|
82
|
-
parallel?: EChartOption["parallel"];
|
|
83
|
-
/**
|
|
84
|
-
* parallel axis
|
|
85
|
-
*/
|
|
86
|
-
parallelAxis?: EChartOption["parallelAxis"];
|
|
58
|
+
showThemeSelector?: boolean;
|
|
87
59
|
|
|
88
60
|
onClick?: (e: KeyValue) => void;
|
|
89
61
|
onRendered?: (e: KeyValue) => void;
|
|
@@ -95,7 +67,7 @@ export interface GenericProps extends BaseChart {
|
|
|
95
67
|
/**
|
|
96
68
|
* Data table renderer that returns HTML string
|
|
97
69
|
*/
|
|
98
|
-
dataTableRenderer?: (chartOption:
|
|
70
|
+
dataTableRenderer?: (chartOption: EChartsOption) => string;
|
|
99
71
|
}
|
|
100
72
|
|
|
101
73
|
const GenericChartBase = memo(
|
|
@@ -112,7 +84,7 @@ const GenericChartBase = memo(
|
|
|
112
84
|
title,
|
|
113
85
|
theme: chartTheme,
|
|
114
86
|
...options
|
|
115
|
-
}:
|
|
87
|
+
}: GenericProps) => {
|
|
116
88
|
const chartRef = useRef<EChartsType>(null);
|
|
117
89
|
const [theme, setTheme] = useState(chartTheme);
|
|
118
90
|
|
|
@@ -125,7 +97,7 @@ const GenericChartBase = memo(
|
|
|
125
97
|
useEffect(() => {
|
|
126
98
|
const chart = chartRef.current;
|
|
127
99
|
if (chart && onRendered) {
|
|
128
|
-
chart.on("finished", onRendered);
|
|
100
|
+
chart.on("finished", onRendered as any);
|
|
129
101
|
return () => {
|
|
130
102
|
!chart.isDisposed() && chart.off("finished");
|
|
131
103
|
};
|
|
@@ -145,7 +117,7 @@ const GenericChartBase = memo(
|
|
|
145
117
|
useEffect(() => {
|
|
146
118
|
const chart = chartRef.current;
|
|
147
119
|
if (chart && onBrush) {
|
|
148
|
-
chart.on("brush", onBrush);
|
|
120
|
+
chart.on("brush", onBrush as any);
|
|
149
121
|
return () => {
|
|
150
122
|
!chart.isDisposed() && chart.off("brush");
|
|
151
123
|
};
|
|
@@ -155,7 +127,7 @@ const GenericChartBase = memo(
|
|
|
155
127
|
useEffect(() => {
|
|
156
128
|
const chart = chartRef.current;
|
|
157
129
|
if (chart && onBrushEnd) {
|
|
158
|
-
chart.on("brushend", onBrushEnd);
|
|
130
|
+
chart.on("brushend", onBrushEnd as any);
|
|
159
131
|
return () => {
|
|
160
132
|
!chart.isDisposed() && chart.off("brushend");
|
|
161
133
|
};
|
|
@@ -165,7 +137,7 @@ const GenericChartBase = memo(
|
|
|
165
137
|
useEffect(() => {
|
|
166
138
|
const chart = chartRef.current;
|
|
167
139
|
if (chart && onBrushSelected) {
|
|
168
|
-
chart.on("brushselected", onBrushSelected);
|
|
140
|
+
chart.on("brushselected", onBrushSelected as any);
|
|
169
141
|
return () => {
|
|
170
142
|
!chart.isDisposed() && chart.off("brushselected");
|
|
171
143
|
};
|
package/src/charts/MapSeries.tsx
CHANGED
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
isEmpty,
|
|
29
29
|
} from "@react-fabric/utilities";
|
|
30
30
|
import * as echarts from "echarts";
|
|
31
|
-
import { type
|
|
31
|
+
import { type EChartsOption, type EChartsType } from "echarts";
|
|
32
32
|
import { memo, useEffect, useRef, useState, type FC } from "react";
|
|
33
33
|
import { ChartPalette } from "../theme/palettes";
|
|
34
34
|
import { type BaseChart, type CountType } from "../types";
|
|
@@ -63,7 +63,7 @@ const MapSeriesChart: FC<MapSeriesProps> = memo(
|
|
|
63
63
|
const [type, setType] = useState("map");
|
|
64
64
|
const [zoom, setZoom] = useState(1.25);
|
|
65
65
|
|
|
66
|
-
const options = useMemoDebugger<
|
|
66
|
+
const options = useMemoDebugger<EChartsOption>(
|
|
67
67
|
() => {
|
|
68
68
|
if (isEmpty(series)) return {};
|
|
69
69
|
|
|
@@ -29,7 +29,12 @@ import {
|
|
|
29
29
|
useMemoDebugger,
|
|
30
30
|
} from "@react-fabric/core";
|
|
31
31
|
import { isEmpty } from "@react-fabric/utilities";
|
|
32
|
-
import {
|
|
32
|
+
import {
|
|
33
|
+
ECElementEvent,
|
|
34
|
+
ECharts,
|
|
35
|
+
type EChartsOption,
|
|
36
|
+
type EChartsType,
|
|
37
|
+
} from "echarts";
|
|
33
38
|
import { memo, useCallback, useEffect, useRef, useState, type FC } from "react";
|
|
34
39
|
import { type BaseChart, type TimeSeriesType } from "../types";
|
|
35
40
|
import { timeSeriesRenderer } from "../types/utils";
|
|
@@ -58,7 +63,7 @@ const TimeSeriesChart: FC<TimeSeriesProps> = memo(
|
|
|
58
63
|
onClick,
|
|
59
64
|
onBrush,
|
|
60
65
|
}: TimeSeriesProps) => {
|
|
61
|
-
const chartRef = useRef<
|
|
66
|
+
const chartRef = useRef<ECharts>(null);
|
|
62
67
|
const [type, setType] = useState(chartType);
|
|
63
68
|
const [theme, setTheme] = useState(chartTheme);
|
|
64
69
|
|
|
@@ -93,7 +98,7 @@ const TimeSeriesChart: FC<TimeSeriesProps> = memo(
|
|
|
93
98
|
if (chart && !chart?.isDisposed()) {
|
|
94
99
|
enableBrush();
|
|
95
100
|
let range = [0, 0];
|
|
96
|
-
chart.on("brushselected", (e:
|
|
101
|
+
chart.on("brushselected", (e: any) => {
|
|
97
102
|
range = e.batch?.[0]?.areas?.[0]?.coordRange;
|
|
98
103
|
});
|
|
99
104
|
chart.on("brushEnd", () => {
|
|
@@ -107,7 +112,7 @@ const TimeSeriesChart: FC<TimeSeriesProps> = memo(
|
|
|
107
112
|
}
|
|
108
113
|
}, [chartRef.current, onBrush]);
|
|
109
114
|
|
|
110
|
-
const options = useMemoDebugger<
|
|
115
|
+
const options = useMemoDebugger<EChartsOption>(
|
|
111
116
|
() => {
|
|
112
117
|
if (isEmpty(_series)) {
|
|
113
118
|
chartRef.current?.clear();
|
|
@@ -140,14 +145,14 @@ const TimeSeriesChart: FC<TimeSeriesProps> = memo(
|
|
|
140
145
|
none: "{yyyy}-{MM}-{dd} {hh}:{mm}:{ss} {SSS}",
|
|
141
146
|
} as AnyObject,
|
|
142
147
|
},
|
|
143
|
-
} as
|
|
148
|
+
} as EChartsOption["xAxis"],
|
|
144
149
|
);
|
|
145
150
|
const valueAxis: AnyObject = Object.assign({}, optionOverride?.yAxis, {
|
|
146
151
|
name: valueAxisName,
|
|
147
152
|
type: "value",
|
|
148
153
|
nameGap: 32,
|
|
149
154
|
nameLocation: "center",
|
|
150
|
-
} as
|
|
155
|
+
} as EChartsOption["yAxis"]);
|
|
151
156
|
|
|
152
157
|
const series = _series?.map(
|
|
153
158
|
(item) =>
|
|
@@ -174,8 +179,8 @@ const TimeSeriesChart: FC<TimeSeriesProps> = memo(
|
|
|
174
179
|
trigger: "axis",
|
|
175
180
|
confine: true,
|
|
176
181
|
position: "top",
|
|
177
|
-
|
|
178
|
-
}
|
|
182
|
+
appendTo: "body",
|
|
183
|
+
},
|
|
179
184
|
optionOverride?.tooltip,
|
|
180
185
|
),
|
|
181
186
|
xAxis: categoryAxis,
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
} from "@react-fabric/core";
|
|
29
29
|
import { isEmpty } from "@react-fabric/utilities";
|
|
30
30
|
import { endOfDay, startOfDay } from "date-fns";
|
|
31
|
-
import { type
|
|
31
|
+
import { type EChartsOption, type EChartsType } from "echarts";
|
|
32
32
|
import { memo, useCallback, useEffect, useRef, useState, type FC } from "react";
|
|
33
33
|
import { type BaseChart } from "../types";
|
|
34
34
|
import { ChartContainer } from "../wrapper/ChartContainer";
|
|
@@ -86,7 +86,7 @@ const TimeSliderChart: FC<TimeSliderProps> = memo(
|
|
|
86
86
|
if (chart && !chart?.isDisposed()) {
|
|
87
87
|
enableBrush();
|
|
88
88
|
chart.on("datazoom", () => {
|
|
89
|
-
const zoom = chart.getOption().dataZoom?.[0];
|
|
89
|
+
const zoom = (chart.getOption().dataZoom as any)?.[0];
|
|
90
90
|
if (zoom) {
|
|
91
91
|
const startValue = Math.floor(zoom.startValue as number);
|
|
92
92
|
const endValue = Math.ceil(
|
|
@@ -108,7 +108,7 @@ const TimeSliderChart: FC<TimeSliderProps> = memo(
|
|
|
108
108
|
"TimeSldier onBrush",
|
|
109
109
|
);
|
|
110
110
|
|
|
111
|
-
const options = useMemoDebugger<
|
|
111
|
+
const options = useMemoDebugger<EChartsOption>(
|
|
112
112
|
() => {
|
|
113
113
|
if (isEmpty(dataSeries)) {
|
|
114
114
|
chartRef.current?.clear();
|
|
@@ -129,7 +129,7 @@ const TimeSliderChart: FC<TimeSliderProps> = memo(
|
|
|
129
129
|
show: false,
|
|
130
130
|
},
|
|
131
131
|
position: "bottom",
|
|
132
|
-
} as
|
|
132
|
+
} as EChartsOption["xAxis"];
|
|
133
133
|
const valueAxis: AnyObject = {
|
|
134
134
|
type: "value",
|
|
135
135
|
nameGap: 24,
|
|
@@ -146,7 +146,7 @@ const TimeSliderChart: FC<TimeSliderProps> = memo(
|
|
|
146
146
|
show: false,
|
|
147
147
|
},
|
|
148
148
|
nameLocation: "center",
|
|
149
|
-
} as
|
|
149
|
+
} as EChartsOption["yAxis"];
|
|
150
150
|
|
|
151
151
|
const series = [
|
|
152
152
|
{
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
|
|
24
24
|
import { CoreIcons, useIsDark, useMemoDebugger } from "@react-fabric/core";
|
|
25
25
|
import { compareValues, isEmpty } from "@react-fabric/utilities";
|
|
26
|
-
import { type
|
|
26
|
+
import { type EChartsOption } from "echarts";
|
|
27
27
|
import { memo, type FC } from "react";
|
|
28
28
|
import { ChartPalette } from "../theme/palettes";
|
|
29
29
|
import { type BaseChart } from "../types";
|
|
@@ -40,7 +40,7 @@ const WordBubbleChart: FC<WordBubbleProps> = memo(
|
|
|
40
40
|
({ series, title, onExport, onClick }: WordBubbleProps) => {
|
|
41
41
|
const isDark = useIsDark();
|
|
42
42
|
|
|
43
|
-
const options = useMemoDebugger<
|
|
43
|
+
const options = useMemoDebugger<EChartsOption>(
|
|
44
44
|
() => {
|
|
45
45
|
if (isEmpty(series)) return {};
|
|
46
46
|
|
|
@@ -55,7 +55,7 @@ const WordBubbleChart: FC<WordBubbleProps> = memo(
|
|
|
55
55
|
confine: true,
|
|
56
56
|
position: "top",
|
|
57
57
|
appendToBody: true,
|
|
58
|
-
} as
|
|
58
|
+
} as EChartsOption["tooltip"],
|
|
59
59
|
series: [
|
|
60
60
|
{
|
|
61
61
|
name: title,
|
package/src/types/index.ts
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
22
22
|
*/
|
|
23
23
|
|
|
24
|
-
import { type
|
|
24
|
+
import { BarSeriesOption, PieSeriesOption, type EChartsOption } from "echarts";
|
|
25
25
|
|
|
26
26
|
export type Theme =
|
|
27
27
|
| "default"
|
|
@@ -54,7 +54,7 @@ export interface BaseChart {
|
|
|
54
54
|
* Additional options for the chart.
|
|
55
55
|
* This can include any ECharts options to customize the chart's appearance and behavior.
|
|
56
56
|
*/
|
|
57
|
-
options?:
|
|
57
|
+
options?: EChartsOption;
|
|
58
58
|
/**
|
|
59
59
|
* Whether to show the theme selector in the chart.
|
|
60
60
|
* This is useful for allowing users to switch between different themes.
|
|
@@ -71,7 +71,7 @@ export interface BaseChart {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
export interface CountType {
|
|
74
|
-
series: Array<
|
|
74
|
+
series: Array<PieSeriesOption & { count: number }>;
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
export interface SeriesType {
|
|
@@ -80,7 +80,7 @@ export interface SeriesType {
|
|
|
80
80
|
valueFormat?: string;
|
|
81
81
|
categories: string[];
|
|
82
82
|
series: Array<
|
|
83
|
-
|
|
83
|
+
BarSeriesOption & {
|
|
84
84
|
data: number[];
|
|
85
85
|
}
|
|
86
86
|
>;
|
|
@@ -90,7 +90,7 @@ export interface TimeSeriesType {
|
|
|
90
90
|
categoryAxisName?: string;
|
|
91
91
|
valueAxisName?: string;
|
|
92
92
|
series: Array<
|
|
93
|
-
|
|
93
|
+
BarSeriesOption & {
|
|
94
94
|
data: Array<[Date, number]>;
|
|
95
95
|
}
|
|
96
96
|
>;
|
|
@@ -31,7 +31,7 @@ import {
|
|
|
31
31
|
} from "@react-fabric/core";
|
|
32
32
|
import { type SizeObject } from "@react-fabric/core/dist/types/types";
|
|
33
33
|
import classNames from "classnames";
|
|
34
|
-
import { type
|
|
34
|
+
import { type EChartsOption, type EChartsType } from "echarts";
|
|
35
35
|
import "echarts-wordcloud";
|
|
36
36
|
import {
|
|
37
37
|
Fragment,
|
|
@@ -96,7 +96,7 @@ export const ChartContainer = memo(
|
|
|
96
96
|
theme?: Theme;
|
|
97
97
|
isEmpty?: boolean;
|
|
98
98
|
emptyIcon?: string;
|
|
99
|
-
options:
|
|
99
|
+
options: EChartsOption;
|
|
100
100
|
children?: AnyObject;
|
|
101
101
|
chartRef?: Ref<EChartsType>;
|
|
102
102
|
onClick?: (event: AnyObject) => void;
|
|
@@ -140,6 +140,10 @@ export const ChartContainer = memo(
|
|
|
140
140
|
chartRef.dispose();
|
|
141
141
|
};
|
|
142
142
|
}
|
|
143
|
+
}, []);
|
|
144
|
+
|
|
145
|
+
useEffect(() => {
|
|
146
|
+
chartRef?.setTheme(chartTheme);
|
|
143
147
|
}, [chartTheme]);
|
|
144
148
|
|
|
145
149
|
useEffect(() => {
|