8

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

Community
  • 1
  • 1
SteveEdson
  • 2,485
  • 2
  • 28
  • 46

3 Answers3

15

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.

Peter Dolberg
  • 2,027
  • 16
  • 21
2

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.

SteveEdson
  • 2,485
  • 2
  • 28
  • 46
0

You could try another charting library. I often use flot for simple graphs, and raphael graphs for more complicated things (slightly harder to manipulate, and looks a bit more clunky to me)

gRaphael: http://g.raphaeljs.com/ Flot: http://www.flotcharts.org/

Billy Moon
  • 57,113
  • 24
  • 136
  • 237
  • I'll bear this in mind for future work, however unfortunately, this is not a suitable solution for this project as too much work has gone into making the dashboard, other charts and controls etc. Thanks though. – SteveEdson Oct 31 '12 at 15:02