dcim-topology2d 2.0.7 → 2.1.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/chart-diagram/src/echarts/index.js +4 -1
- package/chart-diagram/src/utils/changeOptions.d.ts +1 -0
- package/chart-diagram/src/utils/changeOptions.js +49 -35
- package/chart-diagram/src/utils/conversion.d.ts +1 -0
- package/chart-diagram/src/utils/conversion.js +182 -22
- package/chart-diagram/src/utils/formatter.d.ts +1 -1
- package/chart-diagram/src/utils/formatter.js +96 -19
- package/chart-diagram/src/utils/index.d.ts +1 -0
- package/chart-diagram/src/utils/index.js +1 -0
- package/chart-diagram/src/utils/render.d.ts +1 -1
- package/chart-diagram/src/utils/render.js +47 -27
- package/chart-diagram/src/utils/surfaceParametricConversion.d.ts +3 -0
- package/chart-diagram/src/utils/surfaceParametricConversion.js +252 -0
- package/core/src/canvas.js +4 -3
- package/core/src/common.js +16 -10
- package/core/src/core.d.ts +2 -0
- package/core/src/core.js +61 -23
- package/core/src/element/common.d.ts +2 -1
- package/core/src/element/common.js +15 -15
- package/core/src/element/datePicker.d.ts +3 -0
- package/core/src/element/datePicker.js +47 -0
- package/core/src/element/index.d.ts +2 -1
- package/core/src/element/index.js +3 -1
- package/core/src/element/select.js +14 -2
- package/core/src/element/tab.js +14 -12
- package/core/src/element/time.d.ts +3 -0
- package/core/src/element/time.js +44 -0
- package/core/src/middles/default.js +8 -2
- package/core/src/middles/nodes/formDatePicker.d.ts +2 -0
- package/core/src/middles/nodes/formDatePicker.js +66 -0
- package/core/src/middles/nodes/formselect.js +7 -0
- package/core/src/middles/nodes/index.d.ts +3 -1
- package/core/src/middles/nodes/index.js +3 -0
- package/core/src/middles/nodes/time.d.ts +2 -0
- package/core/src/middles/nodes/time.js +98 -0
- package/core/src/models/node.js +27 -4
- package/core/src/preview.d.ts +1 -0
- package/core/src/preview.js +30 -6
- package/core/src/renderLayer.js +13 -2
- package/core/src/store/data.d.ts +10 -2
- package/core/src/store/data.js +14 -5
- package/core/src/utils/assignment.d.ts +2 -1
- package/core/src/utils/assignment.js +29 -12
- package/core/src/utils/conversion.d.ts +3 -1
- package/core/src/utils/conversion.js +46 -3
- package/core/src/utils/onmousevent.js +15 -12
- package/core/src/utils/params.js +5 -0
- package/package.json +1 -1
- package/static/echartsDefaultData.js +15 -4
- package/style/common.css +0 -3
- package/style/datePicker.css +44 -0
- package/style/editor.css +3 -0
- package/style/index.css +1 -0
@@ -1,6 +1,7 @@
|
|
1
1
|
import {s8, createDiv, rectangle, commonStore} from '../../../core';
|
2
2
|
import {plugsPool} from '../../../store';
|
3
3
|
import {
|
4
|
+
setMapScatterOptions,
|
4
5
|
setMapLineBarOptions,
|
5
6
|
setMapGaugeOptions,
|
6
7
|
setMapRingOptions,
|
@@ -72,8 +73,10 @@ export function echarts(ctx, node) {
|
|
72
73
|
if (!appearance.type) appearance.type = echartsTypeMap[`type_${option.displayMode}`]; // 兼容旧数据配置
|
73
74
|
// 公共配置 Top排行榜散点图跳过公共属性配置
|
74
75
|
if (option.displayMode !== 4 && option.displayMode !== 7) setMapGlobalOptions(option, node);
|
76
|
+
// 散点图
|
77
|
+
if (appearance.type.includes('scatter')) setMapScatterOptions(option, node);
|
75
78
|
// 折线图和柱状图
|
76
|
-
if (
|
79
|
+
if (appearance.type.includes('line') || appearance.type.includes('bar')) setMapLineBarOptions(option, node);
|
77
80
|
// 仪表盘
|
78
81
|
if (appearance.type === 'gauge') setMapGaugeOptions(option, node);
|
79
82
|
// 环形图 || 饼图
|
@@ -1,6 +1,7 @@
|
|
1
1
|
export declare function setRingChartText<T>(textData: T): void;
|
2
2
|
export declare function setRingPreSeriesOptions<T>(option: T, appearance: T): void;
|
3
3
|
export declare function setRingProSeriesOptions<T>(option: T, appearance: T): void;
|
4
|
+
export declare function set3DPieOptions<T>(option: T, appearance: T, labelLineData: any, realData: any): {};
|
4
5
|
export declare function setChartLegendData<T>(legend: T, appearance: T): void;
|
5
6
|
export declare function setChartXAxisData<T>(xAxis: [], appearance: T): void;
|
6
7
|
export declare function setChartYAxisData<T>(yAxis: [], appearance: T): void;
|
@@ -1,11 +1,11 @@
|
|
1
1
|
// 初始化图例数据和图例配置数据
|
2
2
|
import {
|
3
|
-
echartsLegendDefaultData,
|
4
3
|
echartsXAxisDefaultStyleData,
|
5
4
|
echartsYAxisDefaultStyleData,
|
6
5
|
echartsLineSeriesStyleData,
|
7
6
|
echartsColorData
|
8
7
|
} from '../../../static';
|
8
|
+
import {getPie3D} from './surfaceParametricConversion';
|
9
9
|
|
10
10
|
// 配置环形图中间区域文字样式
|
11
11
|
export function setRingChartText(textData) {
|
@@ -63,6 +63,20 @@ export function setRingProSeriesOptions(option, appearance) {
|
|
63
63
|
seriesLastChildNode.radius = appearance.inner.radius;
|
64
64
|
seriesLastChildNode.itemStyle.normal.color.colorStops[0].color = appearance.inner.borderColor;
|
65
65
|
}
|
66
|
+
|
67
|
+
// 3D饼图 | 环形图 属性配置
|
68
|
+
export function set3DPieOptions(option, appearance, labelLineData, realData){
|
69
|
+
let type = appearance.type.includes('pie') ? 'pie' : 'ring';
|
70
|
+
const {legendData, series, node, total, boxHeight} = getPie3D(appearance.grid.internalDiameterRatio, type, appearance, labelLineData, realData);
|
71
|
+
option.grid3D.boxHeight = boxHeight;
|
72
|
+
option.legend.data = legendData;
|
73
|
+
option.series = series;
|
74
|
+
return {
|
75
|
+
node,
|
76
|
+
total
|
77
|
+
};
|
78
|
+
}
|
79
|
+
|
66
80
|
// 图表X轴数据
|
67
81
|
export function setChartXAxisData(xAxis, appearance) {
|
68
82
|
for (let i = 0; i < xAxis.length; i++) {
|
@@ -94,6 +108,14 @@ export function setChartYAxisData(yAxis, appearance) {
|
|
94
108
|
if (!appearance.ysplitLineLineStyle && yAxis[0].splitLine.show) {
|
95
109
|
appearance.ysplitLineLineStyle = JSON.parse(JSON.stringify(echartsYAxisDefaultStyleData['ysplitLineLineStyle']));
|
96
110
|
}
|
111
|
+
if(appearance.total && appearance.total.length && appearance.totalLabelSynchroYData) {
|
112
|
+
const newYAxisData = [];
|
113
|
+
for (let i = 0; i < appearance.total.length; i++) {
|
114
|
+
const item = appearance.total[i];
|
115
|
+
if(item.value) newYAxisData.push(item.label);
|
116
|
+
}
|
117
|
+
yAxis[0].data = newYAxisData;
|
118
|
+
}
|
97
119
|
for (let i = 0; i < yAxis.length; i++) {
|
98
120
|
const item = yAxis[i];
|
99
121
|
if(!item.axisLabel) item.axisLabel = {};
|
@@ -164,7 +186,6 @@ export function setChartYAxisData(yAxis, appearance) {
|
|
164
186
|
|
165
187
|
// 图表图例数据
|
166
188
|
export function setChartLegendData(legend, appearance) {
|
167
|
-
if (!legend.formatter) legend.formatter = ['{a|{name}}'].join('\n');
|
168
189
|
// 设置默认图例文字配置,如果想改变初始化文字属性,在 appearance中配置即可
|
169
190
|
if (!legend.textStyle) legend.textStyle = {
|
170
191
|
color: '#fff',
|
@@ -176,39 +197,32 @@ export function setChartLegendData(legend, appearance) {
|
|
176
197
|
verticalAlign: 'bottom',
|
177
198
|
}
|
178
199
|
};
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
legend.bottom = bottom || 'auto';
|
206
|
-
legend.left = left || 'auto';
|
207
|
-
legend.padding = padding || [5, 5, 5, 5];
|
208
|
-
legend.textStyle.color = color || '';
|
209
|
-
legend.textStyle.height = height || 8;
|
210
|
-
legend.textStyle.rich.a = fontSize || 12;
|
211
|
-
}
|
200
|
+
const {
|
201
|
+
icon,
|
202
|
+
itemWidth,
|
203
|
+
itemHeight,
|
204
|
+
itemGap,
|
205
|
+
top,
|
206
|
+
right,
|
207
|
+
bottom,
|
208
|
+
left,
|
209
|
+
padding,
|
210
|
+
color,
|
211
|
+
height,
|
212
|
+
fontSize
|
213
|
+
} = appearance.legend;
|
214
|
+
legend.icon = icon || '';
|
215
|
+
legend.itemWidth = itemWidth || 12;
|
216
|
+
legend.itemHeight = itemHeight || 12;
|
217
|
+
legend.itemGap = itemGap || 8;
|
218
|
+
legend.top = top || 'auto';
|
219
|
+
legend.right = right || 'auto';
|
220
|
+
legend.bottom = bottom || 'auto';
|
221
|
+
legend.left = left || 'auto';
|
222
|
+
legend.padding = padding || [5, 5, 5, 5];
|
223
|
+
legend.textStyle.color = color || '';
|
224
|
+
legend.textStyle.height = height || 8;
|
225
|
+
legend.textStyle.rich.a = fontSize || 12;
|
212
226
|
//return legend;
|
213
227
|
}
|
214
228
|
|
@@ -7,6 +7,7 @@ interface echartsOptions {
|
|
7
7
|
}
|
8
8
|
export declare function getXYAxisLabelVal(index: number, intervalNum: number, value: any): string;
|
9
9
|
export declare function initBindTabSetting(node: any): string;
|
10
|
+
export declare function setMapScatterOptions(option: echartsOptions, node: any): void;
|
10
11
|
export declare function setMapLineBarOptions(option: echartsOptions, node: any): void;
|
11
12
|
export declare function setMapGaugeOptions(option: echartsOptions, node: any): void;
|
12
13
|
export declare function setMapRingOptions(option: echartsOptions, node: any): void;
|
@@ -8,7 +8,9 @@ import {
|
|
8
8
|
setLineSeriesStyleData,
|
9
9
|
setRingPreSeriesOptions,
|
10
10
|
setRingProSeriesOptions,
|
11
|
-
|
11
|
+
set3DPieOptions,
|
12
|
+
mapFormatterSet,
|
13
|
+
set3DPieMouseHover
|
12
14
|
} from '../utils';
|
13
15
|
import {
|
14
16
|
gaugeNormalAuto,
|
@@ -41,7 +43,7 @@ export function initBindTabSetting(node) {
|
|
41
43
|
const tabNode = Object.values(switchTabData)[0];
|
42
44
|
const tabEventNode = tabNode.events.find((ev) => {return ev.action === 8});
|
43
45
|
const tabStaticType = tabEventNode && tabEventNode.dcimStaticForType || '';
|
44
|
-
node.data.params.staticForType = tabStaticType;
|
46
|
+
if(node.data.params) node.data.params.staticForType = tabStaticType;
|
45
47
|
return {
|
46
48
|
type: tabStaticType,
|
47
49
|
data: tabNode.tabData
|
@@ -79,6 +81,33 @@ export function setMapStopAutoMoveOptions(chartNode) {
|
|
79
81
|
|
80
82
|
}
|
81
83
|
|
84
|
+
// 自动配置散点图的节点数据
|
85
|
+
export function setMapScatterOptions(option, node) {
|
86
|
+
if(node.appearance.series) {
|
87
|
+
for (let i = 0; i < option.series.length; i++) {
|
88
|
+
const series = option.series[i];
|
89
|
+
const setSeries = node.appearance.series[i];
|
90
|
+
if(setSeries) {
|
91
|
+
series.itemStyle.color = setSeries.itemColor;
|
92
|
+
series.itemStyle.borderColor = setSeries.itemBorderColor;
|
93
|
+
}
|
94
|
+
}
|
95
|
+
}
|
96
|
+
if(node.appearance.yAxis && node.appearance.yAxis.axisLabel && node.appearance.yAxis.axisLabel.length) {
|
97
|
+
const yAxisAxisLabelRich = option.yAxis[0].axisLabel.rich;
|
98
|
+
const yAxisAxisLabel = node.appearance.yAxis.axisLabel;
|
99
|
+
const yAxisData = [];
|
100
|
+
for (let i = 0; i < yAxisAxisLabel.length; i++) {
|
101
|
+
const axisLabel = yAxisAxisLabel[i];
|
102
|
+
yAxisAxisLabelRich[`f${i+1}`] = {
|
103
|
+
color: axisLabel.color
|
104
|
+
};
|
105
|
+
if(axisLabel.label) yAxisData.push(axisLabel.label);
|
106
|
+
}
|
107
|
+
option.yAxis[0].data = yAxisData;
|
108
|
+
}
|
109
|
+
}
|
110
|
+
|
82
111
|
// 自动配置折线和柱状图的节点数据
|
83
112
|
export function setMapLineBarOptions(option, node) {
|
84
113
|
option.color = node.appearance.color;
|
@@ -88,11 +117,17 @@ export function setMapLineBarOptions(option, node) {
|
|
88
117
|
option.yAxis[0].axisLabel.formatter = function (value, index) {
|
89
118
|
return getXYAxisLabelVal(index, node.appearance.intervalNumY, value);
|
90
119
|
}
|
91
|
-
if
|
92
|
-
|
93
|
-
|
94
|
-
|
120
|
+
if(option.series.length < 2) return;
|
121
|
+
const total = node.appearance.total;
|
122
|
+
if(total && total.length) {
|
123
|
+
const seriesData = option.series[0].data;
|
124
|
+
if(seriesData.length < total.length && total[total.length - 1].value) seriesData.push(20);
|
125
|
+
const data2 = [];
|
126
|
+
for (let i = 0; i < seriesData.length; i++) {
|
127
|
+
const dr = node.appearance.total[i] ? node.appearance.total[i].value - Number(seriesData[i]) : option.series[1].data[i];
|
128
|
+
data2.push(dr);
|
95
129
|
}
|
130
|
+
option.series[1].data = data2;
|
96
131
|
}else {
|
97
132
|
option.series.map((item, index) => {
|
98
133
|
if(!(item.itemStyle && item.itemStyle.normal && item.itemStyle.normal.color)) {
|
@@ -136,14 +171,53 @@ export function setMapRingOptions(option, node) {
|
|
136
171
|
//const chartOption = JSON.parse(JSON.stringify(option));
|
137
172
|
const appearance = node.appearance;
|
138
173
|
if(appearance.type === 'ringPre'){
|
139
|
-
|
174
|
+
//环形‘设备告警统计图’节点展示配置
|
140
175
|
setRingPreSeriesOptions(option, appearance);
|
141
176
|
|
142
177
|
}else if(appearance.type === 'ringPro'){
|
143
|
-
|
178
|
+
//环形‘内存、硬盘、CPU指标占比统计’节点展示配置
|
144
179
|
setRingProSeriesOptions(option, appearance);
|
145
180
|
|
181
|
+
}else if(appearance.type === 'ring3d' || appearance.type === 'pie3d'){
|
182
|
+
// 3D饼图配置
|
183
|
+
option.backgroundColor = appearance.backgroundColor;
|
184
|
+
option.grid3D = {
|
185
|
+
show: false,
|
186
|
+
top: appearance.grid.top,
|
187
|
+
left: appearance.grid.left,
|
188
|
+
right: appearance.grid.right,
|
189
|
+
bottom: appearance.grid.bottom,
|
190
|
+
viewControl: {
|
191
|
+
alpha: appearance.grid.alpha, //角度
|
192
|
+
distance: appearance.grid.distance, //调整视角到主体的距离,类似调整zoom
|
193
|
+
rotateSensitivity: 0, //设置为0无法旋转
|
194
|
+
zoomSensitivity: 0, //设置为0无法缩放
|
195
|
+
panSensitivity: 0, //设置为0无法平移
|
196
|
+
autoRotate: false, //自动旋转
|
197
|
+
}
|
198
|
+
};
|
199
|
+
if(appearance.grid.beta) option.grid3D.viewControl.beta = appearance.grid.beta;
|
200
|
+
Object.assign(option.legend, appearance.legend);
|
201
|
+
if(appearance.labelLine && appearance.labelLine.show) set3DPieLabelLine(option, appearance.labelLine, node.TID, node.id);
|
202
|
+
if(appearance.legendTextStyle) {
|
203
|
+
const {fontSize, align, color, width, data} = appearance.legendTextStyle;
|
204
|
+
const rich = {
|
205
|
+
a: {
|
206
|
+
color,
|
207
|
+
width
|
208
|
+
}
|
209
|
+
}
|
210
|
+
for (let i = 0; i < data.length; i++) {
|
211
|
+
rich[`b${i}`] = data[i];
|
212
|
+
}
|
213
|
+
option.legend.textStyle = {
|
214
|
+
fontSize,
|
215
|
+
align,
|
216
|
+
rich
|
217
|
+
}
|
218
|
+
}
|
146
219
|
}else {
|
220
|
+
// 基础图表的配置
|
147
221
|
const seriesNode = option.series[0];
|
148
222
|
if ((!appearance.label || typeof appearance.label.showValue !== 'boolean')) {
|
149
223
|
appearance.label = {
|
@@ -192,6 +266,66 @@ export function setMapRingOptions(option, node) {
|
|
192
266
|
}
|
193
267
|
}
|
194
268
|
|
269
|
+
function getItemNode(color, fontSize, fontWeight, padding) {
|
270
|
+
return {
|
271
|
+
color,
|
272
|
+
fontSize,
|
273
|
+
fontWeight,
|
274
|
+
padding
|
275
|
+
}
|
276
|
+
}
|
277
|
+
|
278
|
+
// 设置3D饼图引线样式
|
279
|
+
function set3DPieLabelLine(option, labelLine, TID, id){
|
280
|
+
const rich = {};
|
281
|
+
const { data, color, lengthWidth, startAngle, clockwise, center, radius } = labelLine;
|
282
|
+
const lineData = [];
|
283
|
+
for (let i = 0; i < data.length; i ++){
|
284
|
+
const {
|
285
|
+
length,
|
286
|
+
length2,
|
287
|
+
nameFontSize,
|
288
|
+
nameFontWeight,
|
289
|
+
nameColor,
|
290
|
+
namePadding,
|
291
|
+
valueFontSize,
|
292
|
+
valueFontWeight,
|
293
|
+
valueColor,
|
294
|
+
valuePadding,
|
295
|
+
unitFontSize,
|
296
|
+
unitFontWeight,
|
297
|
+
unitColor,
|
298
|
+
unitPadding
|
299
|
+
} = data[i];
|
300
|
+
rich[`name${i+1}`] = getItemNode(nameColor, nameFontSize, nameFontWeight, namePadding);
|
301
|
+
rich[`unit${i+1}`] = getItemNode(unitColor, unitFontSize, unitFontWeight, unitPadding);
|
302
|
+
rich[`value${i+1}`] = getItemNode(valueColor, valueFontSize, valueFontWeight, valuePadding);
|
303
|
+
lineData.push({
|
304
|
+
minTurnAngle: 90,
|
305
|
+
length: length,
|
306
|
+
length2: length2,
|
307
|
+
lineStyle: {
|
308
|
+
width: lengthWidth
|
309
|
+
}
|
310
|
+
})
|
311
|
+
}
|
312
|
+
commonStore[TID].echartsDataPool[id].labelLineData = {
|
313
|
+
name: 'pie2d',
|
314
|
+
type: 'pie',
|
315
|
+
hoverAnimation: false,
|
316
|
+
label: {
|
317
|
+
opacity: 1,
|
318
|
+
color,
|
319
|
+
rich
|
320
|
+
},
|
321
|
+
startAngle, //起始角度,支持范围[0, 360]。
|
322
|
+
clockwise, //饼图的扇区是否是顺时针排布。上述这两项配置主要是为了对齐3d的样式
|
323
|
+
radius, // 两个值设置成相同的,环形就隐藏了
|
324
|
+
center, //指示线的位置
|
325
|
+
data: lineData
|
326
|
+
};
|
327
|
+
}
|
328
|
+
|
195
329
|
// 自动配置3D柱状图的节点数据
|
196
330
|
export function setMap3dBarOptions(option, node) {
|
197
331
|
// 取消注册自定义形状
|
@@ -253,7 +387,7 @@ export function setMapGlobalOptions(option, node) {
|
|
253
387
|
// const chartOption = JSON.parse(JSON.stringify(option));
|
254
388
|
const appearance = node.appearance;
|
255
389
|
// 图表网格数据
|
256
|
-
if (appearance.grid) {
|
390
|
+
if (appearance.grid && !appearance.grid.distance) {
|
257
391
|
|
258
392
|
option.grid ? Object.assign(option.grid, appearance.grid) : option.grid = appearance.grid;
|
259
393
|
|
@@ -263,14 +397,15 @@ export function setMapGlobalOptions(option, node) {
|
|
263
397
|
// 图表Y轴数据
|
264
398
|
if (option.yAxis) setChartYAxisData(option.yAxis, appearance);
|
265
399
|
// 图表图例数据
|
266
|
-
|
400
|
+
if (appearance.legend) setChartLegendData(option.legend, appearance);
|
267
401
|
// 曲线样式数据
|
268
402
|
if (appearance.type.includes('line')) setLineSeriesStyleData(option.series, appearance);
|
269
403
|
}
|
270
404
|
|
271
405
|
// 实时改变图表data值
|
272
406
|
export function setMapDataOptions(option, node) {
|
273
|
-
const
|
407
|
+
const currentStore = commonStore[node.TID];
|
408
|
+
let optionNode = currentStore.echartsOptionsPool[node.id].option;
|
274
409
|
const appearance = node.appearance;
|
275
410
|
const params = node.params;
|
276
411
|
// 3d 柱状图
|
@@ -290,6 +425,7 @@ export function setMapDataOptions(option, node) {
|
|
290
425
|
// 日,周,月,年,实时类型,不与分组统计一起使用
|
291
426
|
staticTypeData = staticForType ? syncEchartsData && syncEchartsData[`${staticForType}_Data`] : syncEchartsData;
|
292
427
|
}
|
428
|
+
let dataDictionary = {};
|
293
429
|
// 实时数据加载
|
294
430
|
if(staticTypeData) {
|
295
431
|
|
@@ -298,13 +434,13 @@ export function setMapDataOptions(option, node) {
|
|
298
434
|
if(node.tabData && node.tabData.data.state && optionNode.yAxis[0].max) Object.assign(optionNode.yAxis[0], node.tabData.data); //若Tabs切换配置了数据,则修改Y轴原有配置
|
299
435
|
|
300
436
|
if(appearance.type === 'barPileStatic') {
|
301
|
-
|
437
|
+
|
302
438
|
barPileStaticDataAuto(optionNode, staticTypeData, appearance);
|
303
|
-
|
439
|
+
|
304
440
|
}else {
|
305
|
-
|
306
|
-
lineBarDataAuto(optionNode, params, staticTypeData);
|
307
|
-
|
441
|
+
|
442
|
+
lineBarDataAuto(optionNode, params, staticTypeData, appearance);
|
443
|
+
|
308
444
|
}
|
309
445
|
|
310
446
|
}
|
@@ -327,6 +463,16 @@ export function setMapDataOptions(option, node) {
|
|
327
463
|
}else if(appearance.type === 'ringPro'){
|
328
464
|
// 按照百分比统计设备配置情况
|
329
465
|
pieRingProportionAuto(optionNode, pieData, appearance.proportion);
|
466
|
+
|
467
|
+
}else if(appearance.type === 'ring3d' || appearance.type === 'pie3d'){
|
468
|
+
for (let i = 0; i < pieData.length; i++){
|
469
|
+
pieData[i].itemOpacity = 0.9;
|
470
|
+
pieData[i].itemColor = appearance.chartData[i] && appearance.chartData[i].itemColor || echartsColorData[i];
|
471
|
+
}
|
472
|
+
// 3D饼图图例更新
|
473
|
+
const labelLineData = currentStore.echartsDataPool[node.id].labelLineData;
|
474
|
+
dataDictionary = set3DPieOptions(optionNode, appearance, labelLineData, pieData);
|
475
|
+
|
330
476
|
}else {
|
331
477
|
|
332
478
|
pieRingNormalAuto(optionNode, pieData);
|
@@ -363,16 +509,23 @@ export function setMapDataOptions(option, node) {
|
|
363
509
|
}
|
364
510
|
}
|
365
511
|
}
|
366
|
-
if
|
367
|
-
|
368
|
-
|
369
|
-
|
370
|
-
|
512
|
+
if(option.series[0].pieData) {
|
513
|
+
// 3D饼图图例初始化
|
514
|
+
const labelLineData = currentStore.echartsDataPool[node.id].labelLineData;
|
515
|
+
dataDictionary = set3DPieOptions(option, appearance, labelLineData);
|
516
|
+
optionNode = option;
|
517
|
+
}else {
|
518
|
+
if (option.series) {
|
519
|
+
for (let i = 0; i < option.series.length; i++) {
|
520
|
+
const item = option.series[i];
|
521
|
+
if(item.name) optionNode.series[i].name = item.name;
|
522
|
+
optionNode.series[i].data = item.data;
|
523
|
+
}
|
371
524
|
}
|
372
525
|
}
|
373
526
|
}
|
374
527
|
|
375
|
-
mapFormatterSet(appearance, optionNode, staticTypeData);
|
528
|
+
mapFormatterSet(appearance, optionNode, staticTypeData, dataDictionary);
|
376
529
|
|
377
530
|
const currentChartNode = commonStore[node.TID].echartsDataPool[node.id];
|
378
531
|
const mapChart = currentChartNode.chart;
|
@@ -394,6 +547,13 @@ export function setMapDataOptions(option, node) {
|
|
394
547
|
return mapChart.setOption(chartNode);
|
395
548
|
})
|
396
549
|
}
|
550
|
+
// 鼠标hover状态,用于3D饼图
|
551
|
+
if(appearance.mouseHoverState) {
|
552
|
+
mapChart.off('mouseover');
|
553
|
+
mapChart.off('globalout');
|
554
|
+
let type = appearance.type.includes('pie') ? 'pie' : 'ring';
|
555
|
+
set3DPieMouseHover(mapChart, type, option, appearance.seriesStyleData);
|
556
|
+
}
|
397
557
|
mapChart.setOption(optionNode);
|
398
558
|
mapChart.resize();
|
399
559
|
}
|
@@ -1 +1 @@
|
|
1
|
-
export declare function mapFormatterSet(appearance: object, option: any, data: any): void;
|
1
|
+
export declare function mapFormatterSet(appearance: object, option: any, data: any, dataDictionary: any): void;
|
@@ -1,12 +1,15 @@
|
|
1
|
-
import {
|
1
|
+
import {rankingTopColorList} from '../../../static';
|
2
2
|
|
3
|
-
export function mapFormatterSet(appearance, options, data) {
|
3
|
+
export function mapFormatterSet(appearance, options, data, dataDictionary) {
|
4
4
|
if(appearance.type.includes('ring') || appearance.type.includes('pie')) {
|
5
5
|
const seriesNode = options.series[0];
|
6
6
|
if(seriesNode.label && seriesNode.label.normal &&!seriesNode.label.normal.formatter) {
|
7
7
|
setMapRingOptionsFormatter(appearance, seriesNode);
|
8
8
|
}
|
9
9
|
}
|
10
|
+
if(appearance.type === 'ring3d') setMapRing3DFormatter(appearance, options, dataDictionary);
|
11
|
+
if(appearance.type === 'pie3d') setMapPie3DFormatter(appearance, options);
|
12
|
+
if(appearance.type.includes('line') || appearance.type.includes('bar')) setMapLineBarFormatter(appearance, options);
|
10
13
|
if(appearance.type.includes('lineTwins')) setMapLineTwinsFormatter(appearance, options);
|
11
14
|
if(appearance.type.includes('scatter')) setMapScatterFormatter(options);
|
12
15
|
if(appearance.type.includes('TOPRanking')) setMapTopScoreFormatter(options, data, appearance);
|
@@ -30,23 +33,47 @@ function setMapLineTwinsFormatter(appearance, options) {
|
|
30
33
|
}
|
31
34
|
}
|
32
35
|
}
|
33
|
-
//
|
34
|
-
function
|
36
|
+
// 折线 || 柱状图
|
37
|
+
function setMapLineBarFormatter(appearance, options){
|
35
38
|
if(!options.tooltip.formatter){
|
36
39
|
options.tooltip.formatter = function(param) {
|
37
|
-
|
40
|
+
const firstUnit = getTooltipUnit(0, appearance);
|
41
|
+
const firstDott = getTooltipDott(param[0].color);
|
42
|
+
let data = `${firstDott}${param[0].seriesName}:${param[0].value} ${firstUnit}`;
|
43
|
+
for (let i = 1; i < param.length; i++){
|
44
|
+
const item = param[i];
|
45
|
+
const unit = getTooltipUnit(i, appearance);
|
46
|
+
const dott = getTooltipDott(param[i].color);
|
47
|
+
data += `<br>${dott}${item.seriesName}:${appearance.total && appearance.total[item.dataIndex].value || item.value} ${unit}`;
|
48
|
+
}
|
49
|
+
return `<div style="border-bottom: 1px solid rgba(255,255,255,.3); font-size: 12px;margin-bottom: 5px;">${param[0].name}</div>${data}`;
|
50
|
+
}
|
51
|
+
}
|
52
|
+
}
|
53
|
+
function getTooltipUnit(index, appearance) {
|
54
|
+
return appearance.tooltipUnit && appearance.tooltipUnit[index] || appearance.series && appearance.series[index] && appearance.series[index].labelUnit || '';
|
55
|
+
}
|
56
|
+
function getTooltipDott(color) {
|
57
|
+
return `<span style="display: inline-block;margin-right: 8px;border: 5px solid ${color};border-radius: 100%"></span>`;
|
58
|
+
}
|
59
|
+
// 堆叠统计
|
60
|
+
function setMapBarPileStaticFormatter(appearance, options) {
|
61
|
+
for (let i = 0; i < options.series.length; i++) {
|
62
|
+
const item = options.series[i];
|
63
|
+
const setItem = appearance.series[i];
|
64
|
+
if(setItem) {
|
65
|
+
item.itemStyle.normal.color = setItem.itemColor;
|
66
|
+
item.label.color = setItem.labelColor;
|
67
|
+
item.label.fontSize = setItem.labelSize;
|
68
|
+
item.label.padding[0] = setItem.labelTop;
|
38
69
|
}
|
70
|
+
item.label.formatter = `{c}${setItem ? setItem.labelUnit : ''}`;
|
39
71
|
}
|
40
|
-
if(
|
72
|
+
if(appearance.total && appearance.total.length) {
|
41
73
|
options.series[1].label.formatter = function(param) {
|
42
74
|
if(!param.value) return '';
|
43
|
-
|
44
|
-
|
45
|
-
value = `${appearance.totalStyle.label ? appearance.total[param.dataIndex] : ''}${appearance.totalStyle.unit}`;
|
46
|
-
}else {
|
47
|
-
value = `${appearance.total[param.dataIndex]}`;
|
48
|
-
}
|
49
|
-
return value;
|
75
|
+
const val = appearance.totalLabel ? appearance.total[param.dataIndex].value || options.series[1].data[param.dataIndex] : '';
|
76
|
+
return `${val}${appearance.series[1].labelUnit}`;
|
50
77
|
}
|
51
78
|
}
|
52
79
|
}
|
@@ -61,18 +88,22 @@ function setMapTopScoreFormatter(options, data, appearance) {
|
|
61
88
|
const seriesNode = options.series[0];
|
62
89
|
if(appearance.total && appearance.total.length) {
|
63
90
|
const realData = data && data.seriesData && data.seriesData[0] && data.seriesData[0].data;
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
91
|
+
const normalData = [28.7, 24.2, 20.3, 19.8, 19.3];
|
92
|
+
const resultData = realData && realData.length ? realData : normalData;
|
93
|
+
seriesNode.itemStyle.normal.label.formatter = function(param) {
|
94
|
+
return `${resultData[param.dataIndex]}${appearance.unit}`;
|
95
|
+
}
|
96
|
+
for(let i = 0; i < appearance.total.length; i++) {
|
97
|
+
const value = appearance.total[i].value;
|
98
|
+
seriesNode.data[i] = value ? parseInt(value) : normalData[i];
|
69
99
|
}
|
70
100
|
}
|
71
101
|
if(seriesNode.itemStyle.normal.color) return;
|
102
|
+
const colorList = appearance.barColor || rankingTopColorList;
|
72
103
|
for (let i = 0; i < options.series.length; i++) {
|
73
104
|
const node = options.series[i];
|
74
105
|
node.itemStyle.normal.color = function(params) {
|
75
|
-
return
|
106
|
+
return colorList[params.dataIndex];
|
76
107
|
}
|
77
108
|
}
|
78
109
|
}
|
@@ -126,4 +157,50 @@ function setMapRingOptionsFormatter(appearance, seriesNode) {
|
|
126
157
|
}
|
127
158
|
}
|
128
159
|
}
|
160
|
+
}
|
161
|
+
// 环形3D图自定义展示配置
|
162
|
+
function setMapRing3DFormatter(appearance, options, data) {
|
163
|
+
if(!options.tooltip.formatter) {
|
164
|
+
options.tooltip.formatter = (params) => {
|
165
|
+
if (params.seriesName !== 'mouseoutSeries' && params.seriesName !== 'pie2d') {
|
166
|
+
const pieData = options.series[params.seriesIndex].pieData;
|
167
|
+
const pv = (pieData.endRatio - pieData.startRatio) *100;
|
168
|
+
let bfb = Math.round(pv);
|
169
|
+
return `${
|
170
|
+
params.seriesName
|
171
|
+
}<br/><span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:${
|
172
|
+
params.color
|
173
|
+
};"></span>${bfb}${appearance.unit}`;
|
174
|
+
}
|
175
|
+
}
|
176
|
+
}
|
177
|
+
options.legend.formatter = (name) => {
|
178
|
+
const legendItem = data.node[name];
|
179
|
+
const pv = (legendItem.value / data.total) * 100;
|
180
|
+
const p = Math.round(pv)+'%';
|
181
|
+
return `{a|${name}}{b${legendItem.order}|${legendItem.value}}{b${legendItem.order}|${p}}`;
|
182
|
+
}
|
183
|
+
}
|
184
|
+
// 饼图3D图自定义展示配置
|
185
|
+
function setMapPie3DFormatter(appearance, options) {
|
186
|
+
if(!options.tooltip.formatter) {
|
187
|
+
options.tooltip.formatter = (params) => {
|
188
|
+
if (params.seriesName !== 'mouseoutSeries') {
|
189
|
+
const pieData = options.series[params.seriesIndex].pieData;
|
190
|
+
if(!pieData) return; // 先退出,后期若有hover引线时,图形联动的需求时再做逻辑处理
|
191
|
+
return `${
|
192
|
+
params.seriesName
|
193
|
+
}<br/><span style="display:inline-block;margin-right:5px;border-radius:10px;width:10px;height:10px;background-color:${
|
194
|
+
params.color
|
195
|
+
};"></span>${pieData.value}${appearance.unit}`;
|
196
|
+
}
|
197
|
+
}
|
198
|
+
}
|
199
|
+
const lastSeriesNode = options.series[options.series.length - 1];
|
200
|
+
if(appearance.labelLine.show && !lastSeriesNode.label.formatter) {
|
201
|
+
lastSeriesNode.label.formatter = (params) => {
|
202
|
+
const dataIndex = params.dataIndex + 1;
|
203
|
+
return `{name${dataIndex}|${params.name}}{value${dataIndex}|${params.value}}{unit${dataIndex}|${appearance.unit}}`;
|
204
|
+
}
|
205
|
+
}
|
129
206
|
}
|
@@ -1,4 +1,4 @@
|
|
1
|
-
export declare function lineBarDataAuto(option: any, params: {}, data: {}): void;
|
1
|
+
export declare function lineBarDataAuto(option: any, params: {}, data: {}, appearance: {}): void;
|
2
2
|
export declare function barPileStaticDataAuto(option: any, data: {}, appearance: {}): void;
|
3
3
|
export declare function topRankingListAuto(option: any, data: {}, appearance: {}): void;
|
4
4
|
export declare function scatterDataAuto(option: any, data: {}): void;
|