dcim-topology2d 1.1.6 → 2.0.5

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 (83) hide show
  1. package/chart-diagram/index.d.ts +1 -1
  2. package/chart-diagram/index.js +1 -1
  3. package/chart-diagram/src/echarts/index.js +88 -96
  4. package/chart-diagram/src/register.js +3 -3
  5. package/chart-diagram/src/utils/changeOptions.d.ts +7 -4
  6. package/chart-diagram/src/utils/changeOptions.js +228 -144
  7. package/chart-diagram/src/utils/conversion.d.ts +12 -12
  8. package/chart-diagram/src/utils/conversion.js +263 -137
  9. package/chart-diagram/src/utils/render.d.ts +6 -0
  10. package/chart-diagram/src/utils/render.js +124 -0
  11. package/core/index.d.ts +1 -0
  12. package/core/index.js +1 -0
  13. package/core/src/activeLayer.js +0 -6
  14. package/core/src/canvas.js +1 -0
  15. package/core/src/common.d.ts +1 -2
  16. package/core/src/common.js +197 -541
  17. package/core/src/core.js +116 -60
  18. package/core/src/divLayer.d.ts +0 -3
  19. package/core/src/divLayer.js +13 -34
  20. package/core/src/element/common.d.ts +5 -0
  21. package/core/src/element/common.js +52 -0
  22. package/core/src/element/iframe.d.ts +3 -0
  23. package/core/src/element/iframe.js +12 -0
  24. package/core/src/element/index.d.ts +4 -0
  25. package/core/src/element/index.js +4 -0
  26. package/core/src/element/select.d.ts +11 -0
  27. package/core/src/element/select.js +234 -0
  28. package/core/src/element/tab.d.ts +1 -0
  29. package/core/src/element/tab.js +19 -0
  30. package/core/src/healps/changeData.d.ts +1 -2
  31. package/core/src/healps/changeData.js +33 -125
  32. package/core/src/middles/default.js +3 -1
  33. package/core/src/middles/nodes/arbitrarygraph.js +11 -9
  34. package/core/src/middles/nodes/formselect.d.ts +2 -0
  35. package/core/src/middles/nodes/formselect.js +87 -0
  36. package/core/src/middles/nodes/iframe.js +21 -4
  37. package/core/src/middles/nodes/index.d.ts +1 -0
  38. package/core/src/middles/nodes/index.js +1 -0
  39. package/core/src/models/node.d.ts +4 -0
  40. package/core/src/models/node.js +24 -22
  41. package/core/src/models/pen.js +3 -52
  42. package/core/src/models/rect.js +2 -2
  43. package/core/src/options.d.ts +2 -0
  44. package/core/src/options.js +2 -1
  45. package/core/src/preview.js +51 -32
  46. package/core/src/renderLayer.d.ts +10 -6
  47. package/core/src/renderLayer.js +36 -43
  48. package/core/src/store/data.d.ts +71 -21
  49. package/core/src/store/data.js +93 -17
  50. package/core/src/utils/assignment.d.ts +6 -3
  51. package/core/src/utils/assignment.js +120 -21
  52. package/core/src/utils/construction.d.ts +10 -3
  53. package/core/src/utils/construction.js +7 -1
  54. package/core/src/utils/conversion.d.ts +3 -0
  55. package/core/src/utils/conversion.js +62 -1
  56. package/core/src/utils/index.d.ts +1 -1
  57. package/core/src/utils/index.js +1 -1
  58. package/core/src/utils/math.d.ts +1 -0
  59. package/core/src/utils/math.js +3 -0
  60. package/core/src/utils/onmousevent.d.ts +3 -0
  61. package/core/src/utils/onmousevent.js +27 -7
  62. package/core/src/utils/params.d.ts +2 -0
  63. package/core/src/utils/params.js +57 -0
  64. package/myShape-diagram/index.js +196 -0
  65. package/package.json +1 -1
  66. package/static/echartsDefaultData.js +27 -107
  67. package/static/element.js +14 -0
  68. package/static/form.js +11 -0
  69. package/static/index.js +2 -1
  70. package/store/actions.js +1 -0
  71. package/store/clear.js +10 -0
  72. package/store/index.js +2 -0
  73. package/style/common.css +18 -0
  74. package/style/editor.css +13 -0
  75. package/style/index.css +3 -12
  76. package/style/select.css +143 -0
  77. package/core/src/poll.js +0 -37
  78. package/core/src/utils/dom.d.ts +0 -9
  79. package/core/src/utils/dom.js +0 -103
  80. package/core/src/utils/dom.js.map +0 -1
  81. package/myShape-diagram/myShape.js +0 -196
  82. package/static/echartsStore.js +0 -14
  83. /package/myShape-diagram/{myShape.ts → index.ts} +0 -0
