ECharts endLabel 超出画布时换行显示
ECharts About 861 wordsseries endLabel
需要配合grid、endLabel的width/distance/overflow、和labelLayout的moveOverlap。
grid.right设置为80,则endLabel的width和distance总和不要超过grid.right(80)。
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: 5 · Posted: 2026-03-06
———         Thanks for Reading         ———
Give me a Star, Thanks:)
https://github.com/fendoudebb/LiteNote扫描下方二维码关注公众号和小程序↓↓↓
Loading...