我尝试了以下演示[在此处输入链接描述] [1]
[1]:https://jsfiddle.net/6snza1fo/ enter code here
您可以以轴为单位计算所需空间,并使用setExtremes
方法应用它:
chart: {
height: 205,
width: 200,
background: '#F2F2F2',
events: {
load: function() {
var maxPxY = 0,
yAxis = this.yAxis[0];
this.series.forEach(function(s) {
s.points.forEach(function(p) {
if (p.dataLabel && p.dataLabel.alignAttr.y < maxPxY) {
maxPxY = p.dataLabel.alignAttr.y;
}
});
});
if (maxPxY) {
yAxis.setExtremes(null, yAxis.toValue(maxPxY));
}
}
}
}
实时演示: https://jsfiddle.net/BlackLabel/amwefro6/1/
API参考:
https://api.highcharts.com/class-reference/Highcharts.Axis#toValue