Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set highcharts y-axis min value to 0, unless there is negative data

I'm having an issue with highcharts where I have a number of different charts being generated by JSON calls.

For the majority of these charts I need the minimum y-axis value to be set at 0, however there are a couple of occasions where negative values need to be shown. How can I tell highcharts to have a minimum y-axis value of 0 only if there are no negative values in the data, is this even possible?

Thanks

like image 663
Pryor74 Avatar asked May 07 '13 10:05

Pryor74


1 Answers

The option that you're looking for is called softMin and was introduced in version 5.0.1. The docs describe it as follows:

A soft minimum for the axis. If the series data minimum is greater than this, the axis will stay at this minimum, but if the series data minimum is lower, the axis will flex to show all data.

yAxis: {     softMin: 0 } 

http://api.highcharts.com/highcharts/yAxis.softMin

like image 170
Yoav Kadosh Avatar answered Oct 02 '22 23:10

Yoav Kadosh