Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Dashed lines for a google line chart

I'd like to have a google line chart with one of the line series a dashed line.

Is this possible using the google jsapi (javascript)?

I'm actually planning on using a ComboChart, with an AreaChart for most of the data, but one series using a LineChart. And I'd like that line to be a dashed line...

like image 302
kimon Avatar asked Mar 26 '12 22:03

kimon


Video Answer


1 Answers

Yes, you can. Just read about the data table roles on the doc

Every point you draw could be certain (certainty : true) or uncertain (certainty : false). Between two points, if one or both are uncertain, the line between will be dashed.

you just have to do like this :

var data = new google.visualization.DataTable();
data.addColumn('string', 'Month'); 
data.addColumn('number', 'Sales'); 
data.addColumn({type:'boolean',role:'certainty'}); // certainty col.
data.addRows([
  ['April',1000,  true],
  ['May',  1170,  true],
  ['June',  660,  true],
  ['July', 1030,  false]
]);
var chartLineWithDash = new google.visualization.LineChart(yourDiv);
chartLineWithDash .draw(data);

the line between June and July will be dashed.

For the moment it is style "Experimental", but feel free to ask! :) Hope it has helped you!

like image 113
Gaelle Avatar answered Oct 24 '22 09:10

Gaelle