dcim-topology2d 1.1.3 → 1.1.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 (42) hide show
  1. package/chart-diagram/index.d.ts +2 -0
  2. package/chart-diagram/index.js +1 -0
  3. package/chart-diagram/src/echarts/index.d.ts +0 -1
  4. package/chart-diagram/src/echarts/index.js +106 -107
  5. package/chart-diagram/src/register.js +9 -8
  6. package/chart-diagram/src/utils/changeOptions.d.ts +4 -0
  7. package/chart-diagram/src/utils/changeOptions.js +163 -0
  8. package/chart-diagram/src/utils/conversion.d.ts +17 -0
  9. package/chart-diagram/src/utils/conversion.js +179 -0
  10. package/chart-diagram/src/utils/drawGraphic.d.ts +3 -0
  11. package/chart-diagram/src/utils/drawGraphic.js +97 -0
  12. package/chart-diagram/src/utils/index.d.ts +3 -0
  13. package/chart-diagram/src/utils/index.js +3 -0
  14. package/core/src/common.js +27 -30
  15. package/core/src/core.js +115 -73
  16. package/core/src/divLayer.d.ts +0 -26
  17. package/core/src/divLayer.js +22 -276
  18. package/core/src/healps/changeData.js +45 -22
  19. package/core/src/middles/arrows/index.d.ts +4 -0
  20. package/core/src/middles/arrows/index.js +5 -0
  21. package/core/src/middles/default.d.ts +1 -3
  22. package/core/src/middles/default.js +51 -51
  23. package/core/src/middles/index.js +3 -2
  24. package/core/src/middles/lines/index.d.ts +4 -0
  25. package/core/src/middles/lines/index.js +5 -0
  26. package/core/src/middles/nodes/iframe.d.ts +2 -0
  27. package/core/src/middles/nodes/iframe.js +12 -0
  28. package/core/src/middles/nodes/index.d.ts +46 -0
  29. package/core/src/middles/nodes/index.js +47 -0
  30. package/core/src/middles/nodes/pentagon.rect.js +1 -1
  31. package/core/src/middles/nodes/rectangle.rect.js +1 -1
  32. package/core/src/models/node.d.ts +6 -0
  33. package/core/src/models/node.js +16 -6
  34. package/core/src/preview.js +14 -0
  35. package/core/src/store/data.js +2 -0
  36. package/core/src/utils/dom.d.ts +2 -0
  37. package/core/src/utils/dom.js +81 -47
  38. package/package.json +1 -1
  39. package/static/echartsDefaultData.js +239 -95
  40. package/static/echartsStore.js +14 -0
  41. package/static/index.js +2 -1
  42. package/style/index.css +3 -0
@@ -1,3 +1,5 @@
1
+ // @ts-ignore
2
+ export * from './src/utils';
1
3
  export * from './src/echarts';
2
4
  export * from './src/register';
3
5
  export * from '../myShape-diagram/myShape';
@@ -1,3 +1,4 @@
1
+ export * from './src/utils';
1
2
  export * from './src/echarts';
2
3
  export * from './src/register';
3
4
  export * from '../myShape-diagram/myShape.js';
@@ -1,4 +1,3 @@
1
1
  // @ts-ignore
2
2
  import { Node } from '../../../core';
3
- export declare const echartsData: any;
4
3
  export declare function echarts(ctx: CanvasRenderingContext2D, node: Node): void;
