How do I add a vertical line marker to my stacked ColumnChart

44 views
Skip to first unread message

Steve Morris

unread,
Feb 21, 2016, 11:42:19 AM2/21/16
to Google Visualization API

How do I add a vertical line marker to a stacked ColumnChart (the red line in the attached bitmap)?
The X-axis is continuous and the x-positions of the columns are "timeofday". The marker will indicate the current time.



Steve Morris

unread,
Feb 22, 2016, 5:59:23 AM2/22/16
to Google Visualization API
Following a example I found on StackOverflow, I tried adding an extra column, with type='timeofday' and role='annotation', an extra row with the time and an annotation style='line', but that does not work.

var numCols=
graphData
.
cols.length;
graphData
.
cols[numCols]={id:'timeLine', type: 'timeofday', role: 'annotation'};

var numRows=
graphData
.
rows.length;
graphData
.
rows[numRows]={c:[]};
graphData
.
rows[numRows].c[numCols]=[10, 47, 0];

graphOptions.annotation=[];
graphOptions.annotation[numCols]={style:'line'};

chart.draw(graphData, graphOptions);


Daniel LaLiberte

unread,
Feb 22, 2016, 9:18:48 AM2/22/16
to Google Visualization API
Hi Steve,

What you want is called a 'domain' annotation, which you should insert immediately after the first column (column 0).  The position of this annotation line will be determined by the corresponding domain value.  Your annotation column should be of type string, but you should be able to give an empty string.  Try a non-empty string first just to make sure you have everything else right.

The line annotation doesn't include the little triangles on the top and bottom, however.  

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualizati...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/8fe7dd0b-c995-4bd9-be45-55653143211d%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--

Steve Morris

unread,
Feb 22, 2016, 3:03:03 PM2/22/16
to Google Visualization API
Thanks, Daniel, that works a charm.

I saw that I can change the color of the line  with 
annotations: {stemColor: 'red'}

Is there anyway to also change the thickness of the line and make it dashed (as compensation for not getting the "little triangles")?

Daniel LaLiberte

unread,
Feb 22, 2016, 3:11:00 PM2/22/16
to Google Visualization API
Sorry, not yet.  Good idea though and we'll probably be able to support that in the future.

--
You received this message because you are subscribed to the Google Groups "Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualizati...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at https://groups.google.com/group/google-visualization-api.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages