ECharts X 轴设置标签重叠时隐藏

ECharts About 611 words

category 类型(默认)

X轴是类目轴(category)时,标签的显示间隔为auto,采用标签不重叠的策略间隔显示标签。

设置成0强制显示所有标签。

设置为1,表示隔一个标签显示一个标签,如果值为2,表示隔两个标签显示一个标签,以此类推。

const option = {
    xAxis: {
        type: 'category',
        axisLabel: {
            interval: 'auto',
        },
    },
};

time 类型

X轴为time类型时,axisLabelhideOverlap属性可以时标签自动隐藏重叠的标签。

const option = {
    xAxis: {
        type: 'time',
        axisLabel: {
            formatter: '{yyyy}',
            hideOverlap: true,
        },
    },
};

文档

https://echarts.apache.org/zh/option.html#xAxis.axisLabel.interval

https://echarts.apache.org/zh/option.html#xAxis.axisLabel.hideOverlap

Views: 10 · Posted: 2026-03-30

———         Thanks for Reading         ———

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

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

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