ECharts endLabel 超出画布时换行显示

ECharts About 861 words

series endLabel

需要配合gridendLabelwidth/distance/overflow、和labelLayoutmoveOverlap

grid.right设置为80,则endLabelwidthdistance总和不要超过grid.right80)。

distance默认是5

overflow设置为breakAll表示当一个很长的英文单词也会强制换行。

labelLayout.moveOverlap设置为shiftY表示当两个endLabel重叠时按Y轴依次往下排列。

option = {
  xAxis: {
    type: "category",
    data: ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"]
  },
  yAxis: {},
  grid: {
      right: '80',
  },
  series: [{
    data: [820, 932, 901, 934, 1290, 1330, 1320],
    type: "line",
    endLabel: {
      show: true,
      width: 75,
      distance: 5,
      overflow: 'breakAll',
    },
    labelLayout: {
        moveOverlap: 'shiftY',
    },
  }]
}

文档

https://echarts.apache.org/zh/option.html#grid.right

https://echarts.apache.org/zh/option.html#series-line.endLabel

https://echarts.apache.org/zh/option.html#series-line.labelLayout.moveOverlap

Views: 8 · Posted: 2026-03-06

———         Thanks for Reading         ———

Give me a Star, Thanks:)

https://github.com/fendoudebb/LiteNote

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

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