Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Charts API Smooth Line Chart

Does anyone know how to create a line chart with a smooth line instead of a jagged line?

I think my chart would present much better to end users with a smooth line.

Here's an example URL:

http://chart.apis.google.com/chart?chxr=0,0,46&chxt=y&chs=300x225&cht=lc&chco=3D7930&chd=s:MNPRSYVUSSMNQRVfXXSPPM&chg=14.3,-1,1,1&chls=2,4,0&chm=B,C5D4B5BB,0,0,0

like image 473
fishbone Avatar asked Feb 03 '11 17:02

fishbone


People also ask

Is Google Charts API free?

Google chart tools are powerful, simple to use, and free. Try out our rich gallery of interactive charts and data tools.

What type of data is best for a line chart?

Line graphs are used to track changes over short and long periods of time. When smaller changes exist, line graphs are better to use than bar graphs. Line graphs can also be used to compare changes over the same period of time for more than one group.


1 Answers

I simply used

var options = {smoothLine: true,}

  var chart = new google.visualization.LineChart(document.getElementById('some_id'));
  chart.draw(data, options);

Disclaimer: if you have very sharp corners the rounding/smoothing can be misleading (for ex. if your curve goes quickly to f(x) = 0 it can become negative to fit the corner.

like image 84
Massagran Avatar answered Oct 25 '22 14:10

Massagran