@@ -2,4 +2,4 @@
2
2
  export * from './src/utils';
3
3
  export * from './src/echarts';
4
4
  export * from './src/register';
5
- export * from '../myShape-diagram/myShape';
5
+ export * from '../myShape-diagram/index.js';
@@ -1,5 +1,5 @@
1
1
  export * from './src/utils';
2
2
  export * from './src/echarts';
3
3
  export * from './src/register';
4
- export * from '../myShape-diagram/myShape.js';
4
+ export * from '../myShape-diagram/index.js';
5
5
  //# sourceMappingURL=index.js.map
@@ -1,106 +1,98 @@
1
- import { s8, createDiv, rectangle, commonStore } from '../../../core';
1
+ import {s8, createDiv, rectangle, commonStore} from '../../../core';
2
+ import {plugsPool} from '../../../store';
2
3
  import {
3
- setMapLineBarOptions,
4
- setMapGaugeOptions,
5
- setMapRingOptions,
6
- setMapAutoMoveOptions,
7
- setMapStopAutoMoveOptions,
8
- setMap3dBarOptions,
9
- setMapTopOptions,
10
- setMapGlobalOptions,
11
- setMapDataOptions
4
+ setMapLineBarOptions,
5
+ setMapGaugeOptions,
6
+ setMapRingOptions,
7
+ setMap3dBarOptions,
8
+ setMapTopOptions,
9
+ setMapGlobalOptions,
10
+ setMapDataOptions
12
11
  } from '../utils';
13
- import { echartsDataStore, echartsOptionsStore } from '../../../static';
12
+ import {echartsTypeMap} from '../../../static';
14
13
 
