dcim-topology2d 1.1.2 → 1.1.4
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/index.d.ts +2 -0
- package/chart-diagram/index.js +1 -0
- package/chart-diagram/src/echarts/index.d.ts +0 -1
- package/chart-diagram/src/echarts/index.js +106 -101
- package/chart-diagram/src/register.js +4 -3
- package/chart-diagram/src/utils/changeOptions.d.ts +4 -0
- package/chart-diagram/src/utils/changeOptions.js +163 -0
- package/chart-diagram/src/utils/conversion.d.ts +17 -0
- package/chart-diagram/src/utils/conversion.js +179 -0
- package/chart-diagram/src/utils/drawGraphic.d.ts +3 -0
- package/chart-diagram/src/utils/drawGraphic.js +97 -0
- package/chart-diagram/src/utils/index.d.ts +3 -0
- package/chart-diagram/src/utils/index.js +3 -0
- package/core/src/common.js +41 -35
- package/core/src/core.js +87 -58
- package/core/src/divLayer.d.ts +0 -26
- package/core/src/divLayer.js +22 -276
- package/core/src/healps/changeData.d.ts +1 -1
- package/core/src/healps/changeData.js +95 -57
- package/core/src/middles/arrows/index.d.ts +4 -0
- package/core/src/middles/arrows/index.js +5 -0
- package/core/src/middles/default.d.ts +1 -3
- package/core/src/middles/default.js +51 -51
- package/core/src/middles/index.js +3 -2
- package/core/src/middles/lines/index.d.ts +4 -0
- package/core/src/middles/lines/index.js +5 -0
- package/core/src/middles/nodes/iframe.d.ts +2 -0
- package/core/src/middles/nodes/iframe.js +12 -0
- package/core/src/middles/nodes/index.d.ts +46 -0
- package/core/src/middles/nodes/index.js +47 -0
- package/core/src/middles/nodes/pentagon.rect.js +1 -1
- package/core/src/middles/nodes/rectangle.rect.js +1 -1
- package/core/src/models/node.d.ts +6 -0
- package/core/src/models/node.js +17 -7
- package/core/src/models/pen.js +10 -1
- package/core/src/preview.js +30 -7
- package/core/src/renderLayer.js +1 -1
- package/core/src/store/data.js +2 -0
- package/core/src/utils/canvas.js +1 -1
- package/core/src/utils/dom.d.ts +2 -0
- package/core/src/utils/dom.js +66 -32
- package/core/src/utils/onmousevent.js +12 -3
- package/package.json +1 -1
- package/static/echartsDefaultData.js +239 -0
- package/static/echartsStore.js +14 -0
- package/static/index.js +2 -0
- package/style/index.css +13 -0
package/core/src/divLayer.js
CHANGED
@@ -20,42 +20,25 @@ var __extends = (this && this.__extends) || (function () {
|
|
20
20
|
};
|
21
21
|
})();
|
22
22
|
import {Store} from 'le5le-store';
|
23
|
-
import {Node, images} from './models
|
24
|
-
import {Lock} from './models/status';
|
25
|
-
import {PenType} from './models/pen';
|
23
|
+
import {Node, PenType, images, defaultImages} from './models';
|
26
24
|
import {Layer} from './layer';
|
27
|
-
import { setStyleForElementIdDiv, DomElements } from './utils'
|
28
|
-
import { commonStore } from './store'
|
25
|
+
import { setStyleForElementIdDiv, createIframeElement, DomElements, DomIframes } from './utils';
|
26
|
+
import { commonStore } from './store';
|
29
27
|
var DivLayer = /** @class */ (function (_super) {
|
30
28
|
__extends(DivLayer, _super);
|
31
|
-
|
32
29
|
function DivLayer(TID) {
|
33
30
|
var _this = _super.call(this, TID) || this;
|
34
31
|
_this.canvas = document.createElement('div');
|
35
|
-
// _this.player = document.createElement('div');
|
36
|
-
// _this.videos = {};
|
37
|
-
// _this.audios = {};
|
38
32
|
_this.iframes = {};
|
39
33
|
_this.elements = {};
|
40
34
|
_this.gifs = {};
|
41
35
|
_this.addDiv = function (node) {
|
42
|
-
// if (node.audio) {
|
43
|
-
// if (_this.audios[node.id] && _this.audios[node.id].media.src !== node.audio) {
|
44
|
-
// _this.audios[node.id].media.src = node.audio;
|
45
|
-
// }
|
46
|
-
// _this.setElemPosition(node, (_this.audios[node.id] && _this.audios[node.id].player) || _this.addMedia(node, 'audio'));
|
47
|
-
// }
|
48
|
-
// if (node.video) {
|
49
|
-
// if (_this.videos[node.id] && _this.videos[node.id].media.src !== node.video) {
|
50
|
-
// _this.videos[node.id].media.src = node.video;
|
51
|
-
// }
|
52
|
-
// _this.setElemPosition(node, (_this.videos[node.id] && _this.videos[node.id].player) || _this.addMedia(node, 'video'));
|
53
|
-
// }
|
54
36
|
if (node.iframe) {
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
37
|
+
Object.assign(_this.iframes, DomIframes);
|
38
|
+
if (_this.iframes[node.id] && _this.iframes[node.id].src !== node.iframe) {
|
39
|
+
_this.iframes[node.id].src = node.iframe;
|
40
|
+
}
|
41
|
+
_this.setElemPosition(node, _this.iframes[node.id] || _this.addIframe(node));
|
59
42
|
}
|
60
43
|
if (node.elementId) {
|
61
44
|
Object.assign(_this.elements, DomElements);
|
@@ -91,18 +74,6 @@ var DivLayer = /** @class */ (function (_super) {
|
|
91
74
|
}
|
92
75
|
}
|
93
76
|
};
|
94
|
-
// if (!_this.options.playIcon) {
|
95
|
-
// _this.options.playIcon = 'iconfont icon-play';
|
96
|
-
// }
|
97
|
-
// if (!_this.options.pauseIcon) {
|
98
|
-
// _this.options.pauseIcon = 'iconfont icon-pause';
|
99
|
-
// }
|
100
|
-
// if (!_this.options.fullScreenIcon) {
|
101
|
-
// _this.options.fullScreenIcon = 'iconfont icon-full-screen';
|
102
|
-
// }
|
103
|
-
// if (!_this.options.loopIcon) {
|
104
|
-
// _this.options.loopIcon = 'iconfont icon-loop';
|
105
|
-
// }
|
106
77
|
_this.canvas.style.position = 'absolute';
|
107
78
|
_this.canvas.style.left = '0';
|
108
79
|
_this.canvas.style.top = '0';
|
@@ -110,230 +81,13 @@ var DivLayer = /** @class */ (function (_super) {
|
|
110
81
|
_this.canvas.style.background = 'transparent';
|
111
82
|
_this.canvas.setAttribute('class', 'canvas-point');
|
112
83
|
commonStore[TID].parentElem.appendChild(_this.canvas);
|
113
|
-
// parentElem.appendChild(_this.player);
|
114
|
-
//_this.createPlayer();
|
115
84
|
_this.subcribe = Store.subscribe(_this.generateStoreKey('LT:addDiv'), _this.addDiv);
|
116
|
-
// _this.subcribeNode = Store.subscribe(_this.generateStoreKey('LT:activeNode'), function (node) {
|
117
|
-
// if (!node || (!node.video && !node.audio)) {
|
118
|
-
// _this.player.style.top = '-99999px';
|
119
|
-
// return;
|
120
|
-
// }
|
121
|
-
// if (node.audio && _this.audios[node.id]) {
|
122
|
-
// _this.media = _this.audios[node.id].media;
|
123
|
-
// }
|
124
|
-
// else if (node.video && _this.videos[node.id]) {
|
125
|
-
// _this.media = _this.videos[node.id].media;
|
126
|
-
// }
|
127
|
-
// else {
|
128
|
-
// return;
|
129
|
-
// }
|
130
|
-
// _this.curNode = node;
|
131
|
-
// _this.player.style.top = _this.parentElem.offsetTop + _this.parentElem.clientHeight + 'px';
|
132
|
-
// _this.player.style.left = _this.parentElem.getBoundingClientRect().left + 'px';
|
133
|
-
// _this.player.style.width = _this.parentElem.clientWidth + 'px';
|
134
|
-
// _this.getMediaCurrent();
|
135
|
-
// if (_this.media.paused) {
|
136
|
-
// _this.playBtn.className = _this.options.playIcon;
|
137
|
-
// }
|
138
|
-
// else {
|
139
|
-
// _this.playBtn.className = _this.options.pauseIcon;
|
140
|
-
// }
|
141
|
-
// });
|
142
|
-
// document.addEventListener('fullscreenchange', function (e) {
|
143
|
-
// if (!_this.media) {
|
144
|
-
// return;
|
145
|
-
// }
|
146
|
-
// if (document.fullscreen) {
|
147
|
-
// _this.media.controls = true;
|
148
|
-
// _this.media.style.userSelect = 'initial';
|
149
|
-
// _this.media.style.pointerEvents = 'initial';
|
150
|
-
// }
|
151
|
-
// else {
|
152
|
-
// _this.media.style.userSelect = 'none';
|
153
|
-
// _this.media.style.pointerEvents = 'none';
|
154
|
-
// _this.media.controls = false;
|
155
|
-
// }
|
156
|
-
// });
|
157
85
|
return _this;
|
158
86
|
}
|
159
|
-
|
160
|
-
DivLayer.prototype.createPlayer = function () {
|
161
|
-
var _this = this;
|
162
|
-
let options = commonStore[_this.TID].options;
|
163
|
-
this.player.style.position = 'fixed';
|
164
|
-
this.player.style.outline = 'none';
|
165
|
-
this.player.style.top = '-99999px';
|
166
|
-
this.player.style.height = '40px';
|
167
|
-
this.player.style.padding = '10px 15px';
|
168
|
-
this.player.style.background = 'rgba(200,200,200,.1)';
|
169
|
-
this.player.style.display = 'flex';
|
170
|
-
this.player.style.alignItems = 'center';
|
171
|
-
this.player.style.userSelect = 'initial';
|
172
|
-
this.player.style.pointerEvents = 'initial';
|
173
|
-
this.player.style.zIndex = '1';
|
174
|
-
this.playBtn = document.createElement('i');
|
175
|
-
this.currentTime = document.createElement('span');
|
176
|
-
this.progress = document.createElement('div');
|
177
|
-
this.progressCurrent = document.createElement('div');
|
178
|
-
this.loop = document.createElement('i');
|
179
|
-
var fullScreen = document.createElement('i');
|
180
|
-
this.playBtn.className = options.playIcon;
|
181
|
-
this.playBtn.style.fontSize = '18px';
|
182
|
-
this.playBtn.style.lineHeight = '20px';
|
183
|
-
this.playBtn.style.cursor = 'pointer';
|
184
|
-
this.currentTime.style.padding = '0 10px';
|
185
|
-
this.currentTime.innerText = '0 / 0';
|
186
|
-
this.progress.style.position = 'relative';
|
187
|
-
this.progress.style.flexGrow = '1';
|
188
|
-
this.progress.style.top = '0';
|
189
|
-
this.progress.style.height = '4px';
|
190
|
-
this.progress.style.background = '#ccc';
|
191
|
-
this.progress.style.borderRadius = '2px';
|
192
|
-
this.progress.style.overflow = 'hidden';
|
193
|
-
this.progress.style.cursor = 'pointer';
|
194
|
-
this.progressCurrent.style.position = 'absolute';
|
195
|
-
this.progressCurrent.style.left = '0';
|
196
|
-
this.progressCurrent.style.top = '0';
|
197
|
-
this.progressCurrent.style.bottom = '0';
|
198
|
-
this.progressCurrent.style.width = '0';
|
199
|
-
this.progressCurrent.style.background = '#52c41a';
|
200
|
-
this.loop.style.margin = '0 10px';
|
201
|
-
this.loop.style.padding = '2px 5px';
|
202
|
-
this.loop.style.borderRadius = '2px';
|
203
|
-
this.loop.className = options.loopIcon;
|
204
|
-
this.loop.style.fontSize = '18px';
|
205
|
-
this.loop.style.lineHeight = '20px';
|
206
|
-
this.loop.style.cursor = 'pointer';
|
207
|
-
fullScreen.className = options.fullScreenIcon;
|
208
|
-
fullScreen.style.fontSize = '17px';
|
209
|
-
fullScreen.style.lineHeight = '20px';
|
210
|
-
fullScreen.style.cursor = 'pointer';
|
211
|
-
this.player.appendChild(this.playBtn);
|
212
|
-
this.player.appendChild(this.currentTime);
|
213
|
-
this.player.appendChild(this.progress);
|
214
|
-
this.progress.appendChild(this.progressCurrent);
|
215
|
-
this.player.appendChild(this.loop);
|
216
|
-
this.player.appendChild(fullScreen);
|
217
|
-
this.playBtn.onclick = function () {
|
218
|
-
if (_this.media.paused) {
|
219
|
-
_this.media.play();
|
220
|
-
_this.playBtn.className = options.pauseIcon;
|
221
|
-
} else {
|
222
|
-
_this.media.pause();
|
223
|
-
_this.playBtn.className = options.playIcon;
|
224
|
-
}
|
225
|
-
};
|
226
|
-
this.progress.onclick = function (e) {
|
227
|
-
_this.media.currentTime = (e.offsetX / _this.progress.clientWidth) * _this.media.duration;
|
228
|
-
};
|
229
|
-
this.loop.onclick = function () {
|
230
|
-
_this.media.loop = !_this.media.loop;
|
231
|
-
_this.curNode.playLoop = _this.media.loop;
|
232
|
-
if (_this.media.loop) {
|
233
|
-
_this.loop.style.background = '#ddd';
|
234
|
-
} else {
|
235
|
-
_this.loop.style.background = 'none';
|
236
|
-
}
|
237
|
-
};
|
238
|
-
fullScreen.onclick = function () {
|
239
|
-
_this.media.requestFullscreen();
|
240
|
-
};
|
241
|
-
options = null;
|
242
|
-
};
|
243
|
-
DivLayer.prototype.getMediaCurrent = function () {
|
244
|
-
if (!this.media) {
|
245
|
-
return;
|
246
|
-
}
|
247
|
-
this.currentTime.innerText =
|
248
|
-
this.formatSeconds(this.media.currentTime) + ' / ' + this.formatSeconds(this.media.duration);
|
249
|
-
this.progressCurrent.style.width =
|
250
|
-
(this.media.currentTime / this.media.duration) * this.progress.clientWidth + 'px';
|
251
|
-
};
|
252
|
-
DivLayer.prototype.addMedia = function (node, type) {
|
253
|
-
var _this = this;
|
254
|
-
var player = document.createElement('div');
|
255
|
-
var current = document.createElement('div');
|
256
|
-
var media = document.createElement(type);
|
257
|
-
current.style.position = 'absolute';
|
258
|
-
current.style.outline = 'none';
|
259
|
-
current.style.left = '0';
|
260
|
-
current.style.bottom = '0';
|
261
|
-
current.style.height = '2px';
|
262
|
-
current.style.background = '#52c41a';
|
263
|
-
media.style.position = 'absolute';
|
264
|
-
media.style.outline = 'none';
|
265
|
-
media.style.left = '0';
|
266
|
-
media.style.right = '0';
|
267
|
-
media.style.top = '0';
|
268
|
-
media.style.bottom = '0';
|
269
|
-
if (type === 'video') {
|
270
|
-
media.style.width = node.rect.width + 'px';
|
271
|
-
media.style.height = node.rect.height + 'px';
|
272
|
-
}
|
273
|
-
player.style.background = 'transparent';
|
274
|
-
if (node.play === 1) {
|
275
|
-
media.autoplay = true;
|
276
|
-
}
|
277
|
-
media.loop = node.playLoop;
|
278
|
-
media.ontimeupdate = function () {
|
279
|
-
current.style.width = (media.currentTime / media.duration) * node.rect.width + 'px';
|
280
|
-
_this.getMediaCurrent();
|
281
|
-
if (_this.media === media) {
|
282
|
-
if (node.playLoop) {
|
283
|
-
media.loop = true;
|
284
|
-
_this.loop.style.background = '#ddd';
|
285
|
-
} else {
|
286
|
-
media.loop = false;
|
287
|
-
_this.loop.style.background = 'none';
|
288
|
-
}
|
289
|
-
}
|
290
|
-
};
|
291
|
-
media.onended = function () {
|
292
|
-
Store.set(_this.generateStoreKey('mediaEnd'), node);
|
293
|
-
if (_this.media === media) {
|
294
|
-
_this.playBtn.className = commonStore[_this.TID].options.playIcon;
|
295
|
-
}
|
296
|
-
_this.playNext(node.nextPlay);
|
297
|
-
};
|
298
|
-
media.onloadedmetadata = function () {
|
299
|
-
_this.getMediaCurrent();
|
300
|
-
};
|
301
|
-
media.src = node[type];
|
302
|
-
player.appendChild(media);
|
303
|
-
player.appendChild(current);
|
304
|
-
this[type + 's'][node.id] = {
|
305
|
-
player: player,
|
306
|
-
current: current,
|
307
|
-
media: media
|
308
|
-
};
|
309
|
-
this.canvas.appendChild(player);
|
310
|
-
return player;
|
311
|
-
};
|
312
|
-
DivLayer.prototype.playNext = function (next) {
|
313
|
-
if (!next) {
|
314
|
-
return;
|
315
|
-
}
|
316
|
-
for (var _i = 0, _a = commonStore[this.TID].data.pens; _i < _a.length; _i++) {
|
317
|
-
var item = _a[_i];
|
318
|
-
if (!(item instanceof Node)) {
|
319
|
-
continue;
|
320
|
-
}
|
321
|
-
if (item.tags.indexOf(next) > -1) {
|
322
|
-
if (item.audio && this.audios[item.id] && this.audios[item.id].media && this.audios[item.id].media.paused) {
|
323
|
-
this.audios[item.id].media.play();
|
324
|
-
} else if (item.video && this.videos[item.id].media && this.videos[item.id].media.paused) {
|
325
|
-
this.videos[item.id].media.play();
|
326
|
-
}
|
327
|
-
}
|
328
|
-
}
|
329
|
-
};
|
330
87
|
DivLayer.prototype.addIframe = function (node) {
|
331
|
-
|
332
|
-
iframe.scrolling = 'no';
|
333
|
-
iframe.frameBorder = '0';
|
334
|
-
iframe.src = node.iframe;
|
88
|
+
const iframe = createIframeElement(node);
|
335
89
|
this.iframes[node.id] = iframe;
|
336
|
-
|
90
|
+
commonStore[node.TID].parentElem.appendChild(iframe);
|
337
91
|
return iframe;
|
338
92
|
};
|
339
93
|
DivLayer.prototype.addGif = function (node) {
|
@@ -347,25 +101,16 @@ var DivLayer = /** @class */ (function (_super) {
|
|
347
101
|
DivLayer.prototype.removeDiv = function (item) {
|
348
102
|
if (this.curNode && item.id === this.curNode.id) {
|
349
103
|
this.curNode = null;
|
350
|
-
// this.media = null;
|
351
|
-
// this.player.style.top = '-99999px';
|
352
104
|
}
|
353
|
-
// if (item.audio) {
|
354
|
-
// this.canvas.removeChild(this.audios[item.id].player);
|
355
|
-
// this.audios[item.id] = null;
|
356
|
-
// }
|
357
|
-
// if (item.video) {
|
358
|
-
// this.canvas.removeChild(this.videos[item.id].player);
|
359
|
-
// this.videos[item.id] = null;
|
360
|
-
// }
|
361
105
|
if (item.iframe) {
|
362
|
-
|
363
|
-
|
106
|
+
const iframesNode = this.iframes[item.id] || DomIframes[item.id];
|
107
|
+
commonStore[item.TID].parentElem.removeChild(iframesNode);
|
108
|
+
this.iframes[item.id] ? this.iframes[item.id] = null : DomIframes[item.id] = null;
|
364
109
|
}
|
365
110
|
if (item.elementId) {
|
366
111
|
const elementNode = this.elements[item.id] || DomElements[item.id];
|
367
112
|
this.canvas.removeChild(elementNode);
|
368
|
-
this.elements[item.id] = null;
|
113
|
+
this.elements[item.id] ? this.elements[item.id] = null : DomElements[item.id] = null;
|
369
114
|
}
|
370
115
|
if (item.gif) {
|
371
116
|
this.canvas.removeChild(this.gifs[item.id]);
|
@@ -383,19 +128,22 @@ var DivLayer = /** @class */ (function (_super) {
|
|
383
128
|
};
|
384
129
|
DivLayer.prototype.clear = function () {
|
385
130
|
this.canvas.innerHTML = '';
|
386
|
-
//this.audios = {};
|
387
|
-
//this.videos = {};
|
388
131
|
this.iframes = {};
|
389
132
|
this.elements = {};
|
390
133
|
this.gifs = {};
|
391
|
-
for (
|
134
|
+
for (let key in DomIframes) {
|
135
|
+
delete DomIframes[key];
|
136
|
+
}
|
137
|
+
for (let key in DomElements) {
|
392
138
|
delete DomElements[key];
|
393
139
|
}
|
394
140
|
// tslint:disable-next-line:forin
|
395
|
-
for (
|
141
|
+
for (let key in images) {
|
396
142
|
delete images[key];
|
397
143
|
}
|
398
|
-
|
144
|
+
for (let key in defaultImages) {
|
145
|
+
delete defaultImages[key];
|
146
|
+
}
|
399
147
|
};
|
400
148
|
DivLayer.prototype.formatSeconds = function (seconds) {
|
401
149
|
var h = Math.floor(seconds / 3600);
|
@@ -447,8 +195,6 @@ var DivLayer = /** @class */ (function (_super) {
|
|
447
195
|
DivLayer.prototype.destroy = function () {
|
448
196
|
this.clear();
|
449
197
|
this.subcribe.unsubscribe();
|
450
|
-
//this.subcribeNode.unsubscribe();
|
451
|
-
|
452
198
|
//优化
|
453
199
|
this.canvas.onmousemove = null;
|
454
200
|
this.canvas.onmousedown = null
|
@@ -5,4 +5,4 @@ export declare function setNodeEvents(item: any[], pen: Pen): void;
|
|
5
5
|
export declare function setControlData(pen: Pen, syncData: Node): void;
|
6
6
|
export declare function getControlNode(item: any, data: any): Node;
|
7
7
|
export declare function getDetailData(data: Node): void;
|
8
|
-
export declare function setStatisticalData(pen: Pen, staticForType: string, chartData: any): Node;
|
8
|
+
export declare function setStatisticalData(pen: Pen, dataType: any, staticForType: string, chartData: any): Node;
|
@@ -1,6 +1,9 @@
|
|
1
1
|
//let DETAILDATA = null;
|
2
|
+
import { echartsDefaultDataMap } from '../../../static';
|
3
|
+
import { commonStore } from '../store'
|
2
4
|
export function setConfItemNode(pen, syn_synata) {
|
3
5
|
if (!pen.data) return
|
6
|
+
commonStore[pen.TID].data.dataResize = 1;
|
4
7
|
if(pen.data instanceof Array) {
|
5
8
|
let _syn = ''
|
6
9
|
let isResetVal = false
|
@@ -78,7 +81,6 @@ export function setConfItemNode(pen, syn_synata) {
|
|
78
81
|
color = '#D38C00';
|
79
82
|
break;
|
80
83
|
}
|
81
|
-
|
82
84
|
// 显示的属性
|
83
85
|
if (name === 'text') {
|
84
86
|
pen.font.color = color
|
@@ -88,77 +90,113 @@ export function setConfItemNode(pen, syn_synata) {
|
|
88
90
|
}else {
|
89
91
|
pen.fillStyle = color
|
90
92
|
}
|
91
|
-
|
92
93
|
if (name === 'electricFan') setFanData(pen, _syn)
|
93
94
|
}else {
|
94
95
|
if (pen.elementRendered) pen.elementRendered = false;
|
95
|
-
if(pen.data.
|
96
|
+
if(pen.data.echarts) {
|
96
97
|
const { echartDataValue } = syn_synata;
|
97
|
-
//const seriesData = pen.data.echarts.option.series.length > 1 ? echartDataValue : echartData
|
98
98
|
const seriesData = echartDataValue;
|
99
|
-
const chartData = seriesData && Object.keys(seriesData).length && seriesData[pen.data.params.id];
|
100
|
-
const staticForType = pen.data.params
|
101
|
-
|
102
|
-
// 无效配置
|
103
|
-
}else {
|
104
|
-
pen.data.echarts = setStatisticalData(pen, staticForType, chartData);
|
105
|
-
}
|
99
|
+
const chartData = pen.data.params && seriesData && Object.keys(seriesData).length && seriesData[pen.data.params.id];
|
100
|
+
const staticForType = pen.data.params && pen.data.params.staticForType || '';//统计类型:日,周,月,年
|
101
|
+
pen.data.echarts.option = setStatisticalData(pen, null, staticForType, chartData);
|
106
102
|
}
|
107
103
|
}
|
108
104
|
return pen
|
109
105
|
}
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
106
|
+
|
107
|
+
/**
|
108
|
+
* 设置图表数据
|
109
|
+
* @param pen 拓扑节点
|
110
|
+
* @param dataType 数据类型:‘def’-默认,不传默认为-实时
|
111
|
+
* @param staticForType 统计类型:日,周,月,年
|
112
|
+
* @param chartData // 图表实时数据
|
113
|
+
* @returns {*}
|
114
|
+
*/
|
115
|
+
export function setStatisticalData(pen, dataType, staticForType, chartData) {
|
116
|
+
const node = JSON.parse(JSON.stringify(pen));
|
117
|
+
const echartsOption = node.data.echarts.option;
|
118
|
+
const optionDisplayMode = echartsOption.displayMode;
|
119
|
+
let displayMode = 0;
|
120
|
+
if(typeof optionDisplayMode === 'string') {
|
121
|
+
|
122
|
+
const displayType = optionDisplayMode.split('_')[0];
|
123
|
+
|
124
|
+
displayMode = parseInt(displayType);
|
125
|
+
|
126
|
+
}else {
|
127
|
+
displayMode = parseInt(optionDisplayMode);
|
128
|
+
}
|
129
|
+
const defaultData = echartsDefaultDataMap[`displayMode_${optionDisplayMode}`];
|
130
|
+
const staticTypeData = chartData && chartData[`${staticForType}_Data`];
|
131
|
+
const chartRealData = staticForType ? staticTypeData || defaultData : chartData || defaultData;
|
114
132
|
if (displayMode === 1 || displayMode === 2){ // 折线图,柱状图
|
115
133
|
//const xData = [], seriesData = [];
|
116
|
-
|
134
|
+
dataType = staticForType && staticTypeData || chartData && chartData.seriesData.length ? '' : 'def';
|
135
|
+
const seriesNodes = echartsOption.series;
|
136
|
+
const isBaseLineBar = ['line', 'bar'].includes(node.appearance.type);
|
117
137
|
// 双轴曲线
|
118
|
-
if(seriesNodes.length > 1 || node.data.params.curveNum > 1){
|
138
|
+
if(seriesNodes.length > 1 || node.data.params && node.data.params.curveNum > 1){
|
119
139
|
const legendData = [];
|
120
|
-
|
121
|
-
|
122
|
-
let
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
140
|
+
let legendChange = false;
|
141
|
+
echartsOption.xAxis[0].data = chartRealData.XData;
|
142
|
+
let order = 0;
|
143
|
+
//循环给每条统计数据赋值
|
144
|
+
seriesNodes.map((item, index) => {
|
145
|
+
let seriesItem = null;
|
146
|
+
// 执行类型为恢复默认
|
147
|
+
if(dataType === 'def') {
|
148
|
+
let defaultSeriesItem = defaultData.seriesData[order];
|
149
|
+
if(!defaultSeriesItem) defaultSeriesItem = defaultData.seriesData[0]; // 默认数据只有一个时,只取第一个
|
150
|
+
seriesItem = JSON.parse(JSON.stringify(defaultSeriesItem));
|
151
|
+
if(['line', 'bar'].includes(item.type)) order++; // 此判断为过滤series中的图表柱子或折线节点样式
|
152
|
+
if(!isBaseLineBar) return item.data = seriesItem.data; // 曲线或柱状图模板一般会走这个逻辑
|
153
|
+
if(!index) {
|
154
|
+
seriesItem.name = '标注1';
|
155
|
+
item.data = seriesItem.data;
|
156
|
+
}else {
|
157
|
+
// 自动生成series数据计算
|
158
|
+
for(let i = 0, sdl = seriesItem.data.length; i < sdl; i++){
|
159
|
+
displayMode === 1 ? seriesItem.data[i] -= 400 : seriesItem.data[i] += 100;
|
160
|
+
}
|
161
|
+
seriesItem.name = `标注${index + 1}`;
|
162
|
+
item.data = seriesItem.data;
|
163
|
+
}
|
164
|
+
}else {
|
165
|
+
// 执行类型为实时数据
|
166
|
+
seriesItem = chartRealData.seriesData[index];
|
167
|
+
if(!seriesItem) return item.data = [];
|
168
|
+
item.data = seriesItem.data;
|
169
|
+
}
|
170
|
+
// 获取角标数据
|
171
|
+
if(seriesItem.name) {
|
172
|
+
item.name = seriesItem.name;
|
173
|
+
legendData.push(seriesItem.name);
|
174
|
+
legendChange = true;
|
175
|
+
}
|
176
|
+
});
|
177
|
+
if(echartsOption.legend && legendChange) echartsOption.legend.data = legendData; // 为角标数据赋值
|
136
178
|
}else {
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
179
|
+
// 单曲线或柱状的执行逻辑
|
180
|
+
echartsOption.xAxis[0].data = chartRealData.XData;
|
181
|
+
const { name, data } = chartRealData.seriesData[0];
|
182
|
+
if(name) seriesNodes[0].name = name;
|
183
|
+
seriesNodes[0].data = data;
|
141
184
|
}
|
142
185
|
}
|
143
|
-
if(displayMode === 4) { //
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
node
|
149
|
-
|
150
|
-
|
151
|
-
for (let sd = 0; sd < chartOptions.seriesData.length; sd++) {
|
152
|
-
barData.push(100);
|
153
|
-
}
|
154
|
-
node.data.echarts.option.series[1].data = barData;
|
186
|
+
if(displayMode === 4) { // top排行榜
|
187
|
+
echartsOption.yAxis[0].data = chartRealData.XData;
|
188
|
+
const { data } = chartRealData.seriesData[0];
|
189
|
+
echartsOption.yAxis[1].data = data;
|
190
|
+
for (let i = 0; i < echartsOption.series.length; i++) {
|
191
|
+
const node = echartsOption.series[i];
|
192
|
+
node.symbolBoundingData = chartRealData.total;
|
193
|
+
node.data = data;
|
155
194
|
}
|
156
195
|
}
|
157
|
-
if (displayMode === 5){ //
|
158
|
-
const colors =
|
159
|
-
const pieData = staticForType ? chartData : chartData.data;
|
196
|
+
if (displayMode === 5 || displayMode === 3){ // 饼图/环形图
|
197
|
+
const colors = echartsOption.color;
|
198
|
+
const pieData = staticForType ? chartData || defaultData : chartData && chartData.data || defaultData.seriesData;
|
160
199
|
const seriesData = [];
|
161
|
-
if(!pieData) return;
|
162
200
|
pieData.map((chd, index) => {
|
163
201
|
seriesData.push({
|
164
202
|
itemStyle: { color: colors[index] },
|
@@ -166,15 +204,15 @@ export function setStatisticalData(pen, staticForType, chartData) {
|
|
166
204
|
value: chd.value
|
167
205
|
})
|
168
206
|
})
|
169
|
-
|
207
|
+
echartsOption.series[0].data = seriesData;
|
170
208
|
}
|
171
|
-
if(displayMode === 6
|
209
|
+
if(displayMode === 6){ // 仪表盘
|
172
210
|
// 仪表盘分两种,分别有不同的取值方式,下面两行先注释掉
|
173
211
|
// node.appearance.title.text = chartData.name;
|
174
212
|
// node.data.echarts.option.title.text = chartData.name;
|
175
|
-
|
213
|
+
echartsOption.series[0].data[0].value = chartData && chartData.value || defaultData.value;
|
176
214
|
}
|
177
|
-
return
|
215
|
+
return echartsOption;
|
178
216
|
}
|
179
217
|
export function setNodeEvents(item, pen) {
|
180
218
|
|
@@ -1,6 +1,4 @@
|
|
1
|
-
import { Point } from '../models';
|
2
|
-
import { Node } from '../models';
|
3
|
-
import { Line } from '../models';
|
1
|
+
import { Point, Node, Line } from '../models';
|
4
2
|
export declare const drawNodeFns: any;
|
5
3
|
export declare const iconRectFns: any;
|
6
4
|
export declare const textRectFns: any;
|