win-chart 2.13.0 → 3.0.0
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/README.md +55 -7
- package/dist/cjs/components/ChartWrapper.cjs +39 -0
- package/dist/cjs/components/EarthChart.cjs +168 -0
- package/dist/cjs/components/GanttChart.cjs +302 -0
- package/dist/cjs/components/WinChart.cjs +125 -0
- package/dist/cjs/index.cjs +58 -0
- package/dist/cjs/types/index.cjs +51 -0
- package/dist/cjs/utils/const.cjs +68 -0
- package/dist/cjs/utils/data.cjs +9382 -0
- package/dist/cjs/utils/earthMockData.cjs +6017 -0
- package/dist/cjs/utils/getAreaSpec.cjs +143 -0
- package/dist/cjs/utils/getBarSpec.cjs +171 -0
- package/dist/cjs/utils/getChartOptions.cjs +78 -0
- package/dist/cjs/utils/getColumnSpec.cjs +127 -0
- package/dist/cjs/utils/getDualSpec.cjs +171 -0
- package/dist/cjs/utils/getFunnelSpec.cjs +89 -0
- package/dist/cjs/utils/getLineSpec.cjs +72 -0
- package/dist/cjs/utils/getPieSpec.cjs +140 -0
- package/dist/cjs/utils/getRadarSpec.cjs +100 -0
- package/dist/cjs/utils/tool.cjs +240 -0
- package/dist/esm/components/ChartWrapper.js +5 -0
- package/dist/esm/components/EarthChart.js +134 -0
- package/dist/esm/components/GanttChart.js +268 -0
- package/dist/esm/components/WinChart.js +79 -0
- package/dist/esm/index.js +6 -0
- package/dist/esm/types/index.js +17 -0
- package/dist/esm/utils/const.js +31 -0
- package/dist/esm/utils/data.js +9342 -0
- package/dist/esm/utils/earthMockData.js +5983 -0
- package/dist/esm/utils/getAreaSpec.js +106 -0
- package/dist/esm/utils/getBarSpec.js +134 -0
- package/dist/esm/utils/getChartOptions.js +44 -0
- package/dist/esm/utils/getColumnSpec.js +90 -0
- package/dist/esm/utils/getDualSpec.js +134 -0
- package/dist/esm/utils/getFunnelSpec.js +55 -0
- package/dist/esm/utils/getLineSpec.js +38 -0
- package/dist/esm/utils/getPieSpec.js +103 -0
- package/dist/esm/utils/getRadarSpec.js +66 -0
- package/dist/esm/utils/tool.js +146 -0
- package/dist/index.js +1219 -0
- package/dist/types/components/GanttChart.d.ts +0 -1
- package/dist/types/demos/DualSystemComparisonChart.d.ts +1 -0
- package/dist/types/demos/EastWestResourceComparisonChart.d.ts +1 -0
- package/dist/types/demos/PolicyGrowthChart.d.ts +1 -0
- package/dist/types/demos/PolicyOpennessChart.d.ts +1 -0
- package/dist/types/demos/PracticalUsageTrendChart.d.ts +1 -0
- package/dist/types/demos/index.d.ts +5 -0
- package/dist/types/types/index.d.ts +14 -14
- package/dist/types/utils/getAreaSpec.d.ts +1 -1
- package/dist/types/utils/getBarSpec.d.ts +1 -1
- package/dist/types/utils/getChartOptions.d.ts +1 -1
- package/dist/types/utils/getColumnSpec.d.ts +1 -1
- package/dist/types/utils/getDualSpec.d.ts +1 -1
- package/dist/types/utils/getFunnelSpec.d.ts +1 -1
- package/dist/types/utils/getLineSpec.d.ts +1 -1
- package/dist/types/utils/getPieSpec.d.ts +1 -1
- package/dist/types/utils/getRadarSpec.d.ts +1 -1
- package/dist/types/utils/tool.d.ts +59 -3
- package/package.json +33 -32
- package/dist/bundle.esm.js +0 -22
- package/dist/index.d.ts +0 -147
- package/dist/types/app.d.ts +0 -1
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { init } from "echarts";
|
|
3
|
+
import "echarts-gl";
|
|
4
|
+
import { useEffect, useRef, useState } from "react";
|
|
5
|
+
import { ChartWrapper } from "./ChartWrapper.js";
|
|
6
|
+
import { debounce } from "../utils/tool.js";
|
|
7
|
+
const mockPointsData = [];
|
|
8
|
+
for(let i = 0; i < 50; i++)mockPointsData.push({
|
|
9
|
+
name: `测试${i + 1}`,
|
|
10
|
+
value: [
|
|
11
|
+
150 * Math.random(),
|
|
12
|
+
50 * Math.random()
|
|
13
|
+
],
|
|
14
|
+
symbolSize: 8
|
|
15
|
+
});
|
|
16
|
+
const mockLinesData = [];
|
|
17
|
+
for(let i = 0; i < 10; i++)mockLinesData.push([
|
|
18
|
+
[
|
|
19
|
+
150 * Math.random(),
|
|
20
|
+
50 * Math.random()
|
|
21
|
+
],
|
|
22
|
+
[
|
|
23
|
+
150 * Math.random(),
|
|
24
|
+
50 * Math.random()
|
|
25
|
+
]
|
|
26
|
+
]);
|
|
27
|
+
const EarthChart = ({ className = '', style = {}, extraOption = {}, lineStyles = {}, pointsStyles = {}, pointsData = [], linesData = [], globeOption = {} })=>{
|
|
28
|
+
const boxRef = useRef(null);
|
|
29
|
+
const [eChart, setEChart] = useState();
|
|
30
|
+
useEffect(()=>{
|
|
31
|
+
const eChart = init(boxRef.current);
|
|
32
|
+
setEChart(eChart);
|
|
33
|
+
const resize = debounce(eChart.resize, 500);
|
|
34
|
+
const handlerResize = ()=>{
|
|
35
|
+
resize();
|
|
36
|
+
};
|
|
37
|
+
globalThis.addEventListener('resize', handlerResize);
|
|
38
|
+
return ()=>{
|
|
39
|
+
globalThis.removeEventListener('resize', handlerResize);
|
|
40
|
+
};
|
|
41
|
+
}, []);
|
|
42
|
+
useEffect(()=>{
|
|
43
|
+
if (eChart) {
|
|
44
|
+
const series = [];
|
|
45
|
+
series.push({
|
|
46
|
+
type: 'lines3D',
|
|
47
|
+
name: "lines3D",
|
|
48
|
+
effect: {
|
|
49
|
+
show: true,
|
|
50
|
+
trailWidth: 2,
|
|
51
|
+
trailLength: 0.15,
|
|
52
|
+
trailOpacity: 1,
|
|
53
|
+
trailColor: 'rgb(30, 30, 60)'
|
|
54
|
+
},
|
|
55
|
+
lineStyle: {
|
|
56
|
+
width: 5,
|
|
57
|
+
color: 'rgb(50, 50, 150)',
|
|
58
|
+
opacity: 0.3
|
|
59
|
+
},
|
|
60
|
+
blendMode: 'lighter',
|
|
61
|
+
data: linesData,
|
|
62
|
+
...lineStyles
|
|
63
|
+
});
|
|
64
|
+
series.push({
|
|
65
|
+
type: 'scatter3D',
|
|
66
|
+
coordinateSystem: 'globe',
|
|
67
|
+
zlevel: 3,
|
|
68
|
+
rippleEffect: {
|
|
69
|
+
brushType: 'stroke'
|
|
70
|
+
},
|
|
71
|
+
label: {
|
|
72
|
+
fontSize: 8,
|
|
73
|
+
show: true,
|
|
74
|
+
position: 'right',
|
|
75
|
+
formatter: '{b}'
|
|
76
|
+
},
|
|
77
|
+
itemStyle: {
|
|
78
|
+
normal: {
|
|
79
|
+
color: '#f5f802'
|
|
80
|
+
}
|
|
81
|
+
},
|
|
82
|
+
data: pointsData,
|
|
83
|
+
...pointsStyles
|
|
84
|
+
});
|
|
85
|
+
eChart.setOption({
|
|
86
|
+
backgroundColor: '#000',
|
|
87
|
+
baseColor: '#000',
|
|
88
|
+
shading: 'realistic',
|
|
89
|
+
globe: {
|
|
90
|
+
environment: 'https://img.alicdn.com/imgextra/i2/O1CN017x8UE61p6wqej1Y0c_!!6000000005312-0-tps-2048-1024.jpg',
|
|
91
|
+
heightTexture: 'https://img.alicdn.com/imgextra/i2/O1CN01BB16kM1ILFttfdYZg_!!6000000000876-0-tps-4096-2048.jpg',
|
|
92
|
+
baseTexture: 'https://img.alicdn.com/imgextra/i4/O1CN01fs70Dq25ElSd8mU6C_!!6000000007495-0-tps-5400-2700.jpg',
|
|
93
|
+
shading: 'lambert',
|
|
94
|
+
light: {
|
|
95
|
+
ambient: {
|
|
96
|
+
intensity: 1
|
|
97
|
+
},
|
|
98
|
+
main: {
|
|
99
|
+
intensity: 0.1
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
viewControl: {
|
|
103
|
+
autoRotate: true,
|
|
104
|
+
distance: 230
|
|
105
|
+
},
|
|
106
|
+
left: '20%',
|
|
107
|
+
...globeOption
|
|
108
|
+
},
|
|
109
|
+
series: series,
|
|
110
|
+
...extraOption
|
|
111
|
+
});
|
|
112
|
+
const timer = setTimeout(()=>{
|
|
113
|
+
eChart.resize();
|
|
114
|
+
}, 500);
|
|
115
|
+
return ()=>{
|
|
116
|
+
clearTimeout(timer);
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
}, [
|
|
120
|
+
eChart,
|
|
121
|
+
extraOption,
|
|
122
|
+
globeOption,
|
|
123
|
+
lineStyles,
|
|
124
|
+
linesData,
|
|
125
|
+
pointsData,
|
|
126
|
+
pointsStyles
|
|
127
|
+
]);
|
|
128
|
+
return /*#__PURE__*/ jsx(ChartWrapper, {
|
|
129
|
+
ref: boxRef,
|
|
130
|
+
className: className,
|
|
131
|
+
style: style
|
|
132
|
+
});
|
|
133
|
+
};
|
|
134
|
+
export { EarthChart };
|
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { format, graphic, init } from "echarts";
|
|
3
|
+
import { useEffect, useRef, useState } from "react";
|
|
4
|
+
import { ChartWrapper } from "./ChartWrapper.js";
|
|
5
|
+
import { debounce } from "../utils/tool.js";
|
|
6
|
+
import { airportData } from "../utils/data.js";
|
|
7
|
+
const HEIGHT_RATIO = 0.6;
|
|
8
|
+
const DIM_CATEGORY_INDEX = 0;
|
|
9
|
+
const DIM_TIME_ARRIVAL = 1;
|
|
10
|
+
const DIM_TIME_DEPARTURE = 2;
|
|
11
|
+
const _cartesianXBounds = [];
|
|
12
|
+
const _cartesianYBounds = [];
|
|
13
|
+
const _rawData = airportData;
|
|
14
|
+
const GanttChart = ({ className = '', style = {}, extraOption = {} })=>{
|
|
15
|
+
const boxRef = useRef(null);
|
|
16
|
+
const [eChart, setEChart] = useState();
|
|
17
|
+
useEffect(()=>{
|
|
18
|
+
const eChart = init(boxRef.current);
|
|
19
|
+
setEChart(eChart);
|
|
20
|
+
const resize = debounce(eChart.resize, 500);
|
|
21
|
+
const handlerResize = ()=>{
|
|
22
|
+
resize();
|
|
23
|
+
};
|
|
24
|
+
globalThis.addEventListener('resize', handlerResize);
|
|
25
|
+
return ()=>{
|
|
26
|
+
globalThis.removeEventListener('resize', handlerResize);
|
|
27
|
+
};
|
|
28
|
+
}, []);
|
|
29
|
+
useEffect(()=>{
|
|
30
|
+
if (eChart) {
|
|
31
|
+
eChart.setOption(makeOption());
|
|
32
|
+
const timer = setTimeout(()=>{
|
|
33
|
+
eChart.resize();
|
|
34
|
+
}, 500);
|
|
35
|
+
return ()=>{
|
|
36
|
+
clearTimeout(timer);
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
}, [
|
|
40
|
+
eChart,
|
|
41
|
+
extraOption
|
|
42
|
+
]);
|
|
43
|
+
return /*#__PURE__*/ jsx(ChartWrapper, {
|
|
44
|
+
ref: boxRef,
|
|
45
|
+
className: className,
|
|
46
|
+
style: style
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
function makeOption() {
|
|
50
|
+
return {
|
|
51
|
+
tooltip: {},
|
|
52
|
+
animation: false,
|
|
53
|
+
toolbox: {
|
|
54
|
+
left: 20,
|
|
55
|
+
top: 0,
|
|
56
|
+
itemSize: 20
|
|
57
|
+
},
|
|
58
|
+
title: {
|
|
59
|
+
text: 'Gantt of Airport Flight',
|
|
60
|
+
left: 'center'
|
|
61
|
+
},
|
|
62
|
+
grid: {
|
|
63
|
+
show: true,
|
|
64
|
+
top: 70,
|
|
65
|
+
bottom: 20,
|
|
66
|
+
left: 100,
|
|
67
|
+
right: 20,
|
|
68
|
+
backgroundColor: '#fff',
|
|
69
|
+
borderWidth: 0
|
|
70
|
+
},
|
|
71
|
+
xAxis: {
|
|
72
|
+
type: 'time',
|
|
73
|
+
position: 'top',
|
|
74
|
+
splitLine: {
|
|
75
|
+
lineStyle: {
|
|
76
|
+
color: [
|
|
77
|
+
'#E9EDFF'
|
|
78
|
+
]
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
axisLine: {
|
|
82
|
+
show: false
|
|
83
|
+
},
|
|
84
|
+
axisTick: {
|
|
85
|
+
lineStyle: {
|
|
86
|
+
color: '#929ABA'
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
axisLabel: {
|
|
90
|
+
color: '#929ABA',
|
|
91
|
+
inside: false,
|
|
92
|
+
align: 'center'
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
yAxis: {
|
|
96
|
+
axisTick: {
|
|
97
|
+
show: false
|
|
98
|
+
},
|
|
99
|
+
splitLine: {
|
|
100
|
+
show: false
|
|
101
|
+
},
|
|
102
|
+
axisLine: {
|
|
103
|
+
show: false
|
|
104
|
+
},
|
|
105
|
+
axisLabel: {
|
|
106
|
+
show: false
|
|
107
|
+
},
|
|
108
|
+
min: 0,
|
|
109
|
+
max: _rawData.parkingApron.data.length
|
|
110
|
+
},
|
|
111
|
+
series: [
|
|
112
|
+
{
|
|
113
|
+
id: 'flightData',
|
|
114
|
+
type: 'custom',
|
|
115
|
+
renderItem: renderGanttItem,
|
|
116
|
+
dimensions: _rawData.flight.dimensions,
|
|
117
|
+
encode: {
|
|
118
|
+
x: [
|
|
119
|
+
DIM_TIME_ARRIVAL,
|
|
120
|
+
DIM_TIME_DEPARTURE
|
|
121
|
+
],
|
|
122
|
+
y: DIM_CATEGORY_INDEX,
|
|
123
|
+
tooltip: [
|
|
124
|
+
DIM_CATEGORY_INDEX,
|
|
125
|
+
DIM_TIME_ARRIVAL,
|
|
126
|
+
DIM_TIME_DEPARTURE
|
|
127
|
+
]
|
|
128
|
+
},
|
|
129
|
+
data: _rawData.flight.data
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
type: 'custom',
|
|
133
|
+
renderItem: renderAxisLabelItem,
|
|
134
|
+
dimensions: _rawData.parkingApron.dimensions,
|
|
135
|
+
encode: {
|
|
136
|
+
x: -1,
|
|
137
|
+
y: 0
|
|
138
|
+
},
|
|
139
|
+
data: _rawData.parkingApron.data.map(function(item, index) {
|
|
140
|
+
return [
|
|
141
|
+
index
|
|
142
|
+
].concat(item);
|
|
143
|
+
})
|
|
144
|
+
}
|
|
145
|
+
]
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
function renderGanttItem(params, api) {
|
|
149
|
+
const categoryIndex = api.value(DIM_CATEGORY_INDEX);
|
|
150
|
+
const timeArrival = api.coord([
|
|
151
|
+
api.value(DIM_TIME_ARRIVAL),
|
|
152
|
+
categoryIndex
|
|
153
|
+
]);
|
|
154
|
+
const timeDeparture = api.coord([
|
|
155
|
+
api.value(DIM_TIME_DEPARTURE),
|
|
156
|
+
categoryIndex
|
|
157
|
+
]);
|
|
158
|
+
const coordSys = params.coordSys;
|
|
159
|
+
_cartesianXBounds[0] = coordSys.x;
|
|
160
|
+
_cartesianXBounds[1] = coordSys.x + coordSys.width;
|
|
161
|
+
_cartesianYBounds[0] = coordSys.y;
|
|
162
|
+
_cartesianYBounds[1] = coordSys.y + coordSys.height;
|
|
163
|
+
const barLength = timeDeparture[0] - timeArrival[0];
|
|
164
|
+
const barHeight = api.size([
|
|
165
|
+
0,
|
|
166
|
+
1
|
|
167
|
+
])[1] * HEIGHT_RATIO;
|
|
168
|
+
const x = timeArrival[0];
|
|
169
|
+
const y = timeArrival[1] - barHeight;
|
|
170
|
+
const flightNumber = api.value(3) + '';
|
|
171
|
+
const flightNumberWidth = format.getTextRect(flightNumber).width;
|
|
172
|
+
const text = barLength > flightNumberWidth + 40 && x + barLength >= 180 ? flightNumber : '';
|
|
173
|
+
const rectNormal = clipRectByRect(params, {
|
|
174
|
+
x: x,
|
|
175
|
+
y: y,
|
|
176
|
+
width: barLength,
|
|
177
|
+
height: barHeight
|
|
178
|
+
});
|
|
179
|
+
const rectVIP = clipRectByRect(params, {
|
|
180
|
+
x: x,
|
|
181
|
+
y: y,
|
|
182
|
+
width: barLength / 2,
|
|
183
|
+
height: barHeight
|
|
184
|
+
});
|
|
185
|
+
const rectText = clipRectByRect(params, {
|
|
186
|
+
x: x,
|
|
187
|
+
y: y,
|
|
188
|
+
width: barLength,
|
|
189
|
+
height: barHeight
|
|
190
|
+
});
|
|
191
|
+
return {
|
|
192
|
+
type: 'group',
|
|
193
|
+
children: [
|
|
194
|
+
{
|
|
195
|
+
type: 'rect',
|
|
196
|
+
ignore: !rectNormal,
|
|
197
|
+
shape: rectNormal,
|
|
198
|
+
style: api.style()
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
type: 'rect',
|
|
202
|
+
ignore: !rectVIP && !api.value(4),
|
|
203
|
+
shape: rectVIP,
|
|
204
|
+
style: api.style({
|
|
205
|
+
fill: '#ddb30b'
|
|
206
|
+
})
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
type: 'rect',
|
|
210
|
+
ignore: !rectText,
|
|
211
|
+
shape: rectText,
|
|
212
|
+
style: api.style({
|
|
213
|
+
fill: 'transparent',
|
|
214
|
+
stroke: 'transparent',
|
|
215
|
+
text: text,
|
|
216
|
+
textFill: '#fff'
|
|
217
|
+
})
|
|
218
|
+
}
|
|
219
|
+
]
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
function renderAxisLabelItem(params, api) {
|
|
223
|
+
const y = api.coord([
|
|
224
|
+
0,
|
|
225
|
+
api.value(0)
|
|
226
|
+
])[1];
|
|
227
|
+
if (y < params.coordSys.y + 5) return;
|
|
228
|
+
return {
|
|
229
|
+
type: 'group',
|
|
230
|
+
position: [
|
|
231
|
+
10,
|
|
232
|
+
y
|
|
233
|
+
],
|
|
234
|
+
children: [
|
|
235
|
+
{
|
|
236
|
+
type: 'text',
|
|
237
|
+
style: {
|
|
238
|
+
x: 24,
|
|
239
|
+
y: -3,
|
|
240
|
+
text: api.value(1),
|
|
241
|
+
textVerticalAlign: 'bottom',
|
|
242
|
+
textAlign: 'center',
|
|
243
|
+
textFill: '#fff'
|
|
244
|
+
}
|
|
245
|
+
},
|
|
246
|
+
{
|
|
247
|
+
type: 'text',
|
|
248
|
+
style: {
|
|
249
|
+
x: 75,
|
|
250
|
+
y: -2,
|
|
251
|
+
textVerticalAlign: 'bottom',
|
|
252
|
+
textAlign: 'center',
|
|
253
|
+
text: api.value(2),
|
|
254
|
+
textFill: '#000'
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
]
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
function clipRectByRect(params, rect) {
|
|
261
|
+
return graphic.clipRectByRect(rect, {
|
|
262
|
+
x: params.coordSys.x,
|
|
263
|
+
y: params.coordSys.y,
|
|
264
|
+
width: params.coordSys.width,
|
|
265
|
+
height: params.coordSys.height
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
export { GanttChart };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { ChartWrapper } from "./ChartWrapper.js";
|
|
3
|
+
import { useEffect, useRef, useState } from "react";
|
|
4
|
+
import { getEChartOptions } from "../utils/getChartOptions.js";
|
|
5
|
+
import { init, registerTheme } from "echarts";
|
|
6
|
+
import { commonOpt } from "../utils/const.js";
|
|
7
|
+
import { debounce, mergeSeriesOption } from "../utils/tool.js";
|
|
8
|
+
import win_light from "../theme/win-light.js";
|
|
9
|
+
import win_dark from "../theme/win-dark.js";
|
|
10
|
+
import deepmerge from "deepmerge";
|
|
11
|
+
import { WinChartType } from "../types/index.js";
|
|
12
|
+
registerTheme('light', deepmerge(win_light, commonOpt));
|
|
13
|
+
registerTheme('dark', deepmerge(win_dark, commonOpt));
|
|
14
|
+
const mergeOption = {
|
|
15
|
+
arrayMerge: (_destinationArray, sourceArray)=>sourceArray
|
|
16
|
+
};
|
|
17
|
+
const WinChart = (props)=>{
|
|
18
|
+
const boxRef = useRef(null);
|
|
19
|
+
const [instance, setInstance] = useState();
|
|
20
|
+
const [refreshTag, setRefreshTag] = useState(1);
|
|
21
|
+
useEffect(()=>{
|
|
22
|
+
const chart = init(boxRef.current, props.theme ?? 'light');
|
|
23
|
+
setInstance(chart);
|
|
24
|
+
const resize = debounce(chart.resize, 500);
|
|
25
|
+
const handlerResize = ()=>resize();
|
|
26
|
+
globalThis.addEventListener('resize', handlerResize);
|
|
27
|
+
return ()=>{
|
|
28
|
+
globalThis.removeEventListener('resize', handlerResize);
|
|
29
|
+
};
|
|
30
|
+
}, [
|
|
31
|
+
props.theme
|
|
32
|
+
]);
|
|
33
|
+
useEffect(()=>{
|
|
34
|
+
if (instance && refreshTag) {
|
|
35
|
+
const actualChartHeight = instance.getHeight() - 48;
|
|
36
|
+
const newProps = {
|
|
37
|
+
...props,
|
|
38
|
+
...props.chartType === WinChartType.CYCLE && !props.cycleCenterConfig && {
|
|
39
|
+
cycleCenterConfig: {
|
|
40
|
+
title: {
|
|
41
|
+
top: actualChartHeight / 2 + 24
|
|
42
|
+
},
|
|
43
|
+
content: {
|
|
44
|
+
top: actualChartHeight / 2 - 8
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
const { extraOption = {}, extraSeriesOption } = newProps;
|
|
50
|
+
instance.clear();
|
|
51
|
+
const option = deepmerge(mergeSeriesOption(getEChartOptions(newProps), extraSeriesOption), extraOption, mergeOption);
|
|
52
|
+
instance.setOption(option);
|
|
53
|
+
newProps.onLoad?.(instance);
|
|
54
|
+
const timer = setTimeout(()=>{
|
|
55
|
+
instance.resize();
|
|
56
|
+
}, 500);
|
|
57
|
+
return ()=>{
|
|
58
|
+
clearTimeout(timer);
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
}, [
|
|
62
|
+
instance,
|
|
63
|
+
props,
|
|
64
|
+
refreshTag
|
|
65
|
+
]);
|
|
66
|
+
useEffect(()=>{
|
|
67
|
+
if (instance) instance.on('refresh', ()=>{
|
|
68
|
+
setRefreshTag((refreshTag)=>refreshTag + 1);
|
|
69
|
+
});
|
|
70
|
+
}, [
|
|
71
|
+
instance
|
|
72
|
+
]);
|
|
73
|
+
return /*#__PURE__*/ jsx(ChartWrapper, {
|
|
74
|
+
ref: boxRef,
|
|
75
|
+
className: props.className,
|
|
76
|
+
style: props.style
|
|
77
|
+
});
|
|
78
|
+
};
|
|
79
|
+
export { WinChart };
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { WinChart } from "./components/WinChart.js";
|
|
2
|
+
import { IChartInfo, IWinChartProps, WinChartType } from "./types/index.js";
|
|
3
|
+
import { EarthChart } from "./components/EarthChart.js";
|
|
4
|
+
import * as __rspack_external_echarts from "echarts";
|
|
5
|
+
const src = WinChart;
|
|
6
|
+
export { EarthChart, IChartInfo, IWinChartProps, WinChart, WinChartType, src as default, __rspack_external_echarts as echarts };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
var types_WinChartType = /*#__PURE__*/ function(WinChartType) {
|
|
2
|
+
WinChartType["MINI_AREA"] = "mini-area";
|
|
3
|
+
WinChartType["AREA"] = "area";
|
|
4
|
+
WinChartType["DUAL_LINE_BAR"] = "dual-line-bar";
|
|
5
|
+
WinChartType["STACK_DUAL_LINE_BAR"] = "stack-dual-line-bar";
|
|
6
|
+
WinChartType["COLUMN"] = "column";
|
|
7
|
+
WinChartType["STACK_COLUMN"] = "stack-column";
|
|
8
|
+
WinChartType["LINE"] = "line";
|
|
9
|
+
WinChartType["BAR"] = "bar";
|
|
10
|
+
WinChartType["STACK_BAR"] = "stack-bar";
|
|
11
|
+
WinChartType["FUNNEL"] = "funnel";
|
|
12
|
+
WinChartType["PIE"] = "pie";
|
|
13
|
+
WinChartType["CYCLE"] = "cycle";
|
|
14
|
+
WinChartType["RADAR"] = "radar";
|
|
15
|
+
return WinChartType;
|
|
16
|
+
}({});
|
|
17
|
+
export { types_WinChartType as WinChartType };
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const COLOR_LIST = [
|
|
2
|
+
'#3D84FF',
|
|
3
|
+
'#00DCF0',
|
|
4
|
+
'#FCBC26',
|
|
5
|
+
'#00DB75',
|
|
6
|
+
'#BDB8FF',
|
|
7
|
+
'#40B4FF',
|
|
8
|
+
'#FFA101',
|
|
9
|
+
'#90ABE0',
|
|
10
|
+
'#6EE67A',
|
|
11
|
+
'#6B84FF',
|
|
12
|
+
'#FA6B69'
|
|
13
|
+
];
|
|
14
|
+
const commonOpt = {
|
|
15
|
+
grid: {
|
|
16
|
+
top: 24,
|
|
17
|
+
left: 0,
|
|
18
|
+
right: 12,
|
|
19
|
+
bottom: 32,
|
|
20
|
+
containLabel: true
|
|
21
|
+
},
|
|
22
|
+
color: COLOR_LIST,
|
|
23
|
+
legend: {
|
|
24
|
+
itemWidth: 10,
|
|
25
|
+
itemHeight: 10,
|
|
26
|
+
bottom: 0,
|
|
27
|
+
type: 'scroll',
|
|
28
|
+
icon: 'circle'
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
export { COLOR_LIST, commonOpt };
|