Browse Source

fix:图表文字修改,增加单位

master
白凤吉 2 weeks ago
parent
commit
a8b5ea21ff
  1. 31
      src/components/home/LineChart.vue

31
src/components/home/LineChart.vue

@ -29,9 +29,34 @@ watch(
},
tooltip: {
trigger: 'axis',
formatter: (params: any[]) => {
if (!params || !params.length)
return ''
// 1.
const time = params[0].axisValue
let html = `<div>${time}</div>`
// 2. marker线 + + +
params.forEach((item) => {
let unit = ''
switch (item.seriesName) {
case '温度': unit = ' ℃'
break
case '相对湿度': unit = ' %RH'
break
case 'H2O2浓度': unit = ' ppm'
break
case 'H2O2相对饱和度': unit = ' %RS'
break
}
// item.marker echarts
html += `<div>${item.marker} ${item.seriesName}: ${item.data}${unit}</div>`
})
return html
},
},
legend: {
data: ['温度', '湿度', 'H2O2浓度', 'H2O2饱和度'],
data: ['温度', '相对湿度', 'H2O2浓度', 'H2O2相对饱和度'],
orient: 'horizontal', //
itemWidth: 10, //
itemHeight: 10, //
@ -60,7 +85,7 @@ watch(
},
},
{
name: '湿度',
name: '相对湿度',
type: 'line',
data: newValue.data?.map(item => item.rh.toFixed(2)),
symbol: 'circle',
@ -82,7 +107,7 @@ watch(
},
},
{
name: 'H2O2饱和度',
name: 'H2O2相对饱和度',
type: 'line',
data: newValue.data?.map(item => item.rs.toFixed(2)),
symbol: 'circle',

Loading…
Cancel
Save