取值修改
This commit is contained in:
@@ -44,18 +44,36 @@ const init = () => {
|
|||||||
itemStyle: { opacity: 0 }, //去圆点
|
itemStyle: { opacity: 0 }, //去圆点
|
||||||
right: 70
|
right: 70
|
||||||
},
|
},
|
||||||
xAxis: {
|
tooltip: {
|
||||||
type: 'time',
|
trigger: 'axis',
|
||||||
axisLabel: {
|
formatter: (params: any) => {
|
||||||
formatter: {
|
if (!params || params.length === 0) return ''
|
||||||
day: '{MM}-{dd}',
|
|
||||||
month: '{MM}',
|
|
||||||
year: '{yyyy}'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
yAxis: [{}, {}],
|
// 使用第一个项目的轴标签作为时间标题
|
||||||
|
let tooltipText = params[0].axisValueLabel + '<br/>'
|
||||||
|
|
||||||
|
// 遍历所有项目并累加到tooltipText中
|
||||||
|
params.forEach((item: any) => {
|
||||||
|
// 将数值格式化为保留两位小数
|
||||||
|
const formattedValue = Math.round(item.value[1] * 100) / 100
|
||||||
|
tooltipText += `${item.marker} ${item.seriesName}: ${formattedValue}<br/>`
|
||||||
|
})
|
||||||
|
|
||||||
|
return tooltipText
|
||||||
|
}
|
||||||
|
},
|
||||||
|
xAxis: {
|
||||||
|
type: 'time',
|
||||||
|
axisLabel: {
|
||||||
|
formatter: {
|
||||||
|
day: '{MM}-{dd}',
|
||||||
|
month: '{MM}',
|
||||||
|
year: '{yyyy}'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
yAxis: [{}, {}],
|
||||||
grid: {
|
grid: {
|
||||||
left: '1%',
|
left: '1%',
|
||||||
right: '45px',
|
right: '45px',
|
||||||
|
|||||||
Reference in New Issue
Block a user