动态添加了带有min和max的Highcharts系列



我目前有一个Highcharts图表,它有几个选项卡,允许用户在图形/图表上显示各种数据。我动态地为每一个数据点添加级数。

然而,我想为yAxis的两个数据点设置minmax(而不是Highcharts只是自动确定minmax),以便在比较图上的数据时,它们彼此对齐。然而,我似乎找不到一种方法来为添加的系列设置yAxisminmax

下面是我当前的内容:

window["chart"].addAxis({
id: 'Data',
title: {
text: 'Graph',
enabled: true
},
lineWidth: 0,
lineColor: '#000000'
});
window["chart"].addSeries({
data: groupingData,
name: 'Graph',
type: 'line',
color: '#000000',
yAxis: 'Data'
});

在动态添加此系列时,我如何强制minmax用于yAxis?

您可以使用setExtrimes():

https://api.highcharts.com/highcharts/xAxis.events.setExtremeshttps://api.highcharts.com/highcharts/yAxis.events.setExtremes

chart.yAxis[0].setExtremes();

如果有人在寻找答案,我发现当addAxis被调用时,您可以设置min和max:

window["chart"].addAxis({
id: 'Data',
title: {
text: 'Graph',
enabled: true
},
lineWidth: 0,
lineColor: '#000000',
min: minNumber,
max: maxNumber
)}

最新更新