diff --git a/src/components/cockpit/transientDistribution/index.vue b/src/components/cockpit/transientDistribution/index.vue index 6b49714..61e0efe 100644 --- a/src/components/cockpit/transientDistribution/index.vue +++ b/src/components/cockpit/transientDistribution/index.vue @@ -217,29 +217,37 @@ const tableStore: any = new TableStore({ const xlist = tableStore.table.data.xlist || [] // 处理趋势图数据 - const seriesData = [ - { - name: '电压中断', - type: 'line', - showSymbol: false, - color: '#FF9100', - data: trendList[0]?.map((value: number, index: number) => [xlist[index], value]) || [] - }, - { - name: '电压暂降', - type: 'line', - showSymbol: false, - color: '#FFBF00', - data: trendList[1]?.map((value: number, index: number) => [xlist[index], value]) || [] - }, - { - name: '电压暂升', - type: 'line', - showSymbol: false, - color: config.layout.elementUiPrimary[0], - data: trendList[2]?.map((value: number, index: number) => [xlist[index], value]) || [] + const seriesData = trendList.map((item: any) => { + // 根据接口返回的name字段确定系列名称和颜色 + let name = '' + let color = '' + + switch (item.name) { + case 'Evt_Sys_DipStr': + name = '电压暂降' + color = '#FFBF00' + break + case 'Evt_Sys_IntrStr': + name = '电压中断' + color = '#FF9100' + break + case 'Evt_Sys_SwlStr': + name = '电压暂升' + color = config.layout.elementUiPrimary[0] + break + default: + name = item.name + color = '#000000' } - ] + + return { + name: name, + type: 'line', + showSymbol: false, + color: color, + data: item.trendList?.map((value: number, index: number) => [xlist[index], value]) || [] + } + }) // 获取x轴和y轴的标签值 const xLabels = [ @@ -272,9 +280,7 @@ const tableStore: any = new TableStore({ backgroundColor: 'rgba(0,0,0,0.55)', borderWidth: 0, formatter: function (params: any) { - console.log(params, '99000') var tips = '' - tips += '持续时间: ' + yLabels[params.value[1]] + '
' tips += '特征幅值: ' + xLabels[params.value[0]] + '
' tips += '事件次数: ' + params.value[2] + '
'