dcim-topology2d 2.0.5 → 2.0.7

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 (35) hide show
  1. package/chart-diagram/src/echarts/index.js +21 -13
  2. package/chart-diagram/src/utils/changeOptions.js +7 -1
  3. package/chart-diagram/src/utils/conversion.d.ts +1 -0
  4. package/chart-diagram/src/utils/conversion.js +117 -23
  5. package/chart-diagram/src/utils/formatter.d.ts +1 -0
  6. package/chart-diagram/src/utils/formatter.js +129 -0
  7. package/chart-diagram/src/utils/index.d.ts +1 -0
  8. package/chart-diagram/src/utils/index.js +1 -0
  9. package/chart-diagram/src/utils/render.d.ts +3 -1
  10. package/chart-diagram/src/utils/render.js +83 -8
  11. package/core/src/common.js +53 -18
  12. package/core/src/core.js +25 -0
  13. package/core/src/divLayer.js +1 -1
  14. package/core/src/element/common.js +4 -2
  15. package/core/src/element/select.js +29 -0
  16. package/core/src/element/tab.js +5 -1
  17. package/core/src/healps/changeData.js +1 -1
  18. package/core/src/middles/nodes/formoverflow.js +61 -0
  19. package/core/src/middles/nodes/formselect.js +16 -8
  20. package/core/src/middles/nodes/index.d.ts +2 -1
  21. package/core/src/middles/nodes/index.js +1 -0
  22. package/core/src/models/node.js +7 -0
  23. package/core/src/options.d.ts +1 -1
  24. package/core/src/preview.js +28 -1
  25. package/core/src/store/data.d.ts +7 -0
  26. package/core/src/store/data.js +17 -1
  27. package/core/src/utils/assignment.js +2 -2
  28. package/core/src/utils/construction.d.ts +2 -0
  29. package/core/src/utils/construction.js +1 -0
  30. package/core/src/utils/conversion.d.ts +2 -1
  31. package/core/src/utils/conversion.js +52 -0
  32. package/core/src/utils/params.js +3 -0
  33. package/myShape-diagram/index.js +155 -152
  34. package/package.json +1 -1
  35. package/static/echartsDefaultData.js +11 -3
@@ -7,12 +7,14 @@ import {
7
7
  setMap3dBarOptions,
8
8
  setMapTopOptions,
9
9
  setMapGlobalOptions,
10
- setMapDataOptions
10
+ setMapDataOptions,
11
+ initBindTabSetting
11
12
  } from '../utils';
12
13
  import {echartsTypeMap} from '../../../static';
13
14
 
