0
votes

I am trying to make a stacked area highcharts image. Upon searching for the past two hours to set the y-axis max values as the max value of the stack, I was unsuccessful.

enter code herehttp://jsfiddle.net/ms3zcp18/

In the above link, I want the y-axis to be 5268 (doesn't care if it is billions or millions) and not 10. The 10 represents the total 10billion in 2050 but I only want the maximum of 2050 which is 5268 millions as my y-axis. Min value of my y-axis can be 0.

Everyone is speaking about plain charts but stacked area chart max y-axis is not discussed across all forums. I could be wrong too because I only did 2hrs worth of research. And if possible, can the new edit be at the end of javascript file because I am already using the existing javascript file with specific line numbers to make new charts.

Thanks in advance.

2
I updated my answer - Core972

2 Answers

0
votes

If you set the max property only with the value of the highest point, the full range will be cut. So to set the range to show all values, you need to cumulate all stacked values of a specific x, and set max using value created from stacked y. If you have dynamic values, you can update yAxis on load event for example.

API Reference:
http://api.highcharts.com/highcharts/yAxis.max
http://api.highcharts.com/highcharts/yAxis.showLastLabel
http://api.highcharts.com/highcharts/chart.events.load
http://api.highcharts.com/highcharts/Axis.update

Example:
http://jsfiddle.net/o8yd99je/

0
votes

Using this code you can do it but as you said it's a stacked chart so you don't see the top value anymore :

yAxis: {
   ...
   tickinterval: 5268,
   showLastLabel: false
}

Update: Here a fiddle updated to V2