如何在 boxplot highcharts 中将函数设置为最大值
How to set a function to the max value in boxplot highcharts
我正在使用 Angular 和 highcharts 箱线图 API。
我知道我可以在图表配置中设置 y 轴的最大值,就像这样。
max: 100,
tickInterval: 10.
但现在我需要将最大值更改为 return 值。
例如,如果最大 return 值在 60% 左右,那么我应该将最大值设置为 60。
max:60,
tickInterval: 10.
有什么方法可以添加一些 method/function 以适应最大 return 值吗?
例如:
max: funticon(){ xxxxx; return A},
tickInterval: 10
以上函数是我自己的一个检查API最大值的方法。
检查后 return 到图表配置以设置最大值。
使用 chart.events.load 您将能够为 yAxis.max 更新和设置这些值:
https://api.highcharts.com/highcharts/chart.events.load
https://api.highcharts.com/class-reference/Highcharts.Chart#update
演示:
https://stackblitz.com/edit/highcharts-angular-basic-line-wtoktb
chart: {
events: {
load: function() {
const chart = this;
chart.update({
yAxis: {
max: (chart.yAxis[0] as any).dataMax
}
})
}
}
}
我正在使用 Angular 和 highcharts 箱线图 API。 我知道我可以在图表配置中设置 y 轴的最大值,就像这样。
max: 100,
tickInterval: 10.
但现在我需要将最大值更改为 return 值。 例如,如果最大 return 值在 60% 左右,那么我应该将最大值设置为 60。
max:60,
tickInterval: 10.
有什么方法可以添加一些 method/function 以适应最大 return 值吗? 例如:
max: funticon(){ xxxxx; return A},
tickInterval: 10
以上函数是我自己的一个检查API最大值的方法。 检查后 return 到图表配置以设置最大值。
使用 chart.events.load 您将能够为 yAxis.max 更新和设置这些值: https://api.highcharts.com/highcharts/chart.events.load https://api.highcharts.com/class-reference/Highcharts.Chart#update
演示: https://stackblitz.com/edit/highcharts-angular-basic-line-wtoktb
chart: {
events: {
load: function() {
const chart = this;
chart.update({
yAxis: {
max: (chart.yAxis[0] as any).dataMax
}
})
}
}
}