ECharts dataZoom Slider 格式化两端标签

ECharts About 485 words

slider.labelFormatter

string

支持字符串模板,只显示{value},不能使用日期格式化{yyyy}

可以设置为{value} m/s等,添加了字符串m/s这种。

Function

比如将X轴类型为time的数值,在Slider上格式化为日期字符串。

const option = {
    xAxis: {
        type: 'time',
    },
    dataZoom: [
        {
            type: 'slider',
            labelFormatter: function (params) {
                return echarts.time.format(params, '{yyyy}-{MM}', false)
            },
        },
    ],
}

文档

https://echarts.apache.org/zh/option.html#dataZoom-slider.labelFormatter

Views: 18 · Posted: 2026-02-12

———         Thanks for Reading         ———

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

扫描下方二维码关注公众号和小程序↓↓↓

扫描下方二维码关注公众号和小程序↓↓↓
Prev Post
Today In History
Browsing Refresh