@@ -1,107 +1,106 @@
1
- import { s8, createDiv, rectangle } from '../../../core';
2
- export let echartsData = {};
3
- export function echarts(ctx, node) {
4
- //console.log('echarts绘制-----node', node);
5
- // 绘制一个底图,类似于占位符。
6
- rectangle(ctx, node);
7
- // tslint:disable-next-line:no-shadowed-variable
8
- var echarts = echartsData.echarts || window.echarts;
9
- if (!node.data || !echarts) {
10
- return;
11
- }
12
- if (typeof node.data === 'string') {
13
- node.data = JSON.parse(node.data);
14
- }
15
- if (!node.data.echarts) {
16
- return;
17
- }
18
- if (!node.elementId) {
19
- node.elementId = s8();
20
- }
21
- const currentElement = document.getElementById(node.id);
22
- if (!node.elementLoaded && !currentElement) {
23
- // if(echartsData[node.id]) {
24
- // const appearCharts = echarts.getInstanceByDom(echartsData[node.id].div);
25
- // if (appearCharts) echarts.dispose(appearCharts);
26
- // echartsData[node.id] = null;
27
- // }
28
- echartsData[node.id] = {
29
- div: createDiv(node)
30
- };
31
- node.elementLoaded = true;
32
- document.body.appendChild(echartsData[node.id].div);
33
- // 添加当前节点到div层
34
- node.addToDiv('init');
35
- echartsData[node.id].chart = echarts.init(echartsData[node.id].div, node.data.echarts.theme);
36
- node.elementRendered = false;
37
- // 等待父div先渲染完成,避免初始图表控件太大
38
- setTimeout(function () {
39
- echartsData[node.id].chart.resize();
40
- });
41
- }
42
- if (!node.elementRendered) {
43
- // 初始化时,等待父div先渲染完成,避免初始图表控件太大。
44
- setTimeout(function () {
45
- let option = {...node.data.echarts.option};
46
- if(node.appearance.type === 'line' || node.appearance.type === 'bar') {
47
- option.color = node.appearance.color;
48
- option.xAxis[0].axisLabel.formatter = function(value, index){
49
- if (index === 0 || index%(node.appearance.intervalNumX) === 0){
50
- return value;
51
- }
52
- else {
53
- return '';
54
- }
55
- }
56
-
57
- option.yAxis[0].axisLabel.formatter = function(value, index){
58
- if (index === 0 || index%(node.appearance.intervalNumY) === 0){
59
- return value;
60
- }
61
- else {
62
- return '';
63
- }
64
- }
65
- if(option.series.length < 2) {
66
- option.tooltip.formatter = function(params) {
67
- const item = params[0];
68
- return item.name + ' : ' + item.value;
69
- }
70
- }
71
- // if(option.series.length >= 2) {
72
-
73
- // for(let i=0; i<option.series.length-1 ; i++){
74
-
75
- // option.color.push(node.appearance.color[0])
76
- // }
77
- // }
78
- option.yAxis[0].splitLine = node.appearance.splitLine;
79
-
80
- }else if(node.appearance.type === 'gauge') {
81
- option.series[0].min = node.appearance.min;
82
- option.series[0].max = node.appearance.max;
83
- option.series[0].splitNumber = node.appearance.splitNumber;
84
- option.series[0].pointer = node.appearance.pointer;
85
- option.series[0].axisLabel = node.appearance.axisLabel;
86
- option.series[0].axisLine.lineStyle = node.appearance.axisLine.lineStyle;
87
- if(node.appearance.detail) option.series[0].detail = node.appearance.detail;
88
- if(node.appearance.data) option.series[0].data = node.appearance.data;
89
- if(option.isGaugeLinear) {
90
- option.series[0].axisLine.lineStyle.color = [
91
- [1, new echarts.graphic.LinearGradient(0, 0, 1, 0, option.linearColors)]
92
- ]
93
- }
94
- }else if(node.appearance.type === 'ring') {
95
- option.series[0].radius = [`${node.appearance.innerRadius}%`, `${node.appearance.outerRadius}%`];
96
- option.series[0].label = node.appearance.label;
97
- }
98
- option.title = node.appearance.title;
99
- option.backgroundColor = node.appearance.backgroundColor;
100
- if(window.location.pathname.includes('workspace')) echartsData[node.id].chart.clear();
101
- echartsData[node.id].chart.setOption(option);
102
- echartsData[node.id].chart.resize();
103
- node.elementRendered = true;
104
- });
105
- }
106
- }
107
- //# sourceMappingURL=index.js.map
1
+ import { s8, createDiv, rectangle, commonStore } from '../../../core';
2
+ import {
3
+ setMapLineBarOptions,
4
+ setMapGaugeOptions,
5
+ setMapRingOptions,
6
+ setMapAutoMoveOptions,
7
+ setMapStopAutoMoveOptions,
8
+ setMap3dBarOptions,
9
+ setMapTopOptions,
10
+ setMapGlobalOptions,
11
+ setMapDataOptions
12
+ } from '../utils';
13
+ import { echartsDataStore, echartsOptionsStore } from '../../../static';
14
+
15
+ 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)
38
+ }
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
+ })
94
+ });
95
+ setMapAutoMoveOptions(option, currentChartNode, node, function(chartNode){
96
+ return mapChart.setOption(chartNode);
97
+ })
98
+ }
99
+ mapChart.setOption(option);
100
+ mapChart.resize();
101
+ node.elementRendered = true;
102
+ })
103
+ }
104
+ }
105
+
106
+ //# sourceMappingURL=index.js.map
@@ -1,12 +1,13 @@
1
- import { registerNode, loadJS } from '../../core';
2
- import { echarts, echartsData } from './echarts';
3
- import './echarts/echarts.min.js';
1
+ import { registerNode } from '../../core';
2
+ import { echarts } from './echarts';
3
+ import { echartsDataStore } from '../../static';
4
+ // import './echarts/echarts.min.js';
4
5
  export function register(_echarts) {
5
- echartsData.echarts = _echarts;
6
- if (process.browser && !echartsData.echarts && !window.echarts) {
7
- //loadJS('https://cdn.bootcdn.net/ajax/libs/echarts/4.8.0/echarts.min.js', null, true);
8
- loadJS(`${location.origin}/libary/echarts.min.js`, null, true);
9
- }
6
+ echartsDataStore.echarts = _echarts;
7
+ // if (process.browser && !echartsDataStore.echarts && !window.echarts) {
8
+ // //loadJS('https://cdn.bootcdn.net/ajax/libs/echarts/4.8.0/echarts.min.js', null, true);
9
+ // loadJS(`${location.origin}/libary/echarts.min.js`, null, true);
10
+ // }
10
11
  registerNode('echarts', echarts, null, null, null);
11
12
  }
