Knowledge Base Article

Set Max Value For Y Axis In A Chart

There might be cases where one needs to increase the height of the Y-Axis in a chart to ensure that the value labels are not removed while the chart is being responsive.  The following script allows you to increase the max Y-Axis value by an X percentage.
NOTE: The script assumes that the series is ordered in descending order and so takes the first value it gets from the list.
Increase the max value of YAxis to be 30% more than the Max Y Value
widget.on('processresult',function(widget, ev){
 
 var increasePercent = 0.3; // Change the value as needed
 var seriesNum = 0; // Change the value as needed
 
 var s = ev.result.series[seriesNum];
 
 if (!Array.isArray(s) || !s.length) {
 
 var maxYValue = s.data[0].y; // Get first data value since series is ordered in descending order
 
 ev.result.yAxis[0].max = maxYValue + increasePercent * maxYValue ;
 }

})
Updated 03-02-2023
No CommentsBe the first to comment