如何添加数据标签之间的距离/间距



如果我有大量数据,那么数据标签是重叠的。在这种情况下,如何在数据标签之间添加间距。

[
https://jsfiddle.net/3ekhdqov/1/][1]

anit碰撞数据标签没有内置逻辑,但您可以根据需要实现一些。例如,可以根据点的y值编辑translateY属性。

chart: {
zoomType: 'xy',
events: {
render: function() {
var series = this.series;
series[0].points.forEach(function(point, index) {
if (Math.abs(series[1].points[index].y - point.y) < 20) {
console.log(point.dataLabel)
point.dataLabel.attr({
translateY: point.dataLabel.y + 20
});
}
});
}
}
}

现场演示:https://jsfiddle.net/BlackLabel/bg0eyh2t/

API参考:https://api.highcharts.com/class-reference/Highcharts.SVGElement#attr

最新更新