deepsea-components 5.17.5 → 5.17.6
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/components/Echart.cjs +124 -13
- package/dist/components/Echart.d.ts +56 -11
- package/dist/components/Echart.js +51 -13
- package/package.json +2 -1
- package/src/components/Echart.tsx +205 -32
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
"use strict";
|
|
3
3
|
var __webpack_require__ = {};
|
|
4
|
+
(()=>{
|
|
5
|
+
__webpack_require__.n = (module)=>{
|
|
6
|
+
var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
|
|
7
|
+
__webpack_require__.d(getter, {
|
|
8
|
+
a: getter
|
|
9
|
+
});
|
|
10
|
+
return getter;
|
|
11
|
+
};
|
|
12
|
+
})();
|
|
4
13
|
(()=>{
|
|
5
14
|
__webpack_require__.d = (exports1, definition)=>{
|
|
6
15
|
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
@@ -25,53 +34,155 @@ var __webpack_require__ = {};
|
|
|
25
34
|
var __webpack_exports__ = {};
|
|
26
35
|
__webpack_require__.r(__webpack_exports__);
|
|
27
36
|
__webpack_require__.d(__webpack_exports__, {
|
|
37
|
+
Candlestick: ()=>Candlestick,
|
|
28
38
|
Pie: ()=>Pie,
|
|
39
|
+
Gauge: ()=>Gauge,
|
|
29
40
|
Line: ()=>Line,
|
|
30
|
-
|
|
41
|
+
Parallel: ()=>Parallel,
|
|
42
|
+
Bar: ()=>Bar,
|
|
43
|
+
Scatter: ()=>Scatter,
|
|
44
|
+
Custom: ()=>Custom,
|
|
45
|
+
EffectScatter: ()=>EffectScatter,
|
|
46
|
+
Radar: ()=>Radar,
|
|
47
|
+
Sunburst: ()=>Sunburst,
|
|
48
|
+
ThemeRiver: ()=>ThemeRiver,
|
|
49
|
+
Chord: ()=>Chord,
|
|
50
|
+
Heatmap: ()=>Heatmap,
|
|
51
|
+
Echart: ()=>Echart,
|
|
52
|
+
Map: ()=>Map,
|
|
53
|
+
Tree: ()=>Tree,
|
|
54
|
+
Treemap: ()=>Treemap,
|
|
55
|
+
PictorialBar: ()=>PictorialBar,
|
|
56
|
+
Sankey: ()=>Sankey,
|
|
57
|
+
Lines: ()=>Lines,
|
|
58
|
+
Funnel: ()=>Funnel,
|
|
59
|
+
Graph: ()=>Graph,
|
|
60
|
+
Boxplot: ()=>Boxplot
|
|
31
61
|
});
|
|
32
62
|
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
33
63
|
const external_react_namespaceObject = require("react");
|
|
34
64
|
const external_echarts_namespaceObject = require("echarts");
|
|
35
|
-
const
|
|
36
|
-
|
|
65
|
+
const external_stable_hash_namespaceObject = require("stable-hash");
|
|
66
|
+
var external_stable_hash_default = /*#__PURE__*/ __webpack_require__.n(external_stable_hash_namespaceObject);
|
|
67
|
+
function Echart({ ref, width, height, locale, init: initOption, option, chart, ...rest }) {
|
|
37
68
|
const container = (0, external_react_namespaceObject.useRef)(null);
|
|
38
69
|
const chartRef = (0, external_react_namespaceObject.useRef)(null);
|
|
39
70
|
(0, external_react_namespaceObject.useLayoutEffect)(()=>{
|
|
40
71
|
const ele = container.current;
|
|
41
72
|
chartRef.current = (0, external_echarts_namespaceObject.init)(ele, option, {
|
|
73
|
+
...initOption,
|
|
42
74
|
width,
|
|
43
|
-
height
|
|
75
|
+
height,
|
|
76
|
+
locale
|
|
44
77
|
});
|
|
45
78
|
return ()=>{
|
|
46
79
|
var _chartRef_current;
|
|
47
80
|
return null == (_chartRef_current = chartRef.current) ? void 0 : _chartRef_current.dispose();
|
|
48
81
|
};
|
|
49
82
|
}, []);
|
|
50
|
-
(0, external_react_namespaceObject.useImperativeHandle)(ref, ()=>container.current
|
|
51
|
-
(0, external_react_namespaceObject.useImperativeHandle)(chart, ()=>chartRef.current
|
|
83
|
+
(0, external_react_namespaceObject.useImperativeHandle)(ref, ()=>container.current);
|
|
84
|
+
(0, external_react_namespaceObject.useImperativeHandle)(chart, ()=>chartRef.current);
|
|
85
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
86
|
+
var _chartRef_current;
|
|
87
|
+
return null == (_chartRef_current = chartRef.current) ? void 0 : _chartRef_current.setOption(option);
|
|
88
|
+
}, [
|
|
89
|
+
external_stable_hash_default()(option)
|
|
90
|
+
]);
|
|
52
91
|
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
53
|
-
var _chartRef_current
|
|
54
|
-
null == (_chartRef_current = chartRef.current)
|
|
55
|
-
null == (_chartRef_current1 = chartRef.current) || _chartRef_current1.resize({
|
|
92
|
+
var _chartRef_current;
|
|
93
|
+
return null == (_chartRef_current = chartRef.current) ? void 0 : _chartRef_current.resize({
|
|
56
94
|
width,
|
|
57
95
|
height
|
|
58
96
|
});
|
|
59
|
-
}
|
|
97
|
+
}, [
|
|
98
|
+
width,
|
|
99
|
+
height
|
|
100
|
+
]);
|
|
101
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
102
|
+
var _chartRef_current;
|
|
103
|
+
return null == (_chartRef_current = chartRef.current) ? void 0 : _chartRef_current.setOption({
|
|
104
|
+
locale
|
|
105
|
+
});
|
|
106
|
+
}, [
|
|
107
|
+
locale
|
|
108
|
+
]);
|
|
60
109
|
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)("div", {
|
|
61
110
|
ref: container,
|
|
62
111
|
...rest
|
|
63
112
|
});
|
|
64
|
-
}
|
|
65
|
-
const Pie = Echart;
|
|
113
|
+
}
|
|
66
114
|
const Bar = Echart;
|
|
115
|
+
const Boxplot = Echart;
|
|
116
|
+
const Candlestick = Echart;
|
|
117
|
+
const Chord = Echart;
|
|
118
|
+
const Custom = Echart;
|
|
119
|
+
const EffectScatter = Echart;
|
|
120
|
+
const Funnel = Echart;
|
|
121
|
+
const Gauge = Echart;
|
|
122
|
+
const Graph = Echart;
|
|
123
|
+
const Heatmap = Echart;
|
|
67
124
|
const Line = Echart;
|
|
125
|
+
const Lines = Echart;
|
|
126
|
+
const Map = Echart;
|
|
127
|
+
const Parallel = Echart;
|
|
128
|
+
const PictorialBar = Echart;
|
|
129
|
+
const Pie = Echart;
|
|
130
|
+
const Radar = Echart;
|
|
131
|
+
const Sankey = Echart;
|
|
132
|
+
const Scatter = Echart;
|
|
133
|
+
const Sunburst = Echart;
|
|
134
|
+
const ThemeRiver = Echart;
|
|
135
|
+
const Tree = Echart;
|
|
136
|
+
const Treemap = Echart;
|
|
68
137
|
exports.Bar = __webpack_exports__.Bar;
|
|
138
|
+
exports.Boxplot = __webpack_exports__.Boxplot;
|
|
139
|
+
exports.Candlestick = __webpack_exports__.Candlestick;
|
|
140
|
+
exports.Chord = __webpack_exports__.Chord;
|
|
141
|
+
exports.Custom = __webpack_exports__.Custom;
|
|
142
|
+
exports.Echart = __webpack_exports__.Echart;
|
|
143
|
+
exports.EffectScatter = __webpack_exports__.EffectScatter;
|
|
144
|
+
exports.Funnel = __webpack_exports__.Funnel;
|
|
145
|
+
exports.Gauge = __webpack_exports__.Gauge;
|
|
146
|
+
exports.Graph = __webpack_exports__.Graph;
|
|
147
|
+
exports.Heatmap = __webpack_exports__.Heatmap;
|
|
69
148
|
exports.Line = __webpack_exports__.Line;
|
|
149
|
+
exports.Lines = __webpack_exports__.Lines;
|
|
150
|
+
exports.Map = __webpack_exports__.Map;
|
|
151
|
+
exports.Parallel = __webpack_exports__.Parallel;
|
|
152
|
+
exports.PictorialBar = __webpack_exports__.PictorialBar;
|
|
70
153
|
exports.Pie = __webpack_exports__.Pie;
|
|
154
|
+
exports.Radar = __webpack_exports__.Radar;
|
|
155
|
+
exports.Sankey = __webpack_exports__.Sankey;
|
|
156
|
+
exports.Scatter = __webpack_exports__.Scatter;
|
|
157
|
+
exports.Sunburst = __webpack_exports__.Sunburst;
|
|
158
|
+
exports.ThemeRiver = __webpack_exports__.ThemeRiver;
|
|
159
|
+
exports.Tree = __webpack_exports__.Tree;
|
|
160
|
+
exports.Treemap = __webpack_exports__.Treemap;
|
|
71
161
|
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
72
162
|
"Bar",
|
|
163
|
+
"Boxplot",
|
|
164
|
+
"Candlestick",
|
|
165
|
+
"Chord",
|
|
166
|
+
"Custom",
|
|
167
|
+
"Echart",
|
|
168
|
+
"EffectScatter",
|
|
169
|
+
"Funnel",
|
|
170
|
+
"Gauge",
|
|
171
|
+
"Graph",
|
|
172
|
+
"Heatmap",
|
|
73
173
|
"Line",
|
|
74
|
-
"
|
|
174
|
+
"Lines",
|
|
175
|
+
"Map",
|
|
176
|
+
"Parallel",
|
|
177
|
+
"PictorialBar",
|
|
178
|
+
"Pie",
|
|
179
|
+
"Radar",
|
|
180
|
+
"Sankey",
|
|
181
|
+
"Scatter",
|
|
182
|
+
"Sunburst",
|
|
183
|
+
"ThemeRiver",
|
|
184
|
+
"Tree",
|
|
185
|
+
"Treemap"
|
|
75
186
|
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
76
187
|
Object.defineProperty(exports, '__esModule', {
|
|
77
188
|
value: true
|
|
@@ -1,15 +1,60 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { BarSeriesOption, ComposeOption, DatasetComponentOption, ECharts, GridComponentOption, LineSeriesOption, PieSeriesOption, TitleComponentOption, TooltipComponentOption } from "echarts";
|
|
3
|
-
|
|
4
|
-
export type
|
|
5
|
-
export type
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { ComponentProps, FC, ReactNode, Ref } from "react";
|
|
2
|
+
import { AngleAxisComponentOption, AriaComponentOption, AxisPointerComponentOption, BarSeriesOption, BoxplotSeriesOption, BrushComponentOption, CalendarComponentOption, CandlestickSeriesOption, ChordSeriesOption, ComposeOption, ContinousVisualMapComponentOption, CustomSeriesOption, DataZoomComponentOption, DatasetComponentOption, ECharts, EChartsInitOpts, EffectScatterSeriesOption, FunnelSeriesOption, GaugeSeriesOption, GeoComponentOption, GraphSeriesOption, GraphicComponentOption, GridComponentOption, HeatmapSeriesOption, InsideDataZoomComponentOption, LegendComponentOption, LineSeriesOption, LinesSeriesOption, MapSeriesOption, MarkAreaComponentOption, MarkLineComponentOption, MarkPointComponentOption, MatrixComponentOption, ParallelSeriesOption, PictorialBarSeriesOption, PieSeriesOption, PiecewiseVisualMapComponentOption, PlainLegendComponentOption, PolarComponentOption, RadarComponentOption, RadarSeriesOption, RadiusAxisComponentOption, SankeySeriesOption, ScatterSeriesOption, ScrollableLegendComponentOption, SeriesOption, SingleAxisComponentOption, SliderDataZoomComponentOption, SunburstSeriesOption, ThemeRiverSeriesOption, ThumbnailComponentOption, TimelineComponentOption, TitleComponentOption, ToolboxComponentOption, TooltipComponentOption, TreeSeriesOption, TreemapSeriesOption, VisualMapComponentOption, XAXisComponentOption, YAXisComponentOption } from "echarts";
|
|
3
|
+
import { ECBasicOption } from "echarts/types/src/util/types.js";
|
|
4
|
+
export type ChartOption<T extends SeriesOption = never> = ComposeOption<T | DatasetComponentOption | GridComponentOption | LegendComponentOption | TitleComponentOption | TooltipComponentOption | AxisPointerComponentOption | GeoComponentOption | MarkLineComponentOption | MarkPointComponentOption | MarkAreaComponentOption | DataZoomComponentOption | AriaComponentOption | BrushComponentOption | PolarComponentOption | RadarComponentOption | XAXisComponentOption | YAXisComponentOption | MatrixComponentOption | GraphicComponentOption | ToolboxComponentOption | CalendarComponentOption | TimelineComponentOption | AngleAxisComponentOption | RadiusAxisComponentOption | SingleAxisComponentOption | VisualMapComponentOption | ThumbnailComponentOption | PlainLegendComponentOption | InsideDataZoomComponentOption | SliderDataZoomComponentOption | PiecewiseVisualMapComponentOption | ContinousVisualMapComponentOption | ScrollableLegendComponentOption>;
|
|
5
|
+
export type BarOption = ChartOption<BarSeriesOption>;
|
|
6
|
+
export type BoxplotOption = ChartOption<BoxplotSeriesOption>;
|
|
7
|
+
export type CandlestickOption = ChartOption<CandlestickSeriesOption>;
|
|
8
|
+
export type ChordOption = ChartOption<ChordSeriesOption>;
|
|
9
|
+
export type CustomOption = ChartOption<CustomSeriesOption>;
|
|
10
|
+
export type EffectScatterOption = ChartOption<EffectScatterSeriesOption>;
|
|
11
|
+
export type FunnelOption = ChartOption<FunnelSeriesOption>;
|
|
12
|
+
export type GaugeOption = ChartOption<GaugeSeriesOption>;
|
|
13
|
+
export type GraphOption = ChartOption<GraphSeriesOption>;
|
|
14
|
+
export type HeatmapOption = ChartOption<HeatmapSeriesOption>;
|
|
15
|
+
export type LineOption = ChartOption<LineSeriesOption>;
|
|
16
|
+
export type LinesOption = ChartOption<LinesSeriesOption>;
|
|
17
|
+
export type MapOption = ChartOption<MapSeriesOption>;
|
|
18
|
+
export type ParallelOption = ChartOption<ParallelSeriesOption>;
|
|
19
|
+
export type PictorialBarOption = ChartOption<PictorialBarSeriesOption>;
|
|
20
|
+
export type PieOption = ChartOption<PieSeriesOption>;
|
|
21
|
+
export type RadarOption = ChartOption<RadarSeriesOption>;
|
|
22
|
+
export type SankeyOption = ChartOption<SankeySeriesOption>;
|
|
23
|
+
export type ScatterOption = ChartOption<ScatterSeriesOption>;
|
|
24
|
+
export type SunburstOption = ChartOption<SunburstSeriesOption>;
|
|
25
|
+
export type ThemeRiverOption = ChartOption<ThemeRiverSeriesOption>;
|
|
26
|
+
export type TreeOption = ChartOption<TreeSeriesOption>;
|
|
27
|
+
export type TreemapOption = ChartOption<TreemapSeriesOption>;
|
|
28
|
+
export type ModifiableEChartsInitOpts = Pick<EChartsInitOpts, "width" | "height" | "locale">;
|
|
29
|
+
export interface EChartInitOption extends Omit<EChartsInitOpts, keyof ModifiableEChartsInitOpts> {
|
|
30
|
+
}
|
|
31
|
+
export interface EchartProps<T extends ECBasicOption = ECBasicOption> extends Omit<ComponentProps<"div">, "children">, ModifiableEChartsInitOpts {
|
|
32
|
+
init?: EChartInitOption;
|
|
9
33
|
option: T;
|
|
10
|
-
chart?:
|
|
34
|
+
chart?: Ref<ECharts>;
|
|
11
35
|
}
|
|
12
|
-
export type EchartComponent<T extends
|
|
13
|
-
export declare
|
|
36
|
+
export type EchartComponent<T extends ECBasicOption = ECBasicOption> = FC<EchartProps<T>>;
|
|
37
|
+
export declare function Echart<T extends ECBasicOption = ECBasicOption>({ ref, width, height, locale, init: initOption, option, chart, ...rest }: EchartProps<T>): ReactNode;
|
|
14
38
|
export declare const Bar: EchartComponent<BarOption>;
|
|
39
|
+
export declare const Boxplot: EchartComponent<BoxplotOption>;
|
|
40
|
+
export declare const Candlestick: EchartComponent<CandlestickOption>;
|
|
41
|
+
export declare const Chord: EchartComponent<ChordOption>;
|
|
42
|
+
export declare const Custom: EchartComponent<CustomOption>;
|
|
43
|
+
export declare const EffectScatter: EchartComponent<EffectScatterOption>;
|
|
44
|
+
export declare const Funnel: EchartComponent<FunnelOption>;
|
|
45
|
+
export declare const Gauge: EchartComponent<GaugeOption>;
|
|
46
|
+
export declare const Graph: EchartComponent<GraphOption>;
|
|
47
|
+
export declare const Heatmap: EchartComponent<HeatmapOption>;
|
|
15
48
|
export declare const Line: EchartComponent<LineOption>;
|
|
49
|
+
export declare const Lines: EchartComponent<LinesOption>;
|
|
50
|
+
export declare const Map: EchartComponent<MapOption>;
|
|
51
|
+
export declare const Parallel: EchartComponent<ParallelOption>;
|
|
52
|
+
export declare const PictorialBar: EchartComponent<PictorialBarOption>;
|
|
53
|
+
export declare const Pie: EchartComponent<PieOption>;
|
|
54
|
+
export declare const Radar: EchartComponent<RadarOption>;
|
|
55
|
+
export declare const Sankey: EchartComponent<SankeyOption>;
|
|
56
|
+
export declare const Scatter: EchartComponent<ScatterOption>;
|
|
57
|
+
export declare const Sunburst: EchartComponent<SunburstOption>;
|
|
58
|
+
export declare const ThemeRiver: EchartComponent<ThemeRiverOption>;
|
|
59
|
+
export declare const Tree: EchartComponent<TreeOption>;
|
|
60
|
+
export declare const Treemap: EchartComponent<TreemapOption>;
|
|
@@ -1,38 +1,76 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
import { jsx } from "react/jsx-runtime";
|
|
3
|
-
import {
|
|
3
|
+
import { useEffect, useImperativeHandle, useLayoutEffect, useRef } from "react";
|
|
4
4
|
import { init } from "echarts";
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
import stable_hash from "stable-hash";
|
|
6
|
+
function Echart({ ref, width, height, locale, init: initOption, option, chart, ...rest }) {
|
|
7
7
|
const container = useRef(null);
|
|
8
8
|
const chartRef = useRef(null);
|
|
9
9
|
useLayoutEffect(()=>{
|
|
10
10
|
const ele = container.current;
|
|
11
11
|
chartRef.current = init(ele, option, {
|
|
12
|
+
...initOption,
|
|
12
13
|
width,
|
|
13
|
-
height
|
|
14
|
+
height,
|
|
15
|
+
locale
|
|
14
16
|
});
|
|
15
17
|
return ()=>{
|
|
16
18
|
var _chartRef_current;
|
|
17
19
|
return null == (_chartRef_current = chartRef.current) ? void 0 : _chartRef_current.dispose();
|
|
18
20
|
};
|
|
19
21
|
}, []);
|
|
20
|
-
useImperativeHandle(ref, ()=>container.current
|
|
21
|
-
useImperativeHandle(chart, ()=>chartRef.current
|
|
22
|
+
useImperativeHandle(ref, ()=>container.current);
|
|
23
|
+
useImperativeHandle(chart, ()=>chartRef.current);
|
|
24
|
+
useEffect(()=>{
|
|
25
|
+
var _chartRef_current;
|
|
26
|
+
return null == (_chartRef_current = chartRef.current) ? void 0 : _chartRef_current.setOption(option);
|
|
27
|
+
}, [
|
|
28
|
+
stable_hash(option)
|
|
29
|
+
]);
|
|
22
30
|
useEffect(()=>{
|
|
23
|
-
var _chartRef_current
|
|
24
|
-
null == (_chartRef_current = chartRef.current)
|
|
25
|
-
null == (_chartRef_current1 = chartRef.current) || _chartRef_current1.resize({
|
|
31
|
+
var _chartRef_current;
|
|
32
|
+
return null == (_chartRef_current = chartRef.current) ? void 0 : _chartRef_current.resize({
|
|
26
33
|
width,
|
|
27
34
|
height
|
|
28
35
|
});
|
|
29
|
-
}
|
|
36
|
+
}, [
|
|
37
|
+
width,
|
|
38
|
+
height
|
|
39
|
+
]);
|
|
40
|
+
useEffect(()=>{
|
|
41
|
+
var _chartRef_current;
|
|
42
|
+
return null == (_chartRef_current = chartRef.current) ? void 0 : _chartRef_current.setOption({
|
|
43
|
+
locale
|
|
44
|
+
});
|
|
45
|
+
}, [
|
|
46
|
+
locale
|
|
47
|
+
]);
|
|
30
48
|
return /*#__PURE__*/ jsx("div", {
|
|
31
49
|
ref: container,
|
|
32
50
|
...rest
|
|
33
51
|
});
|
|
34
|
-
}
|
|
35
|
-
const Pie = Echart;
|
|
52
|
+
}
|
|
36
53
|
const Bar = Echart;
|
|
54
|
+
const Boxplot = Echart;
|
|
55
|
+
const Candlestick = Echart;
|
|
56
|
+
const Chord = Echart;
|
|
57
|
+
const Custom = Echart;
|
|
58
|
+
const EffectScatter = Echart;
|
|
59
|
+
const Funnel = Echart;
|
|
60
|
+
const Gauge = Echart;
|
|
61
|
+
const Graph = Echart;
|
|
62
|
+
const Heatmap = Echart;
|
|
37
63
|
const Line = Echart;
|
|
38
|
-
|
|
64
|
+
const Lines = Echart;
|
|
65
|
+
const Map = Echart;
|
|
66
|
+
const Parallel = Echart;
|
|
67
|
+
const PictorialBar = Echart;
|
|
68
|
+
const Pie = Echart;
|
|
69
|
+
const Radar = Echart;
|
|
70
|
+
const Sankey = Echart;
|
|
71
|
+
const Scatter = Echart;
|
|
72
|
+
const Sunburst = Echart;
|
|
73
|
+
const ThemeRiver = Echart;
|
|
74
|
+
const Tree = Echart;
|
|
75
|
+
const Treemap = Echart;
|
|
76
|
+
export { Bar, Boxplot, Candlestick, Chord, Custom, Echart, EffectScatter, Funnel, Gauge, Graph, Heatmap, Line, Lines, Map, Parallel, PictorialBar, Pie, Radar, Sankey, Scatter, Sunburst, ThemeRiver, Tree, Treemap };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "deepsea-components",
|
|
3
|
-
"version": "5.17.
|
|
3
|
+
"version": "5.17.6",
|
|
4
4
|
"description": "格数科技自用组件库",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"echarts": "^6.0.0",
|
|
41
41
|
"hls.js": "^1.6.13",
|
|
42
42
|
"smooth-scrollbar": "^8.8.4",
|
|
43
|
+
"stable-hash": "^0.0.6",
|
|
43
44
|
"deepsea-tools": "5.42.4",
|
|
44
45
|
"soda-hooks": "6.15.2"
|
|
45
46
|
},
|
|
@@ -1,69 +1,242 @@
|
|
|
1
1
|
"use client"
|
|
2
2
|
|
|
3
|
+
import { ComponentProps, FC, ReactNode, Ref, useEffect, useImperativeHandle, useLayoutEffect, useRef } from "react"
|
|
3
4
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
RefAttributes,
|
|
8
|
-
forwardRef,
|
|
9
|
-
useEffect,
|
|
10
|
-
useImperativeHandle,
|
|
11
|
-
useLayoutEffect,
|
|
12
|
-
useRef,
|
|
13
|
-
} from "react"
|
|
14
|
-
import {
|
|
5
|
+
AngleAxisComponentOption,
|
|
6
|
+
AriaComponentOption,
|
|
7
|
+
AxisPointerComponentOption,
|
|
15
8
|
BarSeriesOption,
|
|
9
|
+
BoxplotSeriesOption,
|
|
10
|
+
BrushComponentOption,
|
|
11
|
+
CalendarComponentOption,
|
|
12
|
+
CandlestickSeriesOption,
|
|
13
|
+
ChordSeriesOption,
|
|
16
14
|
ComposeOption,
|
|
15
|
+
ContinousVisualMapComponentOption,
|
|
16
|
+
CustomSeriesOption,
|
|
17
|
+
DataZoomComponentOption,
|
|
17
18
|
DatasetComponentOption,
|
|
18
19
|
ECharts,
|
|
20
|
+
EChartsInitOpts,
|
|
21
|
+
EffectScatterSeriesOption,
|
|
22
|
+
FunnelSeriesOption,
|
|
23
|
+
GaugeSeriesOption,
|
|
24
|
+
GeoComponentOption,
|
|
25
|
+
GraphSeriesOption,
|
|
26
|
+
GraphicComponentOption,
|
|
19
27
|
GridComponentOption,
|
|
28
|
+
HeatmapSeriesOption,
|
|
29
|
+
InsideDataZoomComponentOption,
|
|
30
|
+
LegendComponentOption,
|
|
20
31
|
LineSeriesOption,
|
|
32
|
+
LinesSeriesOption,
|
|
33
|
+
MapSeriesOption,
|
|
34
|
+
MarkAreaComponentOption,
|
|
35
|
+
MarkLineComponentOption,
|
|
36
|
+
MarkPointComponentOption,
|
|
37
|
+
MatrixComponentOption,
|
|
38
|
+
ParallelSeriesOption,
|
|
39
|
+
PictorialBarSeriesOption,
|
|
21
40
|
PieSeriesOption,
|
|
41
|
+
PiecewiseVisualMapComponentOption,
|
|
42
|
+
PlainLegendComponentOption,
|
|
43
|
+
PolarComponentOption,
|
|
44
|
+
RadarComponentOption,
|
|
45
|
+
RadarSeriesOption,
|
|
46
|
+
RadiusAxisComponentOption,
|
|
47
|
+
SankeySeriesOption,
|
|
48
|
+
ScatterSeriesOption,
|
|
49
|
+
ScrollableLegendComponentOption,
|
|
50
|
+
SeriesOption,
|
|
51
|
+
SingleAxisComponentOption,
|
|
52
|
+
SliderDataZoomComponentOption,
|
|
53
|
+
SunburstSeriesOption,
|
|
54
|
+
ThemeRiverSeriesOption,
|
|
55
|
+
ThumbnailComponentOption,
|
|
56
|
+
TimelineComponentOption,
|
|
22
57
|
TitleComponentOption,
|
|
58
|
+
ToolboxComponentOption,
|
|
23
59
|
TooltipComponentOption,
|
|
60
|
+
TreeSeriesOption,
|
|
61
|
+
TreemapSeriesOption,
|
|
62
|
+
VisualMapComponentOption,
|
|
63
|
+
XAXisComponentOption,
|
|
64
|
+
YAXisComponentOption,
|
|
24
65
|
init,
|
|
25
66
|
} from "echarts"
|
|
67
|
+
import { ECBasicOption } from "echarts/types/src/util/types.js"
|
|
68
|
+
import hash from "stable-hash"
|
|
69
|
+
|
|
70
|
+
export type ChartOption<T extends SeriesOption = never> = ComposeOption<
|
|
71
|
+
| T
|
|
72
|
+
| DatasetComponentOption
|
|
73
|
+
| GridComponentOption
|
|
74
|
+
| LegendComponentOption
|
|
75
|
+
| TitleComponentOption
|
|
76
|
+
| TooltipComponentOption
|
|
77
|
+
| AxisPointerComponentOption
|
|
78
|
+
| GeoComponentOption
|
|
79
|
+
| MarkLineComponentOption
|
|
80
|
+
| MarkPointComponentOption
|
|
81
|
+
| MarkAreaComponentOption
|
|
82
|
+
| DataZoomComponentOption
|
|
83
|
+
| AriaComponentOption
|
|
84
|
+
| BrushComponentOption
|
|
85
|
+
| PolarComponentOption
|
|
86
|
+
| RadarComponentOption
|
|
87
|
+
| XAXisComponentOption
|
|
88
|
+
| YAXisComponentOption
|
|
89
|
+
| MatrixComponentOption
|
|
90
|
+
| GraphicComponentOption
|
|
91
|
+
| ToolboxComponentOption
|
|
92
|
+
| CalendarComponentOption
|
|
93
|
+
| TimelineComponentOption
|
|
94
|
+
| AngleAxisComponentOption
|
|
95
|
+
| RadiusAxisComponentOption
|
|
96
|
+
| SingleAxisComponentOption
|
|
97
|
+
| VisualMapComponentOption
|
|
98
|
+
| ThumbnailComponentOption
|
|
99
|
+
| PlainLegendComponentOption
|
|
100
|
+
| InsideDataZoomComponentOption
|
|
101
|
+
| SliderDataZoomComponentOption
|
|
102
|
+
| PiecewiseVisualMapComponentOption
|
|
103
|
+
| ContinousVisualMapComponentOption
|
|
104
|
+
| ScrollableLegendComponentOption
|
|
105
|
+
>
|
|
106
|
+
|
|
107
|
+
export type BarOption = ChartOption<BarSeriesOption>
|
|
108
|
+
|
|
109
|
+
export type BoxplotOption = ChartOption<BoxplotSeriesOption>
|
|
110
|
+
|
|
111
|
+
export type CandlestickOption = ChartOption<CandlestickSeriesOption>
|
|
112
|
+
|
|
113
|
+
export type ChordOption = ChartOption<ChordSeriesOption>
|
|
114
|
+
|
|
115
|
+
export type CustomOption = ChartOption<CustomSeriesOption>
|
|
116
|
+
|
|
117
|
+
export type EffectScatterOption = ChartOption<EffectScatterSeriesOption>
|
|
118
|
+
|
|
119
|
+
export type FunnelOption = ChartOption<FunnelSeriesOption>
|
|
120
|
+
|
|
121
|
+
export type GaugeOption = ChartOption<GaugeSeriesOption>
|
|
122
|
+
|
|
123
|
+
export type GraphOption = ChartOption<GraphSeriesOption>
|
|
124
|
+
|
|
125
|
+
export type HeatmapOption = ChartOption<HeatmapSeriesOption>
|
|
126
|
+
|
|
127
|
+
export type LineOption = ChartOption<LineSeriesOption>
|
|
26
128
|
|
|
27
|
-
export type
|
|
129
|
+
export type LinesOption = ChartOption<LinesSeriesOption>
|
|
28
130
|
|
|
29
|
-
export type
|
|
131
|
+
export type MapOption = ChartOption<MapSeriesOption>
|
|
30
132
|
|
|
31
|
-
export type
|
|
133
|
+
export type ParallelOption = ChartOption<ParallelSeriesOption>
|
|
32
134
|
|
|
33
|
-
export
|
|
34
|
-
|
|
35
|
-
|
|
135
|
+
export type PictorialBarOption = ChartOption<PictorialBarSeriesOption>
|
|
136
|
+
|
|
137
|
+
export type PieOption = ChartOption<PieSeriesOption>
|
|
138
|
+
|
|
139
|
+
export type RadarOption = ChartOption<RadarSeriesOption>
|
|
140
|
+
|
|
141
|
+
export type SankeyOption = ChartOption<SankeySeriesOption>
|
|
142
|
+
|
|
143
|
+
export type ScatterOption = ChartOption<ScatterSeriesOption>
|
|
144
|
+
|
|
145
|
+
export type SunburstOption = ChartOption<SunburstSeriesOption>
|
|
146
|
+
|
|
147
|
+
export type ThemeRiverOption = ChartOption<ThemeRiverSeriesOption>
|
|
148
|
+
|
|
149
|
+
export type TreeOption = ChartOption<TreeSeriesOption>
|
|
150
|
+
|
|
151
|
+
export type TreemapOption = ChartOption<TreemapSeriesOption>
|
|
152
|
+
|
|
153
|
+
export type ModifiableEChartsInitOpts = Pick<EChartsInitOpts, "width" | "height" | "locale">
|
|
154
|
+
|
|
155
|
+
export interface EChartInitOption extends Omit<EChartsInitOpts, keyof ModifiableEChartsInitOpts> {}
|
|
156
|
+
|
|
157
|
+
export interface EchartProps<T extends ECBasicOption = ECBasicOption> extends Omit<ComponentProps<"div">, "children">, ModifiableEChartsInitOpts {
|
|
158
|
+
init?: EChartInitOption
|
|
36
159
|
option: T
|
|
37
|
-
chart?:
|
|
160
|
+
chart?: Ref<ECharts>
|
|
38
161
|
}
|
|
39
162
|
|
|
40
|
-
export type EchartComponent<T extends
|
|
41
|
-
Omit<EchartProps<T>, "ref"> & RefAttributes<HTMLDivElement>
|
|
42
|
-
>
|
|
163
|
+
export type EchartComponent<T extends ECBasicOption = ECBasicOption> = FC<EchartProps<T>>
|
|
43
164
|
|
|
44
|
-
|
|
45
|
-
|
|
165
|
+
export function Echart<T extends ECBasicOption = ECBasicOption>({
|
|
166
|
+
ref,
|
|
167
|
+
width,
|
|
168
|
+
height,
|
|
169
|
+
locale,
|
|
170
|
+
init: initOption,
|
|
171
|
+
option,
|
|
172
|
+
chart,
|
|
173
|
+
...rest
|
|
174
|
+
}: EchartProps<T>): ReactNode {
|
|
46
175
|
const container = useRef<HTMLDivElement>(null)
|
|
47
176
|
const chartRef = useRef<ECharts | null>(null)
|
|
48
177
|
|
|
49
178
|
useLayoutEffect(() => {
|
|
50
179
|
const ele = container.current!
|
|
51
|
-
chartRef.current = init(ele, option, { width, height })
|
|
180
|
+
chartRef.current = init(ele, option, { ...initOption, width, height, locale })
|
|
52
181
|
return () => chartRef.current?.dispose()
|
|
53
182
|
}, [])
|
|
54
183
|
|
|
55
|
-
useImperativeHandle(ref, () => container.current
|
|
184
|
+
useImperativeHandle(ref, () => container.current!)
|
|
185
|
+
|
|
186
|
+
useImperativeHandle(chart, () => chartRef.current!)
|
|
56
187
|
|
|
57
|
-
|
|
188
|
+
useEffect(() => chartRef.current?.setOption(option), [hash(option)])
|
|
58
189
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
})
|
|
190
|
+
// @ts-expect-error width and height can be string
|
|
191
|
+
useEffect(() => chartRef.current?.resize({ width, height }), [width, height])
|
|
192
|
+
|
|
193
|
+
useEffect(() => chartRef.current?.setOption({ locale }), [locale])
|
|
63
194
|
|
|
64
195
|
return <div ref={container} {...rest} />
|
|
65
|
-
}
|
|
196
|
+
}
|
|
66
197
|
|
|
67
|
-
export const Pie = Echart as EchartComponent<PieOption>
|
|
68
198
|
export const Bar = Echart as EchartComponent<BarOption>
|
|
199
|
+
|
|
200
|
+
export const Boxplot = Echart as EchartComponent<BoxplotOption>
|
|
201
|
+
|
|
202
|
+
export const Candlestick = Echart as EchartComponent<CandlestickOption>
|
|
203
|
+
|
|
204
|
+
export const Chord = Echart as EchartComponent<ChordOption>
|
|
205
|
+
|
|
206
|
+
export const Custom = Echart as EchartComponent<CustomOption>
|
|
207
|
+
|
|
208
|
+
export const EffectScatter = Echart as EchartComponent<EffectScatterOption>
|
|
209
|
+
|
|
210
|
+
export const Funnel = Echart as EchartComponent<FunnelOption>
|
|
211
|
+
|
|
212
|
+
export const Gauge = Echart as EchartComponent<GaugeOption>
|
|
213
|
+
|
|
214
|
+
export const Graph = Echart as EchartComponent<GraphOption>
|
|
215
|
+
|
|
216
|
+
export const Heatmap = Echart as EchartComponent<HeatmapOption>
|
|
217
|
+
|
|
69
218
|
export const Line = Echart as EchartComponent<LineOption>
|
|
219
|
+
|
|
220
|
+
export const Lines = Echart as EchartComponent<LinesOption>
|
|
221
|
+
|
|
222
|
+
export const Map = Echart as EchartComponent<MapOption>
|
|
223
|
+
|
|
224
|
+
export const Parallel = Echart as EchartComponent<ParallelOption>
|
|
225
|
+
|
|
226
|
+
export const PictorialBar = Echart as EchartComponent<PictorialBarOption>
|
|
227
|
+
|
|
228
|
+
export const Pie = Echart as EchartComponent<PieOption>
|
|
229
|
+
|
|
230
|
+
export const Radar = Echart as EchartComponent<RadarOption>
|
|
231
|
+
|
|
232
|
+
export const Sankey = Echart as EchartComponent<SankeyOption>
|
|
233
|
+
|
|
234
|
+
export const Scatter = Echart as EchartComponent<ScatterOption>
|
|
235
|
+
|
|
236
|
+
export const Sunburst = Echart as EchartComponent<SunburstOption>
|
|
237
|
+
|
|
238
|
+
export const ThemeRiver = Echart as EchartComponent<ThemeRiverOption>
|
|
239
|
+
|
|
240
|
+
export const Tree = Echart as EchartComponent<TreeOption>
|
|
241
|
+
|
|
242
|
+
export const Treemap = Echart as EchartComponent<TreemapOption>
|