15
14
  export function echarts(ctx, node) {
16
- if(!(commonStore[node.TID] && commonStore[node.TID].data.dataResize)) return;
17
- //console.log('echarts绘制-----node', node);
18
- // 绘制一个底图,类似于占位符。
19
- rectangle(ctx, node)
20
- // tslint:disable-next-line:no-shadowed-variable
21
- var echarts = echartsDataStore.echarts || window.echarts
22
- if (!node.data || !echarts) {
23
- return
24
- }
25
- if (typeof node.data === 'string') {
26
- node.data = JSON.parse(node.data)
27
- }
28
- if (!node.data.echarts) {
29
- return
30
- }
31
- if (!node.elementId) {
32
- node.elementId = s8()
33
- }
34
- const currentElement = document.getElementById(node.id)
35
- if (!node.elementLoaded && !currentElement) {
36
- echartsDataStore[node.id] = {
37
- div: createDiv(node)
15
+ if (!(commonStore[node.TID] && commonStore[node.TID].data.dataResize)) return;
16
+ //console.log('echarts绘制-----node', node);
17
+ // if(currentElement) currentElement.style.display = !node.visible ? 'none': 'block';
18
+ // if(!node.visible) return;
19
+ // 绘制一个底图,类似于占位符。
20
+ rectangle(ctx, node)
21
+ // tslint:disable-next-line:no-shadowed-variable
22
+ var echarts = plugsPool.echarts || window.echarts
23
+ if (!node.data || !echarts) {
24
+ return
38
25
  }
39
- node.elementLoaded = true
40
- document.body.appendChild(echartsDataStore[node.id].div)
41
- // 添加当前节点到div层
42
- node.addToDiv('init')
43
- echartsDataStore[node.id].chart = echarts.init(echartsDataStore[node.id].div, node.data.echarts.theme)
44
- node.elementRendered = false
45
- // 等待父div先渲染完成,避免初始图表控件太大
46
- setTimeout(function() {
47
- echartsDataStore[node.id].chart.resize()
48
- })
49
- }
50
- if (!node.elementRendered) {
51
- const appearance = node.appearance;
52
- // 初始化时,等待父div先渲染完成,避免初始图表控件太大。
53
- setTimeout(function() {
54
- let option = node.data.echarts.option;
55
- const currentChartNode = echartsDataStore[node.id];
56
- const mapChart = currentChartNode.chart;
57
- const isLocked = commonStore[node.TID] && commonStore[node.TID].data.locked;
58
- if(!isLocked || !echartsOptionsStore[node.id]) {
59
- // 【未锁定(编辑)状态, options未初始化的状态】
60
- // 公共配置 Top排行榜跳过公共属性配置
61
- if(option.displayMode !== 4) option = setMapGlobalOptions(option, node);
62
- // 折线图和柱状图
63
- if (appearance.type === 'line' || appearance.type === 'bar') option = setMapLineBarOptions(option, node);
64
- // 仪表盘
65
- if (appearance.type === 'gauge') option = setMapGaugeOptions(option, node);
66
- // 环形图
67
- if (appearance.type === 'ring') option = setMapRingOptions(option, node);
68
- // 3d 柱状图
69
- if (appearance.type === '3dBar') option = setMap3dBarOptions(option, node);
70
- // Top排行榜
71
- if (appearance.type === 'TOP') option = setMapTopOptions(option, node);
72
- //option.title = appearance.title;
73
- option.backgroundColor = appearance.backgroundColor;
74
- echartsOptionsStore[node.id] = option;
75
- if(!isLocked) mapChart.clear();
76
- }else {
77
- // 【锁定状态且option值已初始化完成】
78
- option = setMapDataOptions(option, node);
79
- }
80
- // if (window.location.pathname.includes('workspace')) mapChart.clear();
81
- clearInterval(currentChartNode.timeTicket);
82
- currentChartNode.timeTicket = null;
83
- // 自动滑动展示数据
84
- if(appearance.timeTicket) {
85
- mapChart.off('mouseover');
86
- mapChart.off('mouseout');
87
- mapChart.on('mouseover', function(){
88
- setMapStopAutoMoveOptions(currentChartNode);
89
- });
90
- mapChart.on('mouseout', function(){
91
- setMapAutoMoveOptions(option, currentChartNode, node, function(chartNode){
92
- return mapChart.setOption(chartNode);
93
- })
26
+ if (typeof node.data === 'string') {
27
+ node.data = JSON.parse(node.data)
28
+ }
29
+ if (!node.data.echarts) {
30
+ return
31
+ }
32
+ if (!node.elementId) {
33
+ node.elementId = s8()
34
+ }
35
+ let echartsData = commonStore[node.TID].echartsDataPool[node.id];
36
+ if (!node.elementLoaded && !(echartsData && echartsData.div)) {
37
+ if(!echartsData) {
38
+ echartsData = {
39
+ div: createDiv(node)
40
+ };
41
+ }else {
42
+ echartsData.div = createDiv(node);
43
+ }
44
+ node.elementLoaded = true
45
+ document.body.appendChild(echartsData.div)
46
+ // 添加当前节点到div层
47
+ node.addToDiv()
48
+ echartsData.chart = echarts.init(echartsData.div, node.data.echarts.theme)
49
+ node.elementRendered = false
50
+ // 等待父div先渲染完成,避免初始图表控件太大
51
+ setTimeout(function () {
52
+ echartsData.chart.resize()
94
53
  });
95
- setMapAutoMoveOptions(option, currentChartNode, node, function(chartNode){
96
- return mapChart.setOption(chartNode);
54
+ commonStore[node.TID].echartsDataPool[node.id] = echartsData;
55
+ }
56
+ if (!node.elementRendered) {
57
+ const appearance = node.appearance;
58
+ // 初始化时,等待父div先渲染完成,避免初始图表控件太大。
59
+ setTimeout(function () {
60
+ let option = node.data.echarts.option;
61
+ 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
+ // 【未锁定(编辑)状态, options未初始化的状态】
65
+ if (!appearance.type) appearance.type = echartsTypeMap[`type_${option.displayMode}`]; // 兼容旧数据配置
66
+ // 公共配置 Top排行榜跳过公共属性配置
67
+ if (option.displayMode !== 4) setMapGlobalOptions(option, node);
68
+ // 折线图和柱状图
69
+ if (['line', 'bar'].includes(appearance.type)) setMapLineBarOptions(option, node);
70
+ // 仪表盘
71
+ if (appearance.type === 'gauge') setMapGaugeOptions(option, node);
72
+ // 环形图 || 饼图
73
+ if (appearance.type.includes('ring') || appearance.type.includes('pie')) setMapRingOptions(option, node);
74
+ // 3d 柱状图
75
+ if (appearance.type === '3dBar') setMap3dBarOptions(option, node);
76
+ // Top排行榜
77
+ if (appearance.type === 'TOP') setMapTopOptions(option, node);
78
+ //option.title = appearance.title;
79
+ option.backgroundColor = appearance.backgroundColor;
80
+ commonStore[node.TID].echartsOptionsPool[node.id] = {
81
+ option: JSON.parse(JSON.stringify(option)),
82
+ data: {
83
+ appearance,
84
+ id: node.id,
85
+ params: node.data.params
86
+ }
87
+ };
88
+ if (!isLocked) echartsData.chart.clear();
89
+ }
90
+ // echarts 数据渲染更新
91
+ setMapDataOptions(option, node);
92
+
93
+ node.elementRendered = true;
97
94
  })
98
- }
99
- mapChart.setOption(option);
100
- mapChart.resize();
101
- node.elementRendered = true;
102
- })
103
- }
95
+ }
104
96
  }
105
97
 
106
98
  //# sourceMappingURL=index.js.map
@@ -1,10 +1,10 @@
1
1
  import { registerNode } from '../../core';
2
2
  import { echarts } from './echarts';
3
- import { echartsDataStore } from '../../static';
3
+ import { plugsPool } from '../../store';
4
4
  // import './echarts/echarts.min.js';
5
5
  export function register(_echarts) {
6
- echartsDataStore.echarts = _echarts;
7
- // if (process.browser && !echartsDataStore.echarts && !window.echarts) {
6
+ plugsPool.echarts = _echarts;
7
+ // if (process.browser && !echartsDataPool.echarts && !window.echarts) {
8
8
  // //loadJS('https://cdn.bootcdn.net/ajax/libs/echarts/4.8.0/echarts.min.js', null, true);
9
9
  // loadJS(`${location.origin}/libary/echarts.min.js`, null, true);
10
10
  // }
@@ -1,4 +1,7 @@
1
- export declare function setChartLegendData<T>(legend: T, appearance: T): T;
2
- export declare function setChartXAxisData<T>(xAxis: [], appearance: T): [];
3
- export declare function setChartYAxisData<T>(yAxis: [], appearance: T): [];
4
- export declare function setLineSeriesStyleData<T>(series: [], appearance: T): [];
1
+ export declare function setRingChartText<T>(textData: T): void;
2
+ export declare function setRingPreSeriesOptions<T>(option: T, appearance: T): void;
3
+ export declare function setRingProSeriesOptions<T>(option: T, appearance: T): void;
4
+ export declare function setChartLegendData<T>(legend: T, appearance: T): void;
5
+ export declare function setChartXAxisData<T>(xAxis: [], appearance: T): void;
6
+ export declare function setChartYAxisData<T>(yAxis: [], appearance: T): void;
7
+ export declare function setLineSeriesStyleData<T>(series: [], appearance: T): void;
@@ -1,163 +1,247 @@
1
1
  // 初始化图例数据和图例配置数据
2
2
  import {
3
- echartsLegendDefaultData,
4
- echartsXAxisDefaultStyleData,
5
- echartsYAxisDefaultStyleData,
6
- echartsLineSeriesStyleData
3
+ echartsLegendDefaultData,
4
+ echartsXAxisDefaultStyleData,
5
+ echartsYAxisDefaultStyleData,
6
+ echartsLineSeriesStyleData,
7
+ echartsColorData
7
8
  } from '../../../static';
8
- // 图表X轴数据
9
- export function setChartXAxisData(xAxis, appearance){
10
- for (let i = 0; i < xAxis.length; i++) {
11
- const item = xAxis[i];
12
- if(!item.axisLabel) {
13
- item.axisLabel = JSON.parse(JSON.stringify(echartsXAxisDefaultStyleData['x1AxisLabel']));
9
+
10
+ // 配置环形图中间区域文字样式
11
+ export function setRingChartText(textData) {
12
+ const {
13
+ vFontSize, vFontWeight, vColor,
14
+ vTop, unitTop, unitFontSize, unitFontWeight,
15
+ unitColor} = textData;
16
+ if(!unitTop) textData.unitTop = 0;
17
+ return {
18
+ v: {
19
+ fontSize: vFontSize,
20
+ fontWeight: vFontWeight,
21
+ color: vColor,
22
+ padding: [vTop, 0, 0, 0]
23
+ },
24
+ unit: {
25
+ fontSize: unitFontSize,
26
+ fontWeight: unitFontWeight,
27
+ color: unitColor,
28
+ padding: [unitTop, 0, 0, 0]
29
+ }
30
+ };
31
+ }
32
+ // 配置环形‘设备告警统计图’节点展示
33
+ export function setRingPreSeriesOptions(option, appearance) {
34
+ const rich = setRingChartText(appearance.text);
35
+ Object.assign(option.title.textStyle.rich, rich);
36
+ option.title.y = `${appearance.text.y}%`;
37
+ option.series[0].radius[1] = `${appearance.inner.borderWidth}%`;
38
+ option.series[0].data[0].itemStyle.color = appearance.inner.borderColor;
39
+ option.series[0].data[1].itemStyle.color = appearance.inner.borderBgColor;
40
+ option.series[1].radius[1] = `${appearance.outer.borderWidth}%`;
41
+ option.series[1].data[0].itemStyle.color = appearance.outer.borderColor;
42
+ }
43
+ // 配置环形‘内存、硬盘、CPU指标占比统计’节点展示
44
+ export function setRingProSeriesOptions(option, appearance) {
45
+ const seriesFirstChildNode = option.series[0];
46
+ const rich = setRingChartText(appearance.text);
47
+ Object.assign(seriesFirstChildNode.data[0].label.normal.rich, rich);
48
+ seriesFirstChildNode.data[0].label.normal.formatter = function(params){
49
+ return `{v|${params.value}}{unit|%}`;
14
50
  }
15
- const axisLabelStr = `x${i+1}AxisLabel`;
16
- if(!appearance[axisLabelStr]) {
17
- appearance[axisLabelStr] = JSON.parse(JSON.stringify(echartsXAxisDefaultStyleData[axisLabelStr]));
18
- Object.assign(appearance[axisLabelStr], item.axisLabel);
19
- }else {
20
- item.axisLabel.color = appearance[axisLabelStr].color || '';
21
- item.axisLabel.fontSize = appearance[axisLabelStr].fontSize || 12;
51
+ seriesFirstChildNode.data[0].value = appearance.proportion;
52
+ seriesFirstChildNode.radius = appearance.outer.radius;
53
+ seriesFirstChildNode.data[0].itemStyle = {
54
+ normal: {
55
+ color: appearance.outer.borderColor,
56
+ shadowColor: appearance.outer.borderColor,
57
+ shadowBlur: 0
58
+ }
59
+ };
60
+ seriesFirstChildNode.data[1].value = 100 - appearance.proportion;
61
+ seriesFirstChildNode.data[1].itemStyle.normal.color = appearance.outer.borderBgColor;
62
+ const seriesLastChildNode = option.series[1];
63
+ seriesLastChildNode.radius = appearance.inner.radius;
64
+ seriesLastChildNode.itemStyle.normal.color.colorStops[0].color = appearance.inner.borderColor;
65
+ }
66
+ // 图表X轴数据
67
+ export function setChartXAxisData(xAxis, appearance) {
68
+ for (let i = 0; i < xAxis.length; i++) {
69
+ const item = xAxis[i];
70
+ if (!item.axisLabel) {
71
+ item.axisLabel = JSON.parse(JSON.stringify(echartsXAxisDefaultStyleData['x1AxisLabel']));
72
+ }
73
+ const axisLabelStr = `x${i + 1}AxisLabel`;
74
+ if (!appearance[axisLabelStr]) {
75
+ appearance[axisLabelStr] = JSON.parse(JSON.stringify(echartsXAxisDefaultStyleData[axisLabelStr]));
76
+ Object.assign(appearance[axisLabelStr], item.axisLabel);
77
+ } else {
78
+ item.axisLabel.color = appearance[axisLabelStr].color || '';
79
+ item.axisLabel.fontSize = appearance[axisLabelStr].fontSize || 12;
80
+ }
22
81
  }
23
- }
24
- return xAxis;
82
+ //return xAxis;
25
83
  }
84
+
26
85
  // 图表Y轴数据
27
- export function setChartYAxisData(yAxis, appearance){
28
- if(typeof appearance.ySplitLineShow !== 'boolean') {
29
- appearance.ySplitLineShow = yAxis[0].splitLine.show;
30
- }
31
- if(!appearance.ysplitLineLineStyle && yAxis[0].splitLine.show) {
32
- appearance.ysplitLineLineStyle = JSON.parse(JSON.stringify(echartsYAxisDefaultStyleData['ysplitLineLineStyle']));
33
- }
34
- for (let i = 0; i < yAxis.length; i++) {
35
- const item = yAxis[i];
36
- if(!item.axisLabel.textStyle) {
37
- item.axisLabel.textStyle = JSON.parse(JSON.stringify(echartsYAxisDefaultStyleData['y1axisLabelTextStyle']));
86
+ export function setChartYAxisData(yAxis, appearance) {
87
+ if (typeof appearance.ySplitLineShow !== 'boolean') {
88
+ appearance.ySplitLineShow = yAxis[0].splitLine.show;
38
89
  }
39
- if(!item.splitLine.lineStyle) {
40
- item.splitLine.lineStyle = JSON.parse(JSON.stringify(echartsYAxisDefaultStyleData['ysplitLineLineStyle']));
90
+ if (!appearance.ysplitLineLineStyle && yAxis[0].splitLine.show) {
91
+ appearance.ysplitLineLineStyle = JSON.parse(JSON.stringify(echartsYAxisDefaultStyleData['ysplitLineLineStyle']));
41
92
  }
42
- const axisLabelTextStyleStr = `y${i+1}axisLabelTextStyle`;
43
- if(!appearance[axisLabelTextStyleStr]) {
44
- appearance[axisLabelTextStyleStr] = JSON.parse(JSON.stringify(echartsYAxisDefaultStyleData[axisLabelTextStyleStr]));
45
- Object.assign(appearance[axisLabelTextStyleStr], item.axisLabel.textStyle);
46
- }else {
47
- const axisLabelTextStyNode = appearance[axisLabelTextStyleStr];
48
- item.axisLabel.textStyle.color = axisLabelTextStyNode.color || '';
49
- item.axisLabel.textStyle.fontSize = axisLabelTextStyNode.fontSize || '12';
50
- item.axisLabel.textStyle.padding = axisLabelTextStyNode.padding || [20, 20, 20, 20];
93
+ for (let i = 0; i < yAxis.length; i++) {
94
+ const item = yAxis[i];
95
+ if (!item.axisLabel.textStyle) {
96
+ item.axisLabel.textStyle = JSON.parse(JSON.stringify(echartsYAxisDefaultStyleData['y1axisLabelTextStyle']));
97
+ }
98
+ if (!item.splitLine.lineStyle) {
99
+ item.splitLine.lineStyle = JSON.parse(JSON.stringify(echartsYAxisDefaultStyleData['ysplitLineLineStyle']));
100
+ }
101
+ const axisLabelTextStyleStr = `y${i + 1}axisLabelTextStyle`;
102
+ if (!appearance[axisLabelTextStyleStr]) {
103
+ appearance[axisLabelTextStyleStr] = JSON.parse(JSON.stringify(echartsYAxisDefaultStyleData[axisLabelTextStyleStr]));
104
+ Object.assign(appearance[axisLabelTextStyleStr], item.axisLabel.textStyle);
105
+ } else {
106
+ const axisLabelTextStyNode = appearance[axisLabelTextStyleStr];
107
+ item.axisLabel.textStyle.color = axisLabelTextStyNode.color || '';
108
+ item.axisLabel.textStyle.fontSize = axisLabelTextStyNode.fontSize || '12';
109
+ item.axisLabel.textStyle.padding = axisLabelTextStyNode.padding || [20, 20, 20, 20];
110
+ }
111
+ if (appearance.ysplitLineLineStyle) {
112
+ item.splitLine.show = appearance.ySplitLineShow;
113
+ const axisLabelTextStyNode = appearance.ysplitLineLineStyle;
114
+ item.splitLine.lineStyle.type = axisLabelTextStyNode.type || 'solid';
115
+ item.splitLine.lineStyle.color = axisLabelTextStyNode.color || '';
116
+ }
117
+ const minMaxStr = `y${i + 1}MinMaxData`;
118
+ if (!appearance[minMaxStr] && item.max) {
119
+ appearance[minMaxStr] = JSON.parse(JSON.stringify(echartsYAxisDefaultStyleData[minMaxStr]));
120
+ const minMaxParams = {
121
+ max: item.max,
122
+ min: item.min,
123
+ interval: item.interval
124
+ };
125
+ Object.assign(appearance[minMaxStr], minMaxParams);
126
+ } else {
127
+ const minMaxNode = appearance[minMaxStr];
128
+ if (minMaxNode) {
129
+ item.max = minMaxNode.max;
130
+ item.min = minMaxNode.min;
131
+ item.interval = minMaxNode.interval;
132
+ }
133
+ }
134
+ const nameStr = `y${i + 1}NameData`;
135
+ if (!appearance[nameStr] && item.name) {
136
+ appearance[nameStr] = JSON.parse(JSON.stringify(echartsYAxisDefaultStyleData[nameStr]));
137
+ const nameParams = {
138
+ name: item.name,
139
+ nameTextStyle: {
140
+ color: item.nameTextStyle.color,
141
+ padding: item.nameTextStyle.padding,
142
+ },
143
+ nameGap: item.nameGap
144
+ };
145
+ Object.assign(appearance[nameStr], nameParams);
146
+ } else {
147
+ const nameNode = appearance[nameStr];
148
+ if (nameNode) {
149
+ item.name = nameNode.name;
150
+ item.nameTextStyle.color = nameNode.nameTextStyle.color;
151
+ item.nameTextStyle.padding = nameNode.nameTextStyle.padding;
152
+ item.nameGap = nameNode.nameGap;
153
+ }
154
+ }
51
155
  }
52
- if(appearance.ysplitLineLineStyle) {
53
- item.splitLine.show = appearance.ySplitLineShow;
54
- const axisLabelTextStyNode = appearance.ysplitLineLineStyle;
55
- item.splitLine.lineStyle.type = axisLabelTextStyNode.type || 'solid';
56
- item.splitLine.lineStyle.color = axisLabelTextStyNode.color || '';
57
- }
58
- const minMaxStr = `y${i+1}MinMaxData`;
59
- if(!appearance[minMaxStr] && item.max){
60
- appearance[minMaxStr] = JSON.parse(JSON.stringify(echartsYAxisDefaultStyleData[minMaxStr]));
61
- const minMaxParams = {
62
- max: item.max,
63
- min: item.min,
64
- interval: item.interval
65
- };
66
- Object.assign(appearance[minMaxStr], minMaxParams);
67
- }else {
68
- const minMaxNode = appearance[minMaxStr];
69
- if(minMaxNode) {
70
- item.max = minMaxNode.max;
71
- item.min = minMaxNode.min;
72
- item.interval = minMaxNode.interval;
73
- }
74
- }
75
- const nameStr = `y${i+1}NameData`;
76
- if(!appearance[nameStr] && item.name){
77
- appearance[nameStr] = JSON.parse(JSON.stringify(echartsYAxisDefaultStyleData[nameStr]));
78
- const nameParams = {
79
- name: item.name,
80
- nameTextStyle: {
81
- color: item.nameTextStyle.color,
82
- padding: item.nameTextStyle.padding,
83
- },
84
- nameGap: item.nameGap
85
- };
86
- Object.assign(appearance[nameStr], nameParams);
87
- }else {
88
- const nameNode = appearance[nameStr];
89
- if(nameNode) {
90
- item.name = nameNode.name;
91
- item.nameTextStyle.color = nameNode.nameTextStyle.color;
92
- item.nameTextStyle.padding = nameNode.nameTextStyle.padding;
93
- item.nameGap = nameNode.nameGap;
94
- }
95
- }
96
- }
97
- return yAxis;
156
+ //return yAxis;
98
157
  }
158
+
99
159
  // 图表图例数据
100
160
  export function setChartLegendData(legend, appearance) {
101
- if(!legend.formatter) legend.formatter = ['{a|{name}}'].join('\n');
102
- // 设置默认图例文字配置,如果想改变初始化文字属性,在 appearance中配置即可
103
- if(!legend.textStyle) legend.textStyle = {
104
- color: '#fff',
105
- height: 8,
106
- rich: {
107
- a: {
108
- fontSize: 12,
109
- verticalAlign: 'bottom',
110
- }
161
+ if (!legend.formatter) legend.formatter = ['{a|{name}}'].join('\n');
162
+ // 设置默认图例文字配置,如果想改变初始化文字属性,在 appearance中配置即可
163
+ if (!legend.textStyle) legend.textStyle = {
164
+ color: '#fff',
165
+ height: 8
166
+ };
167
+ legend.textStyle.rich = {
168
+ a: {
169
+ fontSize: 12,
170
+ verticalAlign: 'bottom',
171
+ }
172
+ };
173
+ if (!appearance.legend) {
174
+ appearance.legend = JSON.parse(JSON.stringify(echartsLegendDefaultData));
175
+ Object.assign(appearance.legend, legend);
176
+ delete appearance.legend['data'];
177
+ delete appearance.legend['textStyle'];
178
+ } else {
179
+ const {
180
+ icon,
181
+ itemWidth,
182
+ itemHeight,
183
+ itemGap,
184
+ top,
185
+ right,
186
+ bottom,
187
+ left,
188
+ padding,
189
+ color,
190
+ height,
191
+ fontSize
192
+ } = appearance.legend;
193
+ legend.icon = icon || '';
194
+ legend.itemWidth = itemWidth || 12;
195
+ legend.itemHeight = itemHeight || 12;
196
+ legend.itemGap = itemGap || 8;
197
+ legend.top = top || 'auto';
198
+ legend.right = right || 'auto';
199
+ legend.bottom = bottom || 'auto';
200
+ legend.left = left || 'auto';
201
+ legend.padding = padding || [5, 5, 5, 5];
202
+ legend.textStyle.color = color || '';
203
+ legend.textStyle.height = height || 8;
204
+ legend.textStyle.rich.a = fontSize || 12;
111
205
  }
112
- };
113
- if (!appearance.legend) {
114
- appearance.legend = JSON.parse(JSON.stringify(echartsLegendDefaultData));
115
- Object.assign(appearance.legend, legend);
116
- delete appearance.legend['data'];
117
- delete appearance.legend['textStyle'];
118
- }else {
119
- const { icon, itemWidth, itemHeight, itemGap, top, right, bottom, left, padding, color, height, fontSize } = appearance.legend;
120
- legend.icon = icon || '';
121
- legend.itemWidth = itemWidth || 12;
122
- legend.itemHeight = itemHeight || 12;
123
- legend.itemGap = itemGap || 8;
124
- legend.top = top || 'auto';
125
- legend.right = right || 'auto';
126
- legend.bottom = bottom || 'auto';
127
- legend.left = left || 'auto';
128
- legend.padding = padding || [5, 5, 5, 5];
129
- legend.textStyle.color = color || '';
130
- legend.textStyle.height = height || 8;
131
- legend.textStyle.rich.a = fontSize || 12;
132
- }
133
- return legend;
206
+ //return legend;
134
207
  }
208
+
135
209
  // 图表曲线数据配置
136
210
  export function setLineSeriesStyleData(series, appearance) {
137
- const defaultSeriesStyle = JSON.parse(JSON.stringify(echartsLineSeriesStyleData));
138
- if(!appearance.seriesOptions) appearance.seriesOptions = [defaultSeriesStyle];
139
- for (let i = 0; i < series.length; i++) {
140
- const item = series[i];
141
- const appearanceSeries = appearance.seriesOptions[i] || defaultSeriesStyle;
142
- item.symbol = appearanceSeries.symbol;
143
- item.smooth = appearanceSeries.smooth;
144
- item.symbolSize = appearanceSeries.symbolSize || 18;
145
- item.itemStyle = {
146
- normal: {
147
- color: appearanceSeries.itemLineStyle.color,
148
- lineStyle: appearanceSeries.itemLineStyle
149
- }
150
- };
151
- if(appearanceSeries.area) {
152
- item.areaStyle = {
153
- color: appearanceSeries.areaColor && { ...appearanceSeries.areaColor } || { ...defaultSeriesStyle.areaColor }
154
- };
155
- appearanceSeries.linear ?
156
- item.areaStyle.color.colorStops = [...appearanceSeries.areaColorStops] :
157
- item.areaStyle = Object.assign({}, item.areaStyle, {color: appearanceSeries.areaBgColor || 'rgba(49, 144, 255, 0.21)'});
158
- }else {
159
- if(item.areaStyle) delete item['areaStyle'];
211
+ let seriesOptions = [];
212
+ for (let i = 0; i < series.length; i++) {
213
+ const defaultSeriesStyle = JSON.parse(JSON.stringify(echartsLineSeriesStyleData));
214
+ const item = series[i];
215
+ let appearanceSeries = appearance.seriesOptions && appearance.seriesOptions[i];
216
+ if(!appearanceSeries) {
217
+ appearanceSeries = defaultSeriesStyle;
218
+ appearanceSeries.name = item.name;
219
+ appearanceSeries.itemLineStyle.color = i === 0 ? defaultSeriesStyle.itemLineStyle.color : echartsColorData[i];
220
+ seriesOptions.push(defaultSeriesStyle);
221
+ }else {
222
+ seriesOptions.push(appearanceSeries);
223
+ }
224
+ item.symbol = appearanceSeries.symbol;
225
+ item.smooth = appearanceSeries.smooth;
226
+ item.symbolSize = appearanceSeries.symbolSize || 18;
227
+ item.itemStyle = {
228
+ normal: {
229
+ color: appearanceSeries.itemLineStyle.color,
230
+ lineStyle: appearanceSeries.itemLineStyle
231
+ }
232
+ };
233
+ if (appearanceSeries.area) {
234
+ item.areaStyle = {
235
+ color: appearanceSeries.areaColor && {...appearanceSeries.areaColor} || {...defaultSeriesStyle.areaColor}
236
+ };
237
+ appearanceSeries.linear ?
238
+ item.areaStyle.color.colorStops = [...appearanceSeries.areaColorStops] :
239
+ item.areaStyle = Object.assign({}, item.areaStyle, {color: appearanceSeries.areaBgColor || 'rgba(49, 144, 255, 0.21)'});
240
+ } else {
241
+ if (item.areaStyle) delete item['areaStyle'];
242
+ }
160
243
  }
161
- }
162
- return series;
244
+
245
+ appearance.seriesOptions = seriesOptions;
246
+ //return series;
163
247
  }