Commit ead733fad7efd69654d82bf9b3d937b32c160039

Authored by ww
1 parent c0db9d33

fix: 修复图表嵌套不渲染图表

... ... @@ -228,7 +228,7 @@ AlarmListComponent.createAlarmItem = function (record) {
228 228 }
229 229
230 230 return (record || []).map(item => {
231   - var { deviceName, status, startTs } = item || {}
  231 + var { alias, deviceName, status, startTs } = item || {}
232 232
233 233 var stateStyle = {
234 234 CLEARED_UNACK: 'color: #cf1322;background: #fff1f0;border-color: #ffa39e;',
... ... @@ -248,7 +248,7 @@ AlarmListComponent.createAlarmItem = function (record) {
248 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 249 <div style="padding: 0 10px;">
250 250 <span style="margin-right: 5px;">设备:</span>
251   - <span>${deviceName}</span>
  251 + <span>${alias || deviceName}</span>
252 252 </div>
253 253 <div style="padding: 5px 10px;">
254 254 <span style="margin-right: 5px;">时间:</span>
... ...
... ... @@ -352,7 +352,7 @@
352 352 */
353 353 Sidebar.prototype.initChartInstance = function (graph) {
354 354 const basicAttr = this.enumCellBasicAttribute
355   - const allCell = graph.getDefaultParent().children || []
  355 + const allCell = Object.entries(graph?.getModel()?.cells || {}).map(([_, item]) => item) || []
356 356 const domIdMapping = new Map()
357 357 for (const cell of allCell) {
358 358 const chartInstanceId = graph.getAttributeForCell(cell, basicAttr.CHART_INSTANCE_ID)
... ... @@ -363,6 +363,7 @@
363 363 domIdMapping.set(chartInstanceId, { width, height, chartType })
364 364 }
365 365 }
  366 +
366 367 const chartsDomList = document.querySelectorAll(`.${enumConst.CHART_CONTAINER_CLS}`)
367 368 for (const chartDom of chartsDomList) {
368 369 const id = chartDom.getAttribute('id')
... ... @@ -421,17 +422,26 @@
421 422 // }
422 423 // }
423 424 function getLineChartDefaultOption() {
  425 + var isLightBox = !!(urlParams || {})['lightbox']
424 426 return {
  427 + title: isLightBox ? {
  428 + text: '暂无数据',
  429 + x: 'center',
  430 + y: 'center',
  431 + subtextStyle: {
  432 + fontSize: 16
  433 + }
  434 + } : {},
425 435 xAxis: {
426 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 439 yAxis: {
430 440 type: 'value',
431 441 },
432 442 series: [
433 443 {
434   - data: [150, 230, 224, 218, 135, 147, 260],
  444 + data: isLightBox ? [] : [150, 230, 224, 218, 135, 147, 260],
435 445 type: 'line',
436 446 },
437 447 ],
... ... @@ -439,17 +449,26 @@
439 449 }
440 450
441 451 function getBarChartDefaultOption() {
  452 + var isLightBox = !!(urlParams || {})['lightbox']
442 453 return {
  454 + title: isLightBox ? {
  455 + text: '暂无数据',
  456 + x: 'center',
  457 + y: 'center',
  458 + subtextStyle: {
  459 + fontSize: 16
  460 + }
  461 + } : {},
443 462 xAxis: {
444 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 466 yAxis: {
448 467 type: 'value',
449 468 },
450 469 series: [
451 470 {
452   - data: [120, 200, 150, 80, 70, 110, 130],
  471 + data: isLightBox ? [] : [120, 200, 150, 80, 70, 110, 130],
453 472 type: 'bar',
454 473 showBackground: true,
455 474 backgroundStyle: {
... ...