diff --git a/src/components/cockpit/exceedanceLevel/components/dailyTrendChart.vue b/src/components/cockpit/exceedanceLevel/components/dailyTrendChart.vue index cdd8fb4..6985ad4 100644 --- a/src/components/cockpit/exceedanceLevel/components/dailyTrendChart.vue +++ b/src/components/cockpit/exceedanceLevel/components/dailyTrendChart.vue @@ -44,18 +44,36 @@ const init = () => { itemStyle: { opacity: 0 }, //去圆点 right: 70 }, - xAxis: { - type: 'time', - axisLabel: { - formatter: { - day: '{MM}-{dd}', - month: '{MM}', - year: '{yyyy}' - } - } - }, + tooltip: { + trigger: 'axis', + formatter: (params: any) => { + if (!params || params.length === 0) return '' - yAxis: [{}, {}], + // 使用第一个项目的轴标签作为时间标题 + let tooltipText = params[0].axisValueLabel + '
' + + // 遍历所有项目并累加到tooltipText中 + params.forEach((item: any) => { + // 将数值格式化为保留两位小数 + const formattedValue = Math.round(item.value[1] * 100) / 100 + tooltipText += `${item.marker} ${item.seriesName}: ${formattedValue}
` + }) + + return tooltipText + } + }, + xAxis: { + type: 'time', + axisLabel: { + formatter: { + day: '{MM}-{dd}', + month: '{MM}', + year: '{yyyy}' + } + } + }, + + yAxis: [{}, {}], grid: { left: '1%', right: '45px',