fix: NEZ-3387 dashboard 图表数据导出 csv 失败

This commit is contained in:
zhangyu
2024-01-19 10:51:39 +08:00
parent 8206c79fc5
commit ee040e6933

View File

@@ -546,8 +546,9 @@ export default {
const data = this.series const data = this.series
let csv = '"time","legend","value"\n' let csv = '"time","legend","value"\n'
data.forEach((item, index) => { data.forEach((item, index) => {
item.data.forEach(value => { if (this.seriesData[index + 1]) {
let val = formatScientificNotation(value[1], this.$lodash.get(chartInfo, 'param.decimals', 2)) this.seriesData[index].forEach((value, timeIndex) => {
let val = formatScientificNotation(value, this.$lodash.get(chartInfo, 'param.decimals', 2))
let unit = '' let unit = ''
if (item.yAxisIndex) { if (item.yAxisIndex) {
unit = chartDataFormat.getUnit(this.$lodash.get(chartInfo, 'param.rightYAxis.unit', 2)) unit = chartDataFormat.getUnit(this.$lodash.get(chartInfo, 'param.rightYAxis.unit', 2))
@@ -562,8 +563,9 @@ export default {
} catch (e) { } catch (e) {
console.log(e) console.log(e)
} }
csv += `"${this.momentTz(value[0] * 1000)}","${legend}","${val}"\n` csv += `"${this.momentTz(this.seriesData[0][timeIndex] * 1000)}","${legend}","${val}"\n`
}) })
}
}) })
return csv return csv
}, },
@@ -583,7 +585,7 @@ export default {
break break
case 'bar' : case 'bar' :
legend = 'alias' legend = 'alias'
keyByData = 'series[0].data' keyByData = 'barData'
break break
case 'pie' : case 'pie' :
legend = 'alias' legend = 'alias'
@@ -627,7 +629,7 @@ export default {
} }
this.$lodash.get(this, keyByData, []).forEach(item => { this.$lodash.get(this, keyByData, []).forEach(item => {
let val = item.showValue let val = item.showValue
let legends = this.yasuo(item[legend]) let legends = this.yasuo(item[legend] || item.alias)
try { try {
val = val.trim() val = val.trim()
legends = legends.trim() legends = legends.trim()