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
package/README.md
CHANGED
|
@@ -1,22 +1,70 @@
|
|
|
1
1
|
# win-chart
|
|
2
2
|
|
|
3
|
-
基于
|
|
3
|
+
基于 ECharts 6 + React 18 封装的通用图表组件库。
|
|
4
|
+
|
|
5
|
+
> **v3.0.0 全新升级**
|
|
6
|
+
>
|
|
7
|
+
> - 🚀 **更小体积**:支持 Tree Shaking,按需加载。
|
|
8
|
+
> - 📦 **双格式产物**:同时支持 ESM 和 CJS,兼容性更好。
|
|
9
|
+
> - ⚡️ **最新依赖**:适配 React 18 和 ECharts 6。
|
|
4
10
|
|
|
5
11
|
## Install
|
|
6
12
|
|
|
7
13
|
```bash
|
|
8
|
-
|
|
14
|
+
# 安装组件库
|
|
15
|
+
npm i win-chart
|
|
16
|
+
|
|
17
|
+
# 安装必要依赖 (Peer Dependencies)
|
|
18
|
+
npm i echarts react react-dom styled-components
|
|
9
19
|
```
|
|
10
20
|
|
|
11
21
|
## Usage
|
|
12
22
|
|
|
23
|
+
### 基础示例
|
|
24
|
+
|
|
13
25
|
```jsx
|
|
14
|
-
import WinChart from 'win-chart';
|
|
26
|
+
import { WinChart, WinChartType } from 'win-chart';
|
|
27
|
+
|
|
28
|
+
// 示例 1: 基础折线图
|
|
29
|
+
const LineDemo = () => {
|
|
30
|
+
const data = [
|
|
31
|
+
{ label: '2019', value: 100, type: '系列A' },
|
|
32
|
+
{ label: '2020', value: 120, type: '系列A' },
|
|
33
|
+
{ label: '2021', value: 150, type: '系列A' },
|
|
34
|
+
];
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<div style={{ height: 400 }}>
|
|
38
|
+
<WinChart
|
|
39
|
+
chartType={WinChartType.LINE}
|
|
40
|
+
data={data}
|
|
41
|
+
extraOption={{ title: { text: '折线图示例' } }}
|
|
42
|
+
/>
|
|
43
|
+
</div>
|
|
44
|
+
);
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// 示例 2: 基础柱状图
|
|
48
|
+
const BarDemo = () => {
|
|
49
|
+
const data = [
|
|
50
|
+
{ label: '产品A', value: 320, type: '销售额' },
|
|
51
|
+
{ label: '产品B', value: 450, type: '销售额' },
|
|
52
|
+
{ label: '产品C', value: 280, type: '销售额' },
|
|
53
|
+
];
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<div style={{ height: 400 }}>
|
|
57
|
+
<WinChart chartType={WinChartType.BAR} data={data} />
|
|
58
|
+
</div>
|
|
59
|
+
);
|
|
60
|
+
};
|
|
15
61
|
```
|
|
16
62
|
|
|
17
63
|
## 注意事项
|
|
18
64
|
|
|
19
|
-
1.
|
|
20
|
-
2.
|
|
21
|
-
|
|
22
|
-
|
|
65
|
+
1. **容器高度**:组件默认宽高为 `100%`,请确保外层容器有明确的高度,否则图表可能无法显示。
|
|
66
|
+
2. **核心属性**:
|
|
67
|
+
- `chartType`: 图表类型枚举(如 `WinChartType.LINE`, `WinChartType.BAR`)。
|
|
68
|
+
- `data`: 数据数组,每个元素需包含 `label` (X轴/分类), `value` (数值), `type` (分组/图例) 三个字段。
|
|
69
|
+
3. **双轴图表**:使用 `extraData` 属性传递右轴数据。注意:`data` 和 `extraData` 的 `label` 顺序必须严格一致且不可缺失。
|
|
70
|
+
4. **自定义配置**:通过 `extraOption` 传递原生 ECharts 配置项。该配置优先级最高,将通过 `deepmerge` 覆盖默认配置。
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
ChartWrapper: ()=>ChartWrapper
|
|
28
|
+
});
|
|
29
|
+
const external_styled_components_namespaceObject = require("styled-components");
|
|
30
|
+
const ChartWrapper = external_styled_components_namespaceObject.styled.div`
|
|
31
|
+
height: 100%;
|
|
32
|
+
`;
|
|
33
|
+
exports.ChartWrapper = __webpack_exports__.ChartWrapper;
|
|
34
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
35
|
+
"ChartWrapper"
|
|
36
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
37
|
+
Object.defineProperty(exports, '__esModule', {
|
|
38
|
+
value: true
|
|
39
|
+
});
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
EarthChart: ()=>EarthChart
|
|
28
|
+
});
|
|
29
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
30
|
+
const external_echarts_namespaceObject = require("echarts");
|
|
31
|
+
require("echarts-gl");
|
|
32
|
+
const external_react_namespaceObject = require("react");
|
|
33
|
+
const external_ChartWrapper_cjs_namespaceObject = require("./ChartWrapper.cjs");
|
|
34
|
+
const tool_cjs_namespaceObject = require("../utils/tool.cjs");
|
|
35
|
+
const mockPointsData = [];
|
|
36
|
+
for(let i = 0; i < 50; i++)mockPointsData.push({
|
|
37
|
+
name: `测试${i + 1}`,
|
|
38
|
+
value: [
|
|
39
|
+
150 * Math.random(),
|
|
40
|
+
50 * Math.random()
|
|
41
|
+
],
|
|
42
|
+
symbolSize: 8
|
|
43
|
+
});
|
|
44
|
+
const mockLinesData = [];
|
|
45
|
+
for(let i = 0; i < 10; i++)mockLinesData.push([
|
|
46
|
+
[
|
|
47
|
+
150 * Math.random(),
|
|
48
|
+
50 * Math.random()
|
|
49
|
+
],
|
|
50
|
+
[
|
|
51
|
+
150 * Math.random(),
|
|
52
|
+
50 * Math.random()
|
|
53
|
+
]
|
|
54
|
+
]);
|
|
55
|
+
const EarthChart = ({ className = '', style = {}, extraOption = {}, lineStyles = {}, pointsStyles = {}, pointsData = [], linesData = [], globeOption = {} })=>{
|
|
56
|
+
const boxRef = (0, external_react_namespaceObject.useRef)(null);
|
|
57
|
+
const [eChart, setEChart] = (0, external_react_namespaceObject.useState)();
|
|
58
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
59
|
+
const eChart = external_echarts_namespaceObject.init(boxRef.current);
|
|
60
|
+
setEChart(eChart);
|
|
61
|
+
const resize = (0, tool_cjs_namespaceObject.debounce)(eChart.resize, 500);
|
|
62
|
+
const handlerResize = ()=>{
|
|
63
|
+
resize();
|
|
64
|
+
};
|
|
65
|
+
globalThis.addEventListener('resize', handlerResize);
|
|
66
|
+
return ()=>{
|
|
67
|
+
globalThis.removeEventListener('resize', handlerResize);
|
|
68
|
+
};
|
|
69
|
+
}, []);
|
|
70
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
71
|
+
if (eChart) {
|
|
72
|
+
const series = [];
|
|
73
|
+
series.push({
|
|
74
|
+
type: 'lines3D',
|
|
75
|
+
name: "lines3D",
|
|
76
|
+
effect: {
|
|
77
|
+
show: true,
|
|
78
|
+
trailWidth: 2,
|
|
79
|
+
trailLength: 0.15,
|
|
80
|
+
trailOpacity: 1,
|
|
81
|
+
trailColor: 'rgb(30, 30, 60)'
|
|
82
|
+
},
|
|
83
|
+
lineStyle: {
|
|
84
|
+
width: 5,
|
|
85
|
+
color: 'rgb(50, 50, 150)',
|
|
86
|
+
opacity: 0.3
|
|
87
|
+
},
|
|
88
|
+
blendMode: 'lighter',
|
|
89
|
+
data: linesData,
|
|
90
|
+
...lineStyles
|
|
91
|
+
});
|
|
92
|
+
series.push({
|
|
93
|
+
type: 'scatter3D',
|
|
94
|
+
coordinateSystem: 'globe',
|
|
95
|
+
zlevel: 3,
|
|
96
|
+
rippleEffect: {
|
|
97
|
+
brushType: 'stroke'
|
|
98
|
+
},
|
|
99
|
+
label: {
|
|
100
|
+
fontSize: 8,
|
|
101
|
+
show: true,
|
|
102
|
+
position: 'right',
|
|
103
|
+
formatter: '{b}'
|
|
104
|
+
},
|
|
105
|
+
itemStyle: {
|
|
106
|
+
normal: {
|
|
107
|
+
color: '#f5f802'
|
|
108
|
+
}
|
|
109
|
+
},
|
|
110
|
+
data: pointsData,
|
|
111
|
+
...pointsStyles
|
|
112
|
+
});
|
|
113
|
+
eChart.setOption({
|
|
114
|
+
backgroundColor: '#000',
|
|
115
|
+
baseColor: '#000',
|
|
116
|
+
shading: 'realistic',
|
|
117
|
+
globe: {
|
|
118
|
+
environment: 'https://img.alicdn.com/imgextra/i2/O1CN017x8UE61p6wqej1Y0c_!!6000000005312-0-tps-2048-1024.jpg',
|
|
119
|
+
heightTexture: 'https://img.alicdn.com/imgextra/i2/O1CN01BB16kM1ILFttfdYZg_!!6000000000876-0-tps-4096-2048.jpg',
|
|
120
|
+
baseTexture: 'https://img.alicdn.com/imgextra/i4/O1CN01fs70Dq25ElSd8mU6C_!!6000000007495-0-tps-5400-2700.jpg',
|
|
121
|
+
shading: 'lambert',
|
|
122
|
+
light: {
|
|
123
|
+
ambient: {
|
|
124
|
+
intensity: 1
|
|
125
|
+
},
|
|
126
|
+
main: {
|
|
127
|
+
intensity: 0.1
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
viewControl: {
|
|
131
|
+
autoRotate: true,
|
|
132
|
+
distance: 230
|
|
133
|
+
},
|
|
134
|
+
left: '20%',
|
|
135
|
+
...globeOption
|
|
136
|
+
},
|
|
137
|
+
series: series,
|
|
138
|
+
...extraOption
|
|
139
|
+
});
|
|
140
|
+
const timer = setTimeout(()=>{
|
|
141
|
+
eChart.resize();
|
|
142
|
+
}, 500);
|
|
143
|
+
return ()=>{
|
|
144
|
+
clearTimeout(timer);
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
}, [
|
|
148
|
+
eChart,
|
|
149
|
+
extraOption,
|
|
150
|
+
globeOption,
|
|
151
|
+
lineStyles,
|
|
152
|
+
linesData,
|
|
153
|
+
pointsData,
|
|
154
|
+
pointsStyles
|
|
155
|
+
]);
|
|
156
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_ChartWrapper_cjs_namespaceObject.ChartWrapper, {
|
|
157
|
+
ref: boxRef,
|
|
158
|
+
className: className,
|
|
159
|
+
style: style
|
|
160
|
+
});
|
|
161
|
+
};
|
|
162
|
+
exports.EarthChart = __webpack_exports__.EarthChart;
|
|
163
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
164
|
+
"EarthChart"
|
|
165
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
166
|
+
Object.defineProperty(exports, '__esModule', {
|
|
167
|
+
value: true
|
|
168
|
+
});
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.d = (exports1, definition)=>{
|
|
5
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: definition[key]
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
})();
|
|
11
|
+
(()=>{
|
|
12
|
+
__webpack_require__.o = (obj, prop)=>Object.prototype.hasOwnProperty.call(obj, prop);
|
|
13
|
+
})();
|
|
14
|
+
(()=>{
|
|
15
|
+
__webpack_require__.r = (exports1)=>{
|
|
16
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
17
|
+
value: 'Module'
|
|
18
|
+
});
|
|
19
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
20
|
+
value: true
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
var __webpack_exports__ = {};
|
|
25
|
+
__webpack_require__.r(__webpack_exports__);
|
|
26
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
27
|
+
GanttChart: ()=>GanttChart
|
|
28
|
+
});
|
|
29
|
+
const jsx_runtime_namespaceObject = require("react/jsx-runtime");
|
|
30
|
+
const external_echarts_namespaceObject = require("echarts");
|
|
31
|
+
const external_react_namespaceObject = require("react");
|
|
32
|
+
const external_ChartWrapper_cjs_namespaceObject = require("./ChartWrapper.cjs");
|
|
33
|
+
const tool_cjs_namespaceObject = require("../utils/tool.cjs");
|
|
34
|
+
const data_cjs_namespaceObject = require("../utils/data.cjs");
|
|
35
|
+
const HEIGHT_RATIO = 0.6;
|
|
36
|
+
const DIM_CATEGORY_INDEX = 0;
|
|
37
|
+
const DIM_TIME_ARRIVAL = 1;
|
|
38
|
+
const DIM_TIME_DEPARTURE = 2;
|
|
39
|
+
const _cartesianXBounds = [];
|
|
40
|
+
const _cartesianYBounds = [];
|
|
41
|
+
const _rawData = data_cjs_namespaceObject.airportData;
|
|
42
|
+
const GanttChart = ({ className = '', style = {}, extraOption = {} })=>{
|
|
43
|
+
const boxRef = (0, external_react_namespaceObject.useRef)(null);
|
|
44
|
+
const [eChart, setEChart] = (0, external_react_namespaceObject.useState)();
|
|
45
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
46
|
+
const eChart = external_echarts_namespaceObject.init(boxRef.current);
|
|
47
|
+
setEChart(eChart);
|
|
48
|
+
const resize = (0, tool_cjs_namespaceObject.debounce)(eChart.resize, 500);
|
|
49
|
+
const handlerResize = ()=>{
|
|
50
|
+
resize();
|
|
51
|
+
};
|
|
52
|
+
globalThis.addEventListener('resize', handlerResize);
|
|
53
|
+
return ()=>{
|
|
54
|
+
globalThis.removeEventListener('resize', handlerResize);
|
|
55
|
+
};
|
|
56
|
+
}, []);
|
|
57
|
+
(0, external_react_namespaceObject.useEffect)(()=>{
|
|
58
|
+
if (eChart) {
|
|
59
|
+
eChart.setOption(makeOption());
|
|
60
|
+
const timer = setTimeout(()=>{
|
|
61
|
+
eChart.resize();
|
|
62
|
+
}, 500);
|
|
63
|
+
return ()=>{
|
|
64
|
+
clearTimeout(timer);
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
}, [
|
|
68
|
+
eChart,
|
|
69
|
+
extraOption
|
|
70
|
+
]);
|
|
71
|
+
return /*#__PURE__*/ (0, jsx_runtime_namespaceObject.jsx)(external_ChartWrapper_cjs_namespaceObject.ChartWrapper, {
|
|
72
|
+
ref: boxRef,
|
|
73
|
+
className: className,
|
|
74
|
+
style: style
|
|
75
|
+
});
|
|
76
|
+
};
|
|
77
|
+
function makeOption() {
|
|
78
|
+
return {
|
|
79
|
+
tooltip: {},
|
|
80
|
+
animation: false,
|
|
81
|
+
toolbox: {
|
|
82
|
+
left: 20,
|
|
83
|
+
top: 0,
|
|
84
|
+
itemSize: 20
|
|
85
|
+
},
|
|
86
|
+
title: {
|
|
87
|
+
text: 'Gantt of Airport Flight',
|
|
88
|
+
left: 'center'
|
|
89
|
+
},
|
|
90
|
+
grid: {
|
|
91
|
+
show: true,
|
|
92
|
+
top: 70,
|
|
93
|
+
bottom: 20,
|
|
94
|
+
left: 100,
|
|
95
|
+
right: 20,
|
|
96
|
+
backgroundColor: '#fff',
|
|
97
|
+
borderWidth: 0
|
|
98
|
+
},
|
|
99
|
+
xAxis: {
|
|
100
|
+
type: 'time',
|
|
101
|
+
position: 'top',
|
|
102
|
+
splitLine: {
|
|
103
|
+
lineStyle: {
|
|
104
|
+
color: [
|
|
105
|
+
'#E9EDFF'
|
|
106
|
+
]
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
axisLine: {
|
|
110
|
+
show: false
|
|
111
|
+
},
|
|
112
|
+
axisTick: {
|
|
113
|
+
lineStyle: {
|
|
114
|
+
color: '#929ABA'
|
|
115
|
+
}
|
|
116
|
+
},
|
|
117
|
+
axisLabel: {
|
|
118
|
+
color: '#929ABA',
|
|
119
|
+
inside: false,
|
|
120
|
+
align: 'center'
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
yAxis: {
|
|
124
|
+
axisTick: {
|
|
125
|
+
show: false
|
|
126
|
+
},
|
|
127
|
+
splitLine: {
|
|
128
|
+
show: false
|
|
129
|
+
},
|
|
130
|
+
axisLine: {
|
|
131
|
+
show: false
|
|
132
|
+
},
|
|
133
|
+
axisLabel: {
|
|
134
|
+
show: false
|
|
135
|
+
},
|
|
136
|
+
min: 0,
|
|
137
|
+
max: _rawData.parkingApron.data.length
|
|
138
|
+
},
|
|
139
|
+
series: [
|
|
140
|
+
{
|
|
141
|
+
id: 'flightData',
|
|
142
|
+
type: 'custom',
|
|
143
|
+
renderItem: renderGanttItem,
|
|
144
|
+
dimensions: _rawData.flight.dimensions,
|
|
145
|
+
encode: {
|
|
146
|
+
x: [
|
|
147
|
+
DIM_TIME_ARRIVAL,
|
|
148
|
+
DIM_TIME_DEPARTURE
|
|
149
|
+
],
|
|
150
|
+
y: DIM_CATEGORY_INDEX,
|
|
151
|
+
tooltip: [
|
|
152
|
+
DIM_CATEGORY_INDEX,
|
|
153
|
+
DIM_TIME_ARRIVAL,
|
|
154
|
+
DIM_TIME_DEPARTURE
|
|
155
|
+
]
|
|
156
|
+
},
|
|
157
|
+
data: _rawData.flight.data
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
type: 'custom',
|
|
161
|
+
renderItem: renderAxisLabelItem,
|
|
162
|
+
dimensions: _rawData.parkingApron.dimensions,
|
|
163
|
+
encode: {
|
|
164
|
+
x: -1,
|
|
165
|
+
y: 0
|
|
166
|
+
},
|
|
167
|
+
data: _rawData.parkingApron.data.map(function(item, index) {
|
|
168
|
+
return [
|
|
169
|
+
index
|
|
170
|
+
].concat(item);
|
|
171
|
+
})
|
|
172
|
+
}
|
|
173
|
+
]
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
function renderGanttItem(params, api) {
|
|
177
|
+
const categoryIndex = api.value(DIM_CATEGORY_INDEX);
|
|
178
|
+
const timeArrival = api.coord([
|
|
179
|
+
api.value(DIM_TIME_ARRIVAL),
|
|
180
|
+
categoryIndex
|
|
181
|
+
]);
|
|
182
|
+
const timeDeparture = api.coord([
|
|
183
|
+
api.value(DIM_TIME_DEPARTURE),
|
|
184
|
+
categoryIndex
|
|
185
|
+
]);
|
|
186
|
+
const coordSys = params.coordSys;
|
|
187
|
+
_cartesianXBounds[0] = coordSys.x;
|
|
188
|
+
_cartesianXBounds[1] = coordSys.x + coordSys.width;
|
|
189
|
+
_cartesianYBounds[0] = coordSys.y;
|
|
190
|
+
_cartesianYBounds[1] = coordSys.y + coordSys.height;
|
|
191
|
+
const barLength = timeDeparture[0] - timeArrival[0];
|
|
192
|
+
const barHeight = api.size([
|
|
193
|
+
0,
|
|
194
|
+
1
|
|
195
|
+
])[1] * HEIGHT_RATIO;
|
|
196
|
+
const x = timeArrival[0];
|
|
197
|
+
const y = timeArrival[1] - barHeight;
|
|
198
|
+
const flightNumber = api.value(3) + '';
|
|
199
|
+
const flightNumberWidth = external_echarts_namespaceObject.format.getTextRect(flightNumber).width;
|
|
200
|
+
const text = barLength > flightNumberWidth + 40 && x + barLength >= 180 ? flightNumber : '';
|
|
201
|
+
const rectNormal = clipRectByRect(params, {
|
|
202
|
+
x: x,
|
|
203
|
+
y: y,
|
|
204
|
+
width: barLength,
|
|
205
|
+
height: barHeight
|
|
206
|
+
});
|
|
207
|
+
const rectVIP = clipRectByRect(params, {
|
|
208
|
+
x: x,
|
|
209
|
+
y: y,
|
|
210
|
+
width: barLength / 2,
|
|
211
|
+
height: barHeight
|
|
212
|
+
});
|
|
213
|
+
const rectText = clipRectByRect(params, {
|
|
214
|
+
x: x,
|
|
215
|
+
y: y,
|
|
216
|
+
width: barLength,
|
|
217
|
+
height: barHeight
|
|
218
|
+
});
|
|
219
|
+
return {
|
|
220
|
+
type: 'group',
|
|
221
|
+
children: [
|
|
222
|
+
{
|
|
223
|
+
type: 'rect',
|
|
224
|
+
ignore: !rectNormal,
|
|
225
|
+
shape: rectNormal,
|
|
226
|
+
style: api.style()
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
type: 'rect',
|
|
230
|
+
ignore: !rectVIP && !api.value(4),
|
|
231
|
+
shape: rectVIP,
|
|
232
|
+
style: api.style({
|
|
233
|
+
fill: '#ddb30b'
|
|
234
|
+
})
|
|
235
|
+
},
|
|
236
|
+
{
|
|
237
|
+
type: 'rect',
|
|
238
|
+
ignore: !rectText,
|
|
239
|
+
shape: rectText,
|
|
240
|
+
style: api.style({
|
|
241
|
+
fill: 'transparent',
|
|
242
|
+
stroke: 'transparent',
|
|
243
|
+
text: text,
|
|
244
|
+
textFill: '#fff'
|
|
245
|
+
})
|
|
246
|
+
}
|
|
247
|
+
]
|
|
248
|
+
};
|
|
249
|
+
}
|
|
250
|
+
function renderAxisLabelItem(params, api) {
|
|
251
|
+
const y = api.coord([
|
|
252
|
+
0,
|
|
253
|
+
api.value(0)
|
|
254
|
+
])[1];
|
|
255
|
+
if (y < params.coordSys.y + 5) return;
|
|
256
|
+
return {
|
|
257
|
+
type: 'group',
|
|
258
|
+
position: [
|
|
259
|
+
10,
|
|
260
|
+
y
|
|
261
|
+
],
|
|
262
|
+
children: [
|
|
263
|
+
{
|
|
264
|
+
type: 'text',
|
|
265
|
+
style: {
|
|
266
|
+
x: 24,
|
|
267
|
+
y: -3,
|
|
268
|
+
text: api.value(1),
|
|
269
|
+
textVerticalAlign: 'bottom',
|
|
270
|
+
textAlign: 'center',
|
|
271
|
+
textFill: '#fff'
|
|
272
|
+
}
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
type: 'text',
|
|
276
|
+
style: {
|
|
277
|
+
x: 75,
|
|
278
|
+
y: -2,
|
|
279
|
+
textVerticalAlign: 'bottom',
|
|
280
|
+
textAlign: 'center',
|
|
281
|
+
text: api.value(2),
|
|
282
|
+
textFill: '#000'
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
]
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
function clipRectByRect(params, rect) {
|
|
289
|
+
return external_echarts_namespaceObject.graphic.clipRectByRect(rect, {
|
|
290
|
+
x: params.coordSys.x,
|
|
291
|
+
y: params.coordSys.y,
|
|
292
|
+
width: params.coordSys.width,
|
|
293
|
+
height: params.coordSys.height
|
|
294
|
+
});
|
|
295
|
+
}
|
|
296
|
+
exports.GanttChart = __webpack_exports__.GanttChart;
|
|
297
|
+
for(var __webpack_i__ in __webpack_exports__)if (-1 === [
|
|
298
|
+
"GanttChart"
|
|
299
|
+
].indexOf(__webpack_i__)) exports[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
300
|
+
Object.defineProperty(exports, '__esModule', {
|
|
301
|
+
value: true
|
|
302
|
+
});
|