Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Charts - Curved Line Chart incorrectly dips below 0

I have a Google line chart, I set 'curveType': 'function' so the graph is curved and has a nice appearance. My problem is that when a data point has a value of 0, followed by a following high value, the chart dips below 0 so that the curve can fit correctly. This also causes the vAxis to have a minRange of -2000, this isn't possible for my data (number of downloads over time).

I've tried to solve this by setting 'minValue': 0 and 'viewWindowMode': 'maximized' on the vAxis, but it hasn't solved the problem completely.

I have attached an image that will explain my problem a lot better than I can with words.

If anyone knows a solution to this, without me having to go back to straight lines, it would be much appreciated. Thanks

like image 930
SteveEdson Avatar asked Oct 31 '12 14:10

SteveEdson


2 Answers

The curve may continue to dip below 0 no matter what you do, but you can crop the view so the lowest point of the displayed graph is at 0. You can do that with the vAxis.viewWindow.min property:

lineChart.draw(data, 
   {
    curveType: "function",
    vAxis: {viewWindow: {min:0} } 
   }
);

See the LineChart documentation for information on vAxis.viewWindow.min and other configuration options.

like image 157
Peter Dolberg Avatar answered Oct 26 '22 18:10

Peter Dolberg


Just a quick update on this. I realised that my data work not be suitable for a curved graph anyway, as it is discrete data and not continuous. I had to switch back to straight lines, which removed my problem. Not an ideal solution, I know, but it is one that worked for me.

like image 37
SteveEdson Avatar answered Oct 26 '22 18:10

SteveEdson