ECharts axisPointer cross 格式化 X 轴与 Y 轴的 label
ECharts About 667 words十字准星指示器
当type为cross时,label的formatter的参数对象中axisDimension表示是X轴还是Y轴。
示例
例子中的xAxis类型是time,所以使用了时间格式化工具类对X轴的label进行格式化,对于Y轴则使用保留两位小数的方法。
const option = {
tooltip: {
trigger: 'axis',
axisPointer: {
type: "cross",
label: {
formatter: (params) => {
if (params.axisDimension === 'x') {
return echarts.time.format(params.value, '{yyyy}-{MM}', false);
} else {
return params.value.toFixed(2);
}
}
},
}
},
}
文档
Views: 7 · Posted: 2026-03-24
———         Thanks for Reading         ———
Give me a Star, Thanks:)
https://github.com/fendoudebb/LiteNote扫描下方二维码关注公众号和小程序↓↓↓
Loading...