14
15
  export function echarts(ctx, node) {
15
- if (!(commonStore[node.TID] && commonStore[node.TID].data.dataResize)) return;
16
+ const currentStore = commonStore[node.TID];
17
+ if (!(currentStore && currentStore.data.dataResize)) return;
16
18
  //console.log('echarts绘制-----node', node);
17
19
  // if(currentElement) currentElement.style.display = !node.visible ? 'none': 'block';
18
20
  // if(!node.visible) return;
@@ -32,7 +34,7 @@ export function echarts(ctx, node) {
32
34
  if (!node.elementId) {
33
35
  node.elementId = s8()
34
36
  }
35
- let echartsData = commonStore[node.TID].echartsDataPool[node.id];
37
+ let echartsData = currentStore.echartsDataPool[node.id];
36
38
  if (!node.elementLoaded && !(echartsData && echartsData.div)) {
37
39
  if(!echartsData) {
38
40
  echartsData = {
@@ -51,7 +53,7 @@ export function echarts(ctx, node) {
51
53
  setTimeout(function () {
52
54
  echartsData.chart.resize()
53
55
  });
54
- commonStore[node.TID].echartsDataPool[node.id] = echartsData;
56
+ currentStore.echartsDataPool[node.id] = echartsData;
55
57
  }
56
58
  if (!node.elementRendered) {
57
59
  const appearance = node.appearance;
@@ -59,12 +61,17 @@ export function echarts(ctx, node) {
59
61
  setTimeout(function () {
60
62
  let option = node.data.echarts.option;
61
63
  if(!(echartsData && echartsData.chart)) return;
62
- const isLocked = commonStore[node.TID] && commonStore[node.TID].data.locked;
63
- if (!isLocked || !commonStore[node.TID].echartsOptionsPool[node.id]) {
64
+ const pageZoom = currentStore.data.pageZoom;
65
+ echartsData.div.style.transform = `scale(${pageZoom})`;
66
+ echartsData.div.style.transformOrigin = '0 0';
67
+ if(node.data.params) node.data.params.tabCorrelationType = echartsData.tabCorrelationType || ''; // 统计图与Tab关联
68
+ const isLocked = currentStore.data.locked;
69
+ if (!isLocked || !currentStore.echartsOptionsPool[node.id]) {
70
+ const tabData = initBindTabSetting(node); // 初始化Tabs数据配置
64
71
  // 【未锁定(编辑)状态, options未初始化的状态】
65
72
  if (!appearance.type) appearance.type = echartsTypeMap[`type_${option.displayMode}`]; // 兼容旧数据配置
66
- // 公共配置 Top排行榜跳过公共属性配置
67
- if (option.displayMode !== 4) setMapGlobalOptions(option, node);
73
+ // 公共配置 Top排行榜散点图跳过公共属性配置
74
+ if (option.displayMode !== 4 && option.displayMode !== 7) setMapGlobalOptions(option, node);
68
75
  // 折线图和柱状图
69
76
  if (['line', 'bar'].includes(appearance.type)) setMapLineBarOptions(option, node);
70
77
  // 仪表盘
@@ -74,22 +81,23 @@ export function echarts(ctx, node) {
74
81
  // 3d 柱状图
75
82
  if (appearance.type === '3dBar') setMap3dBarOptions(option, node);
76
83
  // Top排行榜
77
- if (appearance.type === 'TOP') setMapTopOptions(option, node);
84
+ if (appearance.type.includes('TOP')) setMapTopOptions(option, node);
78
85
  //option.title = appearance.title;
79
86
  option.backgroundColor = appearance.backgroundColor;
80
- commonStore[node.TID].echartsOptionsPool[node.id] = {
87
+ currentStore.echartsOptionsPool[node.id] = {
81
88
  option: JSON.parse(JSON.stringify(option)),
82
89
  data: {
90
+ TID: node.TID,
83
91
  appearance,
84
92
  id: node.id,
85
- params: node.data.params
93
+ params: node.data.params,
94
+ tabData
86
95
  }
87
96
  };
88
97
  if (!isLocked) echartsData.chart.clear();
89
98
  }
90
99
  // echarts 数据渲染更新
91
- setMapDataOptions(option, node);
92
-
100
+ setMapDataOptions(option, currentStore.echartsOptionsPool[node.id].data);
93
101
  node.elementRendered = true;
94
102
  })
95
103
  }
@@ -82,7 +82,11 @@ export function setChartXAxisData(xAxis, appearance) {
82
82
  //return xAxis;
83
83
  }
84
84
 
85
- // 图表Y轴数据
85
+ /**
86
+ * 图表Y轴数据
87
+ * @param yAxis Y轴配置数据
88
+ * @param appearance 图表自定义配置
89
+ */
86
90
  export function setChartYAxisData(yAxis, appearance) {
87
91
  if (typeof appearance.ySplitLineShow !== 'boolean') {
88
92
  appearance.ySplitLineShow = yAxis[0].splitLine.show;
@@ -92,9 +96,11 @@ export function setChartYAxisData(yAxis, appearance) {
92
96
  }
93
97
  for (let i = 0; i < yAxis.length; i++) {
94
98
  const item = yAxis[i];
99
+ if(!item.axisLabel) item.axisLabel = {};
95
100
  if (!item.axisLabel.textStyle) {
96
101
  item.axisLabel.textStyle = JSON.parse(JSON.stringify(echartsYAxisDefaultStyleData['y1axisLabelTextStyle']));
97
102
  }
103
+ if(!item.splitLine) item.splitLine = {};
98
104
  if (!item.splitLine.lineStyle) {
99
105
  item.splitLine.lineStyle = JSON.parse(JSON.stringify(echartsYAxisDefaultStyleData['ysplitLineLineStyle']));
100
106
  }
@@ -6,6 +6,7 @@ interface echartsOptions {
6
6
  tooltip: null
7
7
  }
8
8
  export declare function getXYAxisLabelVal(index: number, intervalNum: number, value: any): string;
9
+ export declare function initBindTabSetting(node: any): string;
9
10
  export declare function setMapLineBarOptions(option: echartsOptions, node: any): void;
10
11
  export declare function setMapGaugeOptions(option: echartsOptions, node: any): void;
11
12
  export declare function setMapRingOptions(option: echartsOptions, node: any): void;
@@ -1,4 +1,4 @@
1
- import {echartsDataRoom, echartsColorData} from '../../../static';
1
+ import {echartsDataRoom, echartsColorData, rankingTopImageName} from '../../../static';
2
2
  import {
3
3
  setSeriesRenderGroup,
4
4
  drawGraphicShape,
@@ -7,7 +7,8 @@ import {
7
7
  setChartYAxisData,
8
8
  setLineSeriesStyleData,
9
9
  setRingPreSeriesOptions,
10
- setRingProSeriesOptions
10
+ setRingProSeriesOptions,
11
+ mapFormatterSet
11
12
  } from '../utils';
12
13
  import {
13
14
  gaugeNormalAuto,
@@ -15,9 +16,11 @@ import {
15
16
  pieRingAssetTotalAuto,
16
17
  pieRingProportionAuto,
17
18
  pieRingNormalAuto,
18
- topRankingListAuto
19
+ topRankingListAuto,
20
+ scatterDataAuto,
21
+ barPileStaticDataAuto
19
22
  } from './render';
20
- import {commonStore} from "../../../core";
23
+ import {commonStore, echartsStaticType} from "../../../core";
21
24
 
22
25
  export function getXYAxisLabelVal(index, intervalNum, value) {
23
26
  if (index === 0 || index % intervalNum === 0) {
@@ -27,6 +30,26 @@ export function getXYAxisLabelVal(index, intervalNum, value) {
27
30
  }
28
31
  }
29
32
 
33
+ /**
34
+ * 初始化图表与tabs关联的配置数据
35
+ * @param node 元件节点
36
+ */
37
+ export function initBindTabSetting(node) {
38
+ const tabStaticKey = node.tags && node.tags.find((tag) => {return tag.includes('switchTabType')});
39
+ const switchTabData = tabStaticKey && commonStore[node.TID].switchTabDataPool[`${tabStaticKey}Data`];
40
+ if(switchTabData) {
41
+ const tabNode = Object.values(switchTabData)[0];
42
+ const tabEventNode = tabNode.events.find((ev) => {return ev.action === 8});
43
+ const tabStaticType = tabEventNode && tabEventNode.dcimStaticForType || '';
44
+ node.data.params.staticForType = tabStaticType;
45
+ return {
46
+ type: tabStaticType,
47
+ data: tabNode.tabData
48
+ };
49
+ }
50
+ return null;
51
+ }
52
+
30
53
  // 自动滑动展示数据
31
54
  export function setMapAutoMoveOptions(option, chartNode, node, callback) {
32
55
  option.dataZoom = echartsDataRoom;
@@ -113,13 +136,13 @@ export function setMapRingOptions(option, node) {
113
136
  //const chartOption = JSON.parse(JSON.stringify(option));
114
137
  const appearance = node.appearance;
115
138
  if(appearance.type === 'ringPre'){
116
-
139
+
117
140
  setRingPreSeriesOptions(option, appearance);
118
-
141
+
119
142
  }else if(appearance.type === 'ringPro'){
120
-
143
+
121
144
  setRingProSeriesOptions(option, appearance);
122
-
145
+
123
146
  }else {
124
147
  const seriesNode = option.series[0];
125
148
  if ((!appearance.label || typeof appearance.label.showValue !== 'boolean')) {
@@ -131,16 +154,41 @@ export function setMapRingOptions(option, node) {
131
154
  seriesNode.label = {
132
155
  normal: {
133
156
  show: true,
134
- position: 'outside'
157
+ position: 'outside',
158
+ color: appearance.label.color || '',
159
+ fontSize: appearance.label.fontSize || '12'
135
160
  }
136
161
  };
137
- seriesNode.label.normal.formatter = (data) => {
138
- if (appearance.label.showValue === true) {
139
- return `${data.name}:${data.value}${appearance.label.unit}`;
140
- } else {
141
- return `${data.name}`;
162
+
163
+ seriesNode.labelLine = appearance.labelLine && {...appearance.labelLine} || {};
164
+
165
+ if(seriesNode.labelLine.lineStyle && !seriesNode.labelLine.lineStyle.color) {
166
+ delete seriesNode.labelLine.lineStyle['color'];
167
+ }
168
+
169
+ const rich = {};
170
+
171
+ if(appearance.cir && appearance.cir.show) {
172
+ rich.cir = {...appearance.cir};
173
+ if(!rich.cir.borderColor) rich.cir.borderColor = 'auto';
174
+ if(!rich.cir.backgroundColor) rich.cir.backgroundColor = 'transparent';
175
+ }
176
+
177
+ if(appearance.labelDetail && appearance.labelDetail.length) {
178
+ // 环形明细展示配置,线条样式配置
179
+ rich.a = {
180
+ color: appearance.label.color || '',
181
+ fontSize: appearance.label.fontSize || '12'
182
+ };
183
+ for (let i = 0; i < appearance.labelDetail.length; i++) {
184
+ const detail = appearance.labelDetail[i];
185
+ rich[`b${i+1}`] = {
186
+ color: detail.color,
187
+ fontSize: detail.fontSize || '12'
188
+ };
142
189
  }
143
190
  }
191
+ seriesNode.label.normal.rich = rich;
144
192
  }
145
193
  }
146
194
 
@@ -179,9 +227,28 @@ export function setMapTopOptions(option, node) {
179
227
  //const chartOption = JSON.parse(JSON.stringify(option));
180
228
  const appearance = node.appearance;
181
229
  Object.assign(option.grid, appearance.grid);
230
+ if(!appearance.type.includes('TOPRanking')) return;
231
+ const yNode = option.yAxis[0];
232
+ if(yNode.axisLabel.rich['a1']) return;
233
+ for (let i = 0, length = yNode.data.length; i < length; i++) {
234
+ const order = i + 1;
235
+ yNode.axisLabel.rich[`a${order}`] = {
236
+ width: 30,
237
+ height: 17,
238
+ lineHeight: 22,
239
+ verticalAlign: 'bottom',
240
+ backgroundColor: {
241
+ image: `../../../images/TOP/NO-${order}-${rankingTopImageName[i]}.png`
242
+ }
243
+ }
244
+ }
182
245
  }
183
246
 
184
- // 公共配置
247
+ /**
248
+ * 公共配置
249
+ * @param option 图表配置数据
250
+ * @param node 元件数据
251
+ */
185
252
  export function setMapGlobalOptions(option, node) {
186
253
  // const chartOption = JSON.parse(JSON.stringify(option));
187
254
  const appearance = node.appearance;
@@ -196,7 +263,7 @@ export function setMapGlobalOptions(option, node) {
196
263
  // 图表Y轴数据
197
264
  if (option.yAxis) setChartYAxisData(option.yAxis, appearance);
198
265
  // 图表图例数据
199
- if (option.legend) setChartLegendData(option.legend, appearance);
266
+ //if (option.legend) setChartLegendData(option.legend, appearance);
200
267
  // 曲线样式数据
201
268
  if (appearance.type.includes('line')) setLineSeriesStyleData(option.series, appearance);
202
269
  }
@@ -205,24 +272,50 @@ export function setMapGlobalOptions(option, node) {
205
272
  export function setMapDataOptions(option, node) {
206
273
  const optionNode = commonStore[node.TID].echartsOptionsPool[node.id].option;
207
274
  const appearance = node.appearance;
208
- const params = node.data ? node.data.params : node.params;
275
+ const params = node.params;
209
276
  // 3d 柱状图
210
277
  if (appearance.type === '3dBar') renderMap3dBarSeriesItem(optionNode.series[0], appearance);
211
278
  const displayMode = parseInt(option.displayMode); // 图表类型
212
- const staticForType = params && params.staticForType || ''; //统计类型:日,周,月,年,实时
279
+ const staticForType = params && params.staticForType || ''; //统计类型:日,周,月,年,实时,其他
213
280
  const syncEchartsData = commonStore[node.TID].echartsRealDataPool[node.id]; // 统计图实时数据
214
- const staticTypeData = staticForType ? syncEchartsData && syncEchartsData[`${staticForType}_Data`] : syncEchartsData; // 统计类型数据
281
+ let staticTypeData = null; // 统计类型数据
282
+ if(staticForType === 'OTHER'){
283
+ // 其他类型,类型中的数据通常统计的都是历史数据,日、周、月、年、实时中的某一类,通常搭配分组统计使用。
284
+ // 类型中绑定一个测点为一个类型,绑定多个测点为多个类型。比如:有电功率和功率因数为两个分类,图表分组中分类数据绑定时就要同时绑定有电功率和功率因数两个测点,否则无法实现切换
285
+ for (let i = 0 ; i < echartsStaticType.length; i++) {
286
+ const chartData = syncEchartsData && syncEchartsData[`${echartsStaticType[i]}_Data`];
287
+ if(chartData) staticTypeData = chartData;
288
+ }
289
+ }else {
290
+ // 日,周,月,年,实时类型,不与分组统计一起使用
291
+ staticTypeData = staticForType ? syncEchartsData && syncEchartsData[`${staticForType}_Data`] : syncEchartsData;
292
+ }
215
293
  // 实时数据加载
216
294
  if(staticTypeData) {
217
295
 
218
296
  if (displayMode === 1 || displayMode === 2) { // 折线图,柱状图
219
297
 
220
- lineBarDataAuto(optionNode, params, staticTypeData);
298
+ if(node.tabData && node.tabData.data.state && optionNode.yAxis[0].max) Object.assign(optionNode.yAxis[0], node.tabData.data); //若Tabs切换配置了数据,则修改Y轴原有配置
299
+
300
+ if(appearance.type === 'barPileStatic') {
301
+
302
+ barPileStaticDataAuto(optionNode, staticTypeData, appearance);
303
+
304
+ }else {
305
+
306
+ lineBarDataAuto(optionNode, params, staticTypeData);
307
+
308
+ }
221
309
 
222
310
  }
223
- if(displayMode === 4) { // top排行榜
311
+ if(displayMode === 4) { // top排行榜-电量仪
224
312
 
225
- topRankingListAuto(optionNode, staticTypeData);
313
+ topRankingListAuto(optionNode, staticTypeData, appearance);
314
+
315
+ }
316
+ if(displayMode === 7) { // 散点图
317
+
318
+ scatterDataAuto(optionNode, staticTypeData);
226
319
 
227
320
  }
228
321
  if (displayMode === 5 || displayMode === 3) { // 饼图/环形图
@@ -268,7 +361,6 @@ export function setMapDataOptions(option, node) {
268
361
  if (item.data) {
269
362
  optionNode.yAxis[i].data = item.data;
270
363
  }
271
- ;
272
364
  }
273
365
  }
274
366
  if (option.series) {
@@ -280,6 +372,8 @@ export function setMapDataOptions(option, node) {
280
372
  }
281
373
  }
282
374
 
375
+ mapFormatterSet(appearance, optionNode, staticTypeData);
376
+
283
377
  const currentChartNode = commonStore[node.TID].echartsDataPool[node.id];
284
378
  const mapChart = currentChartNode.chart;
285
379
  clearInterval(currentChartNode.timeTicket);
@@ -0,0 +1 @@
1
+ export declare function mapFormatterSet(appearance: object, option: any, data: any): void;
@@ -0,0 +1,129 @@
1
+ import {rankingTopImageName, rankingTopColorList} from '../../../static';
2
+
3
+ export function mapFormatterSet(appearance, options, data) {
4
+ if(appearance.type.includes('ring') || appearance.type.includes('pie')) {
5
+ const seriesNode = options.series[0];
6
+ if(seriesNode.label && seriesNode.label.normal &&!seriesNode.label.normal.formatter) {
7
+ setMapRingOptionsFormatter(appearance, seriesNode);
8
+ }
9
+ }
10
+ if(appearance.type.includes('lineTwins')) setMapLineTwinsFormatter(appearance, options);
11
+ if(appearance.type.includes('scatter')) setMapScatterFormatter(options);
12
+ if(appearance.type.includes('TOPRanking')) setMapTopScoreFormatter(options, data, appearance);
13
+ if(appearance.type.includes('barPileStatic')) setMapBarPileStaticFormatter(appearance, options);
14
+ }
15
+ function setMapLineTwinsFormatter(appearance, options) {
16
+ if(!options.tooltip.formatter && appearance.tooltipUnit) {
17
+ options.tooltip.formatter = function (params) {
18
+ let relVal = params[0].name;
19
+ for (var i = 0, l = params.length; i < l; i++) {
20
+ const unit = appearance.tooltipUnit[i] || '';
21
+ relVal +=
22
+ "<br/>" +
23
+ params[i].marker +
24
+ params[i].seriesName +
25
+ " : " +
26
+ params[i].value +
27
+ unit;
28
+ }
29
+ return relVal;
30
+ }
31
+ }
32
+ }
33
+ // 堆叠统计
34
+ function setMapBarPileStaticFormatter(appearance, options) {
35
+ if(!options.tooltip.formatter){
36
+ options.tooltip.formatter = function(param) {
37
+ return `<div style="border-bottom: 1px solid rgba(255,255,255,.3); font-size: 12px;margin-bottom: 5px;">${param[0].name}</div>${param[0].seriesName}:${param[0].value}<br>${param[1].seriesName}:${appearance.total[param[1].dataIndex]}`;
38
+ }
39
+ }
40
+ if(!options.series[1].label.formatter){
41
+ options.series[1].label.formatter = function(param) {
42
+ if(!param.value) return '';
43
+ let value = '';
44
+ if(appearance.totalStyle) {
45
+ value = `${appearance.totalStyle.label ? appearance.total[param.dataIndex] : ''}${appearance.totalStyle.unit}`;
46
+ }else {
47
+ value = `${appearance.total[param.dataIndex]}`;
48
+ }
49
+ return value;
50
+ }
51
+ }
52
+ }
53
+ // Top排行榜自定义展示配置
54
+ function setMapTopScoreFormatter(options, data, appearance) {
55
+ const yNode = options.yAxis[0];
56
+ if(!yNode.axisLabel.formatter) {
57
+ yNode.axisLabel.formatter = function(value, i) {
58
+ return `{a${i+1}|}{b|${value}}`;
59
+ }
60
+ }
61
+ const seriesNode = options.series[0];
62
+ if(appearance.total && appearance.total.length) {
63
+ const realData = data && data.seriesData && data.seriesData[0] && data.seriesData[0].data;
64
+ if(realData && realData.length) {
65
+ seriesNode.data = appearance.total;
66
+ seriesNode.itemStyle.normal.label.formatter = function(param) {
67
+ return `${realData[param.dataIndex]}${appearance.unit}`;
68
+ }
69
+ }
70
+ }
71
+ if(seriesNode.itemStyle.normal.color) return;
72
+ for (let i = 0; i < options.series.length; i++) {
73
+ const node = options.series[i];
74
+ node.itemStyle.normal.color = function(params) {
75
+ return rankingTopColorList[params.dataIndex];
76
+ }
77
+ }
78
+ }
79
+ // 散点图series自定义展示配置
80
+ function setMapScatterFormatter(options) {
81
+ const seriesNode = options.series[0];
82
+ if(!options.tooltip.formatter) {
83
+ options.tooltip.formatter = function(param) {
84
+ const value = param.value;
85
+ // prettier-ignore
86
+ return `<div style="border-bottom: 1px solid rgba(255,255,255,.3); font-size: 12px;padding-bottom: 5px;margin-bottom: 5px;">${param.seriesName}告警</div>告警等级:${value[1]}<br>告警数量:${value[2]}`;
87
+ }
88
+ }
89
+ if(!options.yAxis[0].axisLabel.formatter) {
90
+ options.yAxis[0].axisLabel.formatter = function (value, index) {
91
+ return `{f${index+1}|${value}}`;
92
+ }
93
+ }
94
+ if(seriesNode.symbolSize) return;
95
+ for (let i = 0; i < options.series.length; i++) {
96
+ const node = options.series[i];
97
+ node.symbolSize = function(d) {
98
+ let markSize = Math.sqrt(d[2]) * 2;
99
+ if(markSize < 6) markSize = 6;
100
+ if(markSize > 20) markSize = 20;
101
+ //if(!markSize) markSize = 1;
102
+ return markSize;
103
+ }
104
+ node.label.emphasis.formatter = function(param) {
105
+ return param.data[0];
106
+ }
107
+ }
108
+ }
109
+ // 环形图自定义展示配置
110
+ function setMapRingOptionsFormatter(appearance, seriesNode) {
111
+ if(appearance.labelDetail && appearance.labelDetail.length) {
112
+ seriesNode.label.normal.formatter = (data) => {
113
+ let result = `{a|${data.name}}\n{cir|}`;
114
+ for (let i = 0; i < appearance.labelDetail.length; i++) {
115
+ const detail = appearance.labelDetail[i];
116
+ result += '\n'+`{b${i+1}|${detail.title}${i === 0 ? data.value : data[`value${i+1}`]}${detail.unit}}`;
117
+ }
118
+ return result;
119
+ }
120
+ }else {
121
+ seriesNode.label.normal.formatter = (data) => {
122
+ if (appearance.label.showValue === true) {
123
+ return `${data.name}:${data.value}${appearance.label.unit}`;
124
+ } else {
125
+ return `${data.name}`;
126
+ }
127
+ }
128
+ }
129
+ }
@@ -1,3 +1,4 @@
1
1
  export * from './conversion';
2
2
  export * from './drawGraphic';
3
3
  export * from './changeOptions';
4
+ export * from './formatter';
@@ -1,3 +1,4 @@
1
1
  export * from './conversion';
2
2
  export * from './drawGraphic';
3
3
  export * from './changeOptions';
4
+ export * from './formatter';
@@ -1,5 +1,7 @@
1
1
  export declare function lineBarDataAuto(option: any, params: {}, data: {}): void;
2
- export declare function topRankingListAuto(option: any, data: {}): void;
2
+ export declare function barPileStaticDataAuto(option: any, data: {}, appearance: {}): void;
3
+ export declare function topRankingListAuto(option: any, data: {}, appearance: {}): void;
4
+ export declare function scatterDataAuto(option: any, data: {}): void;
3
5
  export declare function pieRingAssetTotalAuto(option: any, data: {}, total: number, count: number): void;
4
6
  export declare function pieRingProportionAuto(option: any, data: {}, proportion: number): void;
5
7
  export declare function pieRingNormalAuto(option: any, data: {}): void;
@@ -10,6 +10,13 @@ export function lineBarDataAuto(option, params, data) {
10
10
  const seriesNodes = option.series;
11
11
  if(data && data.XData) option.xAxis[0].data = data.XData;
12
12
  if(!(data && data.seriesData && data.seriesData.length)) return;
13
+ if(params.tabCorrelationType) {
14
+ // 如果操作类型是select下拉分组下的tab切换,执行下面的逻辑
15
+ const realSeriesNode = data.seriesData[params.tabVisitOrder || 0];
16
+ seriesNodes[0].data = realSeriesNode.data;
17
+ if(realSeriesNode.name) seriesNodes[0].name = realSeriesNode.name;
18
+ return;
19
+ }
13
20
  if(seriesNodes.length > 1 || params && params.curveNum > 1){
14
21
  // 双曲线|柱状
15
22
  const legendData = [];
@@ -39,21 +46,89 @@ export function lineBarDataAuto(option, params, data) {
39
46
  }
40
47
  }
41
48
 
49
+ export function barPileStaticDataAuto(option, data, appearance) {
50
+ if(data && data.XData) option.yAxis[0].data = data.XData;
51
+ if(!(data && data.seriesData && data.seriesData.length)) return;
52
+ const seriesData = data.seriesData[0].data;
53
+ option.series[0].data = seriesData;
54
+ const data2 = [];
55
+ for (let i = 0; i < seriesData.length; i++) {
56
+ const dr = appearance.total[i] - Number(seriesData[i]);
57
+ data2.push(dr);
58
+ }
59
+ option.series[1].data = data2;
60
+ }
61
+
42
62
  /**
43
- * TOP排行榜实时数据
63
+ * TOP排行-电量仪实时数据
44
64
  * @param option 图表配置数据
45
65
  * @param data 实时图表数据
66
+ * @param appearance 自定义配置数据
46
67
  */
47
- export function topRankingListAuto(option, data) {
68
+ export function topRankingListAuto(option, data, appearance) {
48
69
  if(data && data.XData) option.yAxis[0].data = data.XData;
49
70
  if(!(data && data.seriesData && data.seriesData.length)) return;
50
- const seriesData = data.seriesData[0].data;
51
- option.yAxis[1].data = seriesData;
71
+ if(appearance.type === 'TOPRanking') {
72
+ if(appearance.total && appearance.total.length) return;
73
+ option.series[0].data = data.seriesData[0].data;
74
+ }else {
75
+ const seriesData = data.seriesData[0].data;
76
+ option.yAxis[1].data = seriesData;
77
+ for (let i = 0; i < option.series.length; i++) {
78
+ const node = option.series[i];
79
+ node.symbolBoundingData = data.total;
80
+ node.data = seriesData;
81
+ }
82
+ }
83
+ }
84
+ /**
85
+ * 散点图-分数实时数据
86
+ * @param option 图表配置数据
87
+ * @param data 实时图表数据
88
+ */
89
+ export function scatterDataAuto(option, data) {
90
+ if(data && data.XData) option.xAxis[0].data = data.XData;
91
+ if(!(data && data.seriesData && data.seriesData.length)) return;
92
+ const { scatterData, legend, yData } = convertScatter3DTo2D(data);
93
+ option.legend.data = [...legend];
94
+ option.yAxis[0].data = [...yData];
52
95
  for (let i = 0; i < option.series.length; i++) {
53
- const node = option.series[i];
54
- node.symbolBoundingData = data.total;
55
- node.data = seriesData;
96
+ const seriesNode = option.series[i];
97
+ const name = option.legend.data[i];
98
+ seriesNode.name = name;
99
+ seriesNode.data = scatterData[name];
100
+ }
101
+ }
102
+
103
+ function convertScatter3DTo2D(arr3d) {
104
+ const { XData, seriesData } = arr3d;
105
+ const scatterData = {};
106
+ const legend = [];
107
+ const yData = new Set();
108
+ // 第一层遍历
109
+ for (let d = 0, depth = seriesData.length; d < depth; d++) {
110
+ const areaData = seriesData[d];
111
+ const areaName = areaData.name;
112
+ if(!scatterData[areaName]) scatterData[areaName] = [];
113
+ legend.push(areaData.name);
114
+ // 第二层遍历
115
+ const statusData = areaData.data;
116
+ for (let h = 0, height = statusData.length; h < height; h++) {
117
+ const issues = statusData[h];
118
+ const statusName = XData[h];
119
+ // 第三层遍历
120
+ for (let w = 0, width = issues.length; w < width; w++) {
121
+ const { name, value } = issues[w];
122
+ yData.add(name);
123
+ if(value) scatterData[areaName].push([statusName, name, Number(value)]);
124
+ }
125
+ }
56
126
  }
127
+ return {
128
+ scatterData,
129
+ legend,
130
+ yData
131
+ };
57
132
  }
58
133
 
59
134
  /**
@@ -82,7 +157,7 @@ export function pieRingAssetTotalAuto(option, data, total, count) {
82
157
  */
83
158
  export function pieRingProportionAuto(option, data, proportion) {
84
159
  if(data && data.length) {
85
- proportion = Number(data[0].value) * 100;
160
+ proportion = Number(data[0].value);
86
161
  }
87
162
  if(!option.series[0].data[0].label.normal.formatter) option.series[0].data[0].label.normal.formatter = function(params){
88
163
  return params.value ? `{v|${params.value}}{unit|%}` : `{v|${params.value}}`;