@zgfe/modules-interval 1.0.23-zhongyuan.1 → 1.0.23-zhongyuan.10

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.
Files changed (31) hide show
  1. package/dist/esm/components/eventFilter/index.js +6 -5
  2. package/dist/esm/components/renderContent/styles/index.css +32 -0
  3. package/dist/esm/components/renderContent/styles/index.less +37 -36
  4. package/dist/esm/components/searchPanel/index.js +6 -1
  5. package/dist/esm/components/table/index.js +3 -2
  6. package/dist/esm/constants/code.d.ts +13 -0
  7. package/dist/esm/constants/code.js +13 -0
  8. package/dist/esm/modules/chart/customTooltip.js +5 -3
  9. package/dist/esm/modules/chart/customTooltip1.d.ts +7 -0
  10. package/dist/esm/modules/chart/customTooltip1.js +46 -0
  11. package/dist/esm/modules/chart/index.css +52 -0
  12. package/dist/esm/modules/chart/index.js +19 -8
  13. package/dist/esm/modules/chart/index.less +58 -58
  14. package/dist/esm/modules/chart/intervalChart copy.d.ts +4 -0
  15. package/dist/esm/modules/chart/intervalChart copy.js +299 -0
  16. package/dist/esm/modules/chart/intervalChart.js +321 -35
  17. package/dist/esm/modules/chart/types.d.ts +5 -0
  18. package/dist/esm/modules/content/index.js +50 -20
  19. package/dist/esm/modules/content/utils.d.ts +0 -1
  20. package/dist/esm/modules/content/utils.js +3 -4
  21. package/dist/esm/modules/home/demo/create.js +5 -3
  22. package/dist/esm/modules/home/demo/edit.js +132 -34
  23. package/dist/esm/modules/home/demo/index.js +1 -1
  24. package/dist/esm/modules/home/demo/scene.js +1 -1
  25. package/dist/esm/modules/home/index.js +8 -1
  26. package/dist/esm/modules/home/types.d.ts +0 -1
  27. package/dist/esm/modules/topPanel/index.js +39 -29
  28. package/dist/esm/modules/topPanel/styles/index.less +219 -219
  29. package/dist/esm/modules/topPanel/types.d.ts +1 -0
  30. package/dist/esm/utils/formData.js +31 -28
  31. package/package.json +3 -3
