Commit 02018692977f51f4f6ec7ef92f7575a02c200d67
Merge branch 'fix/chart-nest-not-render' into 'main_dev'
fix: 修复图表嵌套不渲染图表 See merge request yunteng/thingskit-scada!102
Showing
2 changed files
with
26 additions
and
7 deletions
@@ -228,7 +228,7 @@ AlarmListComponent.createAlarmItem = function (record) { | @@ -228,7 +228,7 @@ AlarmListComponent.createAlarmItem = function (record) { | ||
228 | } | 228 | } |
229 | 229 | ||
230 | return (record || []).map(item => { | 230 | return (record || []).map(item => { |
231 | - var { deviceName, status, startTs } = item || {} | 231 | + var { alias, deviceName, status, startTs } = item || {} |
232 | 232 | ||
233 | var stateStyle = { | 233 | var stateStyle = { |
234 | CLEARED_UNACK: 'color: #cf1322;background: #fff1f0;border-color: #ffa39e;', | 234 | CLEARED_UNACK: 'color: #cf1322;background: #fff1f0;border-color: #ffa39e;', |
@@ -248,7 +248,7 @@ AlarmListComponent.createAlarmItem = function (record) { | @@ -248,7 +248,7 @@ AlarmListComponent.createAlarmItem = function (record) { | ||
248 | <div class="alarm-list-item" style="height: ${itemHeight}px; box-sizing: border-box; display: flex; flex-direction: column; justify-content: center; border-bottom: 1px solid black; text-align: left; min-width: 280px; width: 100%;"> | 248 | <div class="alarm-list-item" style="height: ${itemHeight}px; box-sizing: border-box; display: flex; flex-direction: column; justify-content: center; border-bottom: 1px solid black; text-align: left; min-width: 280px; width: 100%;"> |
249 | <div style="padding: 0 10px;"> | 249 | <div style="padding: 0 10px;"> |
250 | <span style="margin-right: 5px;">设备:</span> | 250 | <span style="margin-right: 5px;">设备:</span> |
251 | - <span>${deviceName}</span> | 251 | + <span>${alias || deviceName}</span> |
252 | </div> | 252 | </div> |
253 | <div style="padding: 5px 10px;"> | 253 | <div style="padding: 5px 10px;"> |
254 | <span style="margin-right: 5px;">时间:</span> | 254 | <span style="margin-right: 5px;">时间:</span> |
@@ -352,7 +352,7 @@ | @@ -352,7 +352,7 @@ | ||
352 | */ | 352 | */ |
353 | Sidebar.prototype.initChartInstance = function (graph) { | 353 | Sidebar.prototype.initChartInstance = function (graph) { |
354 | const basicAttr = this.enumCellBasicAttribute | 354 | const basicAttr = this.enumCellBasicAttribute |
355 | - const allCell = graph.getDefaultParent().children || [] | 355 | + const allCell = Object.entries(graph?.getModel()?.cells || {}).map(([_, item]) => item) || [] |
356 | const domIdMapping = new Map() | 356 | const domIdMapping = new Map() |
357 | for (const cell of allCell) { | 357 | for (const cell of allCell) { |
358 | const chartInstanceId = graph.getAttributeForCell(cell, basicAttr.CHART_INSTANCE_ID) | 358 | const chartInstanceId = graph.getAttributeForCell(cell, basicAttr.CHART_INSTANCE_ID) |
@@ -363,6 +363,7 @@ | @@ -363,6 +363,7 @@ | ||
363 | domIdMapping.set(chartInstanceId, { width, height, chartType }) | 363 | domIdMapping.set(chartInstanceId, { width, height, chartType }) |
364 | } | 364 | } |
365 | } | 365 | } |
366 | + | ||
366 | const chartsDomList = document.querySelectorAll(`.${enumConst.CHART_CONTAINER_CLS}`) | 367 | const chartsDomList = document.querySelectorAll(`.${enumConst.CHART_CONTAINER_CLS}`) |
367 | for (const chartDom of chartsDomList) { | 368 | for (const chartDom of chartsDomList) { |
368 | const id = chartDom.getAttribute('id') | 369 | const id = chartDom.getAttribute('id') |
@@ -421,17 +422,26 @@ | @@ -421,17 +422,26 @@ | ||
421 | // } | 422 | // } |
422 | // } | 423 | // } |
423 | function getLineChartDefaultOption() { | 424 | function getLineChartDefaultOption() { |
425 | + var isLightBox = !!(urlParams || {})['lightbox'] | ||
424 | return { | 426 | return { |
427 | + title: isLightBox ? { | ||
428 | + text: '暂无数据', | ||
429 | + x: 'center', | ||
430 | + y: 'center', | ||
431 | + subtextStyle: { | ||
432 | + fontSize: 16 | ||
433 | + } | ||
434 | + } : {}, | ||
425 | xAxis: { | 435 | xAxis: { |
426 | type: 'category', | 436 | type: 'category', |
427 | - data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'], | 437 | + data: isLightBox ? [] : ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'], |
428 | }, | 438 | }, |
429 | yAxis: { | 439 | yAxis: { |
430 | type: 'value', | 440 | type: 'value', |
431 | }, | 441 | }, |
432 | series: [ | 442 | series: [ |
433 | { | 443 | { |
434 | - data: [150, 230, 224, 218, 135, 147, 260], | 444 | + data: isLightBox ? [] : [150, 230, 224, 218, 135, 147, 260], |
435 | type: 'line', | 445 | type: 'line', |
436 | }, | 446 | }, |
437 | ], | 447 | ], |
@@ -439,17 +449,26 @@ | @@ -439,17 +449,26 @@ | ||
439 | } | 449 | } |
440 | 450 | ||
441 | function getBarChartDefaultOption() { | 451 | function getBarChartDefaultOption() { |
452 | + var isLightBox = !!(urlParams || {})['lightbox'] | ||
442 | return { | 453 | return { |
454 | + title: isLightBox ? { | ||
455 | + text: '暂无数据', | ||
456 | + x: 'center', | ||
457 | + y: 'center', | ||
458 | + subtextStyle: { | ||
459 | + fontSize: 16 | ||
460 | + } | ||
461 | + } : {}, | ||
443 | xAxis: { | 462 | xAxis: { |
444 | type: 'category', | 463 | type: 'category', |
445 | - data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'], | 464 | + data: isLightBox ? [] : ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'], |
446 | }, | 465 | }, |
447 | yAxis: { | 466 | yAxis: { |
448 | type: 'value', | 467 | type: 'value', |
449 | }, | 468 | }, |
450 | series: [ | 469 | series: [ |
451 | { | 470 | { |
452 | - data: [120, 200, 150, 80, 70, 110, 130], | 471 | + data: isLightBox ? [] : [120, 200, 150, 80, 70, 110, 130], |
453 | type: 'bar', | 472 | type: 'bar', |
454 | showBackground: true, | 473 | showBackground: true, |
455 | backgroundStyle: { | 474 | backgroundStyle: { |