12
13
  //# sourceMappingURL=register.js.map
@@ -0,0 +1,4 @@
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): [];
@@ -0,0 +1,163 @@
1
+ // 初始化图例数据和图例配置数据
2
+ import {
3
+ echartsLegendDefaultData,
4
+ echartsXAxisDefaultStyleData,
5
+ echartsYAxisDefaultStyleData,
6
+ echartsLineSeriesStyleData
7
+ } 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']));
14
+ }
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;
22
+ }
23
+ }
24
+ return xAxis;
25
+ }
26
+ // 图表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']));
38
+ }
39
+ if(!item.splitLine.lineStyle) {
40
+ item.splitLine.lineStyle = JSON.parse(JSON.stringify(echartsYAxisDefaultStyleData['ysplitLineLineStyle']));
41
+ }
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];
51
+ }
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;
98
+ }
99
+ // 图表图例数据
100
+ 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
+ }
111
+ }
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;
134
+ }
135
+ // 图表曲线数据配置
136
+ 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'];
160
+ }
161
+ }
162
+ return series;
163
+ }
@@ -0,0 +1,17 @@
1
+ interface echartsOptions {
2
+ color: '',
3
+ xAxis: [],
4
+ yAxis: [],
5
+ series: [],
6
+ tooltip: null
7
+ }
8
+ export declare function getXYAxisLabelVal(index: number, intervalNum: number, value: any): string;
9
+ export declare function setMapLineBarOptions(option: echartsOptions, node: any): echartsOptions;
10
+ export declare function setMapGaugeOptions(option: echartsOptions, node: any): echartsOptions;
11
+ export declare function setMapRingOptions(option: echartsOptions, node: any): echartsOptions;
12
+ export declare function setMap3dBarOptions(option: echartsOptions, node: any): echartsOptions;
13
+ export declare function setMapTopOptions(option: echartsOptions, node: any): echartsOptions;
14
+ export declare function setMapGlobalOptions(option: echartsOptions, node: any): echartsOptions;
15
+ export declare function setMapDataOptions(option: echartsOptions, node: any): echartsOptions;
16
+ export declare function setMapAutoMoveOptions(option: echartsOptions, chartNode: string,node: any, callback: any): void;
17
+ export declare function setMapStopAutoMoveOptions(chartNode: string): void;
@@ -0,0 +1,179 @@
1
+ import { echartsDataRoom, echartsOptionsStore } from '../../../static';
2
+ import {
3
+ setSeriesRenderGroup,
4
+ drawGraphicShape,
5
+ setChartLegendData,
6
+ setChartXAxisData,
7
+ setChartYAxisData,
8
+ setLineSeriesStyleData
9
+ } from '../utils';
10
+
11
+ export function getXYAxisLabelVal(index, intervalNum, value) {
12
+ if (index === 0 || index % intervalNum === 0) {
13
+ return value;
14
+ } else {
15
+ return '';
16
+ }
17
+ }
18
+ // 自动滑动展示数据
19
+ export function setMapAutoMoveOptions(option, chartNode, node, callback) {
20
+ option.dataZoom = echartsDataRoom;
21
+ const dataZoomNode = option.dataZoom[0];
22
+ const { start, end, time } = node.appearance.zoomParams;
23
+ const zoomStart = Number(start);
24
+ const zoomEnd = Number(end);
25
+ const zoomTime = Number(time);
26
+ dataZoomNode.start = zoomStart;
27
+ dataZoomNode.end = zoomEnd;
28
+ chartNode.timeTicket = setInterval(() => {
29
+ if (Number(dataZoomNode.end) > 100) {
30
+ dataZoomNode.end = zoomEnd;
31
+ dataZoomNode.start = zoomStart;
32
+ } else {
33
+ dataZoomNode.end = dataZoomNode.end + 1 * (100 / option.series[0].data.length);
34
+ dataZoomNode.start = dataZoomNode.start + 1 * (100 / option.series[0].data.length);
35
+ }
36
+ callback(option);
37
+ }, zoomTime * 1000);
38
+ }
39
+ // 停止自动滑动展示数据
40
+ export function setMapStopAutoMoveOptions(chartNode) {
41
+
42
+ clearInterval(chartNode.timeTicket);
43
+
44
+ }
45
+ // 自动配置折线和柱状图的节点数据
46
+ export function setMapLineBarOptions(option, node) {
47
+ const chartOption = JSON.parse(JSON.stringify(option));
48
+ chartOption.color = node.appearance.color;
49
+ chartOption.xAxis[0].axisLabel.formatter = function(value, index) {
50
+ return getXYAxisLabelVal(index, node.appearance.intervalNumX, value);
51
+ }
52
+ chartOption.yAxis[0].axisLabel.formatter = function(value, index) {
53
+ return getXYAxisLabelVal(index, node.appearance.intervalNumY, value);
54
+ }
55
+ if (chartOption.series.length < 2) {
56
+ chartOption.tooltip.formatter = function(params) {
57
+ const item = params[0];
58
+ return item.name + ' : ' + item.value;
59
+ }
60
+ }
61
+ // chartOption.yAxis[0].splitLine = node.appearance.splitLine;
62
+ return chartOption;
63
+ }
64
+ // 自动配置仪表盘的节点数据
65
+ export function setMapGaugeOptions(option, node) {
66
+ const chartOption = JSON.parse(JSON.stringify(option));
67
+ const seriesNode = chartOption.series[0];
68
+ const appearance = node.appearance;
69
+ seriesNode.min = appearance.min;
70
+ seriesNode.max = appearance.max;
71
+ seriesNode.splitNumber = appearance.splitNumber;
72
+ seriesNode.pointer = appearance.pointer;
73
+ seriesNode.axisLabel = appearance.axisLabel;
74
+ seriesNode.axisLine.lineStyle = appearance.axisLine.lineStyle;
75
+ if(appearance.detail) seriesNode.detail = appearance.detail;
76
+ if(appearance.data) seriesNode.data = appearance.data;
77
+ if(chartOption.isGaugeLinear) {
78
+ seriesNode.axisLine.lineStyle.color = [
79
+ [1, new echarts.graphic.LinearGradient(0, 0, 1, 0, chartOption.linearColors)]
80
+ ]
81
+ }
82
+ return chartOption;
83
+ }
84
+ // 自动配置环形图和饼图的节点数据
85
+ export function setMapRingOptions(option, node) {
86
+ const chartOption = JSON.parse(JSON.stringify(option));
87
+ const seriesNode = chartOption.series[0];
88
+ const appearance = node.appearance;
89
+ seriesNode.radius = [`${appearance.innerRadius}%`, `${appearance.outerRadius}%`];
90
+ seriesNode.label = appearance.label;
91
+ return chartOption;
92
+ }
93
+ // 自动配置3D柱状图的节点数据
94
+ export function setMap3dBarOptions(option, node) {
95
+ // 取消注册自定义形状
96
+ const chartOption = JSON.parse(JSON.stringify(option));
97
+ const seriesNode = chartOption.series[0];
98
+ const appearance = node.appearance;
99
+ if(appearance.seriesCubeLeftLinear) appearance.seriesCubeLeftColor = 'rgb(0, 128, 215)';
100
+ if(appearance.seriesCubeRightLinear) appearance.seriesCubeRightColor = 'rgb(3, 58, 125)';
101
+ if(appearance.graphicShape) {
102
+ const { CubeLeft, CubeRight, CubeTop } = drawGraphicShape(appearance);
103
+ // 注册三个面图形
104
+ echarts.graphic.registerShape('CubeLeft', CubeLeft);
105
+ echarts.graphic.registerShape('CubeRight', CubeRight);
106
+ echarts.graphic.registerShape('CubeTop', CubeTop);
107
+ seriesNode.renderItem = (params, api) => {
108
+ const seriesRenderData = setSeriesRenderGroup(appearance, api);
109
+ return {
110
+ type: 'group',
111
+ children: seriesRenderData,
112
+ };
113
+ };
114
+ }
115
+ chartOption.tooltip.formatter = function(params) {
116
+ const item = params[0];
117
+ return item.name + ' : ' + item.value;
118
+ }
119
+ return chartOption;
120
+ }
121
+ export function setMapTopOptions(option, node) {
122
+ const chartOption = JSON.parse(JSON.stringify(option));
123
+ const appearance = node.appearance;
124
+ Object.assign(chartOption.grid, appearance.grid);
125
+ return chartOption;
126
+ }
127
+ // 公共配置
128
+ export function setMapGlobalOptions(option, node) {
129
+ const chartOption = JSON.parse(JSON.stringify(option));
130
+ const appearance = node.appearance;
131
+ // 图表网格数据
132
+ if (appearance.grid) {
133
+
134
+ chartOption.grid ? Object.assign(chartOption.grid, appearance.grid) : chartOption.grid = appearance.grid;
135
+
136
+ }
137
+ // 图表X轴数据
138
+ if(chartOption.xAxis) setChartXAxisData(chartOption.xAxis, appearance);
139
+ // 图表Y轴数据
140
+ if(chartOption.yAxis) setChartYAxisData(chartOption.yAxis, appearance);
141
+ // 图表图例数据
142
+ if (chartOption.legend) setChartLegendData(chartOption.legend, appearance);
143
+ // 曲线样式数据
144
+ if (appearance.type.includes('line')) setLineSeriesStyleData(chartOption.series, appearance);
145
+
146
+ return chartOption;
147
+ }
148
+ // 实时改变图表data值
149
+ export function setMapDataOptions(option, node) {
150
+ const optionNode = echartsOptionsStore[node.id];
151
+ if (option.legend) {
152
+ optionNode.legend = option.legend;
153
+ }else {
154
+ delete optionNode['legend'];
155
+ }
156
+ if(option.xAxis) {
157
+ for (let i = 0; i < option.xAxis.length; i++) {
158
+ const item = option.xAxis[i];
159
+ if(item.data){
160
+ optionNode.xAxis[i].data = item.data;
161
+ }
162
+ }
163
+ }
164
+ if(option.yAxis) {
165
+ for (let i = 0; i < option.yAxis.length; i++) {
166
+ const item = option.yAxis[i];
167
+ if(item.data){
168
+ optionNode.yAxis[i].data = item.data;
169
+ };
170
+ }
171
+ }
172
+ if(option.series) {
173
+ for (let i = 0; i < option.series.length; i++) {
174
+ const item = option.series[i];
175
+ optionNode.series[i].data = item.data;
176
+ }
177
+ }
178
+ return optionNode;
179
+ }
@@ -0,0 +1,3 @@
1
+ export declare function drawGraphicShape(appearance: any): any;
2
+ export declare function graphicLinearGradient(nr: number, nb: number, nl: number, nt: number, colors: []): any;
3
+ export declare function setSeriesRenderGroup(appearance: any, api: any): [];