@@ -0,0 +1,299 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
3
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
4
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
5
+ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ import React, { useEffect, useRef, useState } from 'react';
8
+ import ReactECharts from 'echarts-for-react';
9
+ import * as echarts from 'echarts';
10
+ import { renderToString } from 'react-dom/server';
11
+ import CustomTooltip from "./customTooltip";
12
+ import { chartColors } from "../../constants";
13
+ import { getRandomColor } from "../../constants/color";
14
+ import { convertDateArray } from "../../utils/formData";
15
+ var _currentAxisBreaks = [{
16
+ start: 5000,
17
+ end: 100000,
18
+ gap: '1.5%'
19
+ }, {
20
+ start: 105000,
21
+ end: 3100000,
22
+ gap: '1.5%'
23
+ }];
24
+ var IntervalChart = function IntervalChart(props) {
25
+ var _useState = useState({}),
26
+ _useState2 = _slicedToArray(_useState, 2),
27
+ option = _useState2[0],
28
+ setOption = _useState2[1];
29
+ var chartRef = useRef(null);
30
+ useEffect(function () {
31
+ var _props$showList, _seriesData$series;
32
+ chartRef && chartRef.current.getEchartsInstance().clear();
33
+ var seriesData = props === null || props === void 0 ? void 0 : (_props$showList = props.showList) === null || _props$showList === void 0 ? void 0 : _props$showList.appData;
34
+ var params = props === null || props === void 0 ? void 0 : props.params;
35
+ var eCharts = {
36
+ tooltip: {
37
+ trigger: 'item',
38
+ // tooltip 跟随鼠标
39
+ position: function position(point, params, dom, rect, size) {
40
+ return [point[0] + 10, point[1] - 10];
41
+ },
42
+ axisPointer: {
43
+ type: 'line'
44
+ }
45
+ // formatter: (params: any) => {
46
+ // let tooltipString = ``;
47
+ // tooltipString += params.map((k) => {
48
+ // const item = seriesData?.series.find((it: any) => it.names[0] === k.name);
49
+ // return renderToString(<CustomTooltip series={item} payload={k} />);
50
+ // });
51
+ // return tooltipString;
52
+ // },
53
+ // formatter: (params: any) => {
54
+ // return renderToString(<CustomTooltip1 series={seriesData?.series} payload={params} />);
55
+ // },
56
+ },
57
+
58
+ legend: {
59
+ bottom: 0,
60
+ icon: 'circle',
61
+ type: 'scroll',
62
+ itemWidth: 10,
63
+ // 设置图例的宽度为10px
64
+ itemHeight: 10 // 设置图例的高度为10px
65
+ },
66
+
67
+ grid: {
68
+ top: '10',
69
+ left: '0',
70
+ right: '0',
71
+ bottom: props.onlyChart ? '0' : '68px',
72
+ containLabel: true
73
+ },
74
+ xAxis: {
75
+ type: 'category',
76
+ boundaryGap: true,
77
+ nameGap: 30,
78
+ data: convertDateArray(params, seriesData === null || seriesData === void 0 ? void 0 : seriesData.xAxis),
79
+ splitArea: {
80
+ show: false
81
+ },
82
+ splitLine: {
83
+ show: false
84
+ },
85
+ axisLine: {
86
+ lineStyle: {
87
+ color: '#E6E7EA' // 设置线条颜色
88
+ }
89
+ },
90
+
91
+ axisLabel: {
92
+ color: '#67727F' // 设置文字颜色
93
+ },
94
+
95
+ axisPointer: {
96
+ type: 'shadow'
97
+ }
98
+ },
99
+ yAxis: {
100
+ type: 'value',
101
+ splitLine: {
102
+ show: true,
103
+ lineStyle: {
104
+ type: 'dashed' // 设置线条类型为虚线
105
+ }
106
+ },
107
+
108
+ axisLabel: {
109
+ color: '#67727F' // 设置文字颜色
110
+ },
111
+
112
+ breaks: _currentAxisBreaks,
113
+ breakArea: {
114
+ itemStyle: {
115
+ opacity: 1
116
+ },
117
+ zigzagZ: 200
118
+ }
119
+ },
120
+ dataZoom: [{
121
+ type: 'inside',
122
+ start: 0,
123
+ end: 20,
124
+ right: 3,
125
+ height: 20 // 设置内置的dataZoom的高度
126
+ }, {
127
+ show: props.onlyChart ? false : true,
128
+ type: 'slider',
129
+ bottom: '38px',
130
+ xAxisIndex: [0],
131
+ start: 0,
132
+ end: 20,
133
+ right: 3,
134
+ height: 20 // 设置滑动条的高度
135
+ }],
136
+
137
+ series: seriesData === null || seriesData === void 0 ? void 0 : (_seriesData$series = seriesData.series) === null || _seriesData$series === void 0 ? void 0 : _seriesData$series.map(function (item, i) {
138
+ var _seriesData$series$i, _seriesData$series$i2;
139
+ // 生成随机颜色
140
+ var color = i < chartColors.length ? chartColors[i] : getRandomColor();
141
+ return {
142
+ type: 'boxplot',
143
+ datasetIndex: i,
144
+ name: seriesData === null || seriesData === void 0 ? void 0 : (_seriesData$series$i = seriesData.series[i]) === null || _seriesData$series$i === void 0 ? void 0 : _seriesData$series$i.names[0],
145
+ data: seriesData === null || seriesData === void 0 ? void 0 : (_seriesData$series$i2 = seriesData.series[i]) === null || _seriesData$series$i2 === void 0 ? void 0 : _seriesData$series$i2.values,
146
+ showBackground: true,
147
+ // 关键修改:背景改为透明
148
+ backgroundStyle: {
149
+ color: 'transparent'
150
+ },
151
+ emphasis: {
152
+ itemStyle: {
153
+ borderColor: item.type ? 'rgba(0,0,0,0.2)' : color // 设置盒子的颜色
154
+ },
155
+
156
+ tooltip: {
157
+ show: true,
158
+ // 单独配置series中的tooltip为显示
159
+ extraCssText: 'border: none;padding:0;border-radius:10px;background: rgba(250, 251, 253, 0.8)',
160
+ // 添加自定义的CSS样式,去掉边框
161
+ formatter: function formatter(params) {
162
+ var tooltipString = renderToString( /*#__PURE__*/React.createElement(CustomTooltip, {
163
+ series: seriesData === null || seriesData === void 0 ? void 0 : seriesData.series[i],
164
+ payload: params
165
+ }));
166
+ return tooltipString;
167
+ }
168
+ }
169
+ },
170
+ itemStyle: {
171
+ borderColor: item.type ? 'rgba(0,0,0,0.2)' : color
172
+ }
173
+ };
174
+ })
175
+ };
176
+ setOption(eCharts);
177
+ }, [props === null || props === void 0 ? void 0 : props.showList]);
178
+ var updateCollapseButton = function updateCollapseButton(params) {
179
+ // If there is any axis break expanded, we need to show the collapse button.
180
+ var needReset = false;
181
+ for (var i = 0; i < params.breaks.length; i++) {
182
+ var changedBreakItem = params.breaks[i];
183
+ if (changedBreakItem.isExpanded) {
184
+ needReset = true;
185
+ break;
186
+ }
187
+ }
188
+ setOption({
189
+ // Draw the collapse button.
190
+ graphic: [{
191
+ elements: [{
192
+ type: 'rect',
193
+ ignore: !needReset,
194
+ name: 'collapseAxisBreakBtn',
195
+ top: 5,
196
+ left: 5,
197
+ shape: {
198
+ r: 3,
199
+ width: 140,
200
+ height: 24
201
+ },
202
+ style: {
203
+ fill: '#eee',
204
+ stroke: '#999',
205
+ lineWidth: 1
206
+ },
207
+ textContent: {
208
+ type: 'text',
209
+ style: {
210
+ text: 'Collapse Axis Breaks',
211
+ fontSize: 13,
212
+ fontWeight: 'bold'
213
+ }
214
+ },
215
+ textConfig: {
216
+ position: 'inside'
217
+ }
218
+ }]
219
+ }]
220
+ });
221
+ };
222
+
223
+ // 获取实例
224
+ var _useState3 = useState(null),
225
+ _useState4 = _slicedToArray(_useState3, 2),
226
+ echartsInstance = _useState4[0],
227
+ setEchartsInstance = _useState4[1];
228
+ useEffect(function () {
229
+ console.log(chartRef.current.getEchartsInstance(), 'chartRef.current.getEchartsInstance()');
230
+ setEchartsInstance(chartRef.current.getEchartsInstance());
231
+ }, []);
232
+ return /*#__PURE__*/React.createElement(ReactECharts, {
233
+ ref: chartRef,
234
+ style: {
235
+ height: '431px',
236
+ padding: 24
237
+ },
238
+ option: option,
239
+ onEvents: {
240
+ axisbreakchanged: function axisbreakchanged(params) {
241
+ return updateCollapseButton(params);
242
+ },
243
+ mousemove: function mousemove(params) {
244
+ console.log('鼠标进入');
245
+ var pointInPixel = [params.offsetX, params.offsetY];
246
+ console.log(echartsInstance, 'echartsInstanceechartsInstance');
247
+
248
+ // 检查是否在网格区域内
249
+ if (echartsInstance && echartsInstance.containPixel('grid', pointInPixel)) {
250
+ var pointInGrid = echartsInstance && echartsInstance.convertFromPixel({
251
+ seriesIndex: 0
252
+ }, pointInPixel);
253
+ if (pointInGrid) {
254
+ var xIndex = Math.round(pointInGrid[0]);
255
+ var option = echartsInstance && echartsInstance.getOption();
256
+ var series = option.series;
257
+ var seriesCount = series.length;
258
+
259
+ // 获取网格区域信息
260
+ var grid = echartsInstance && echartsInstance.getModel().getComponent('grid', 0);
261
+ var gridRect = grid.coordinateSystem.getRect();
262
+
263
+ // 计算每个类目的宽度
264
+ var categoryCount = option.xAxis[0].data.length;
265
+ var categoryWidth = gridRect.width / categoryCount;
266
+
267
+ // 计算当前类目内的相对位置
268
+ var categoryStartX = gridRect.x + xIndex * categoryWidth;
269
+ var relativeX = params.offsetX - categoryStartX;
270
+
271
+ // 计算每个柱子的宽度(考虑柱子间距)
272
+ var barWidth = categoryWidth / seriesCount;
273
+
274
+ // 计算鼠标悬停在哪个系列的柱子上
275
+ var seriesIndex = Math.floor(relativeX / barWidth);
276
+
277
+ // 确保索引有效
278
+ if (seriesIndex >= 0 && seriesIndex < seriesCount && xIndex >= 0 && xIndex < categoryCount) {
279
+ // 显示跟随鼠标的 tooltip
280
+ echartsInstance && echartsInstance.dispatchAction({
281
+ type: 'showTip',
282
+ seriesIndex: seriesIndex,
283
+ dataIndex: xIndex,
284
+ position: [params.offsetX + 10, params.offsetY - 10]
285
+ });
286
+ }
287
+ }
288
+ }
289
+ },
290
+ mouseout: function mouseout() {
291
+ echartsInstance && echartsInstance.dispatchAction({
292
+ type: 'hideTip'
293
+ });
294
+ }
295
+ },
296
+ echarts: echarts
297
+ });
298
+ };
299
+ export default IntervalChart;