Sorting by DataSource Values?

31 views
Skip to first unread message

Matt

unread,
Jun 20, 2017, 6:14:51 PM6/20/17
to Google Visualization API
Is it possible to bring in a datasource on a stacked column graph and use one column in the datasource to stack by? 

If my data looks like below, I would like each stacked column to be a Client. Is this possible? 

[["2017/06/25", "Client A", 805.0],
["2017/06/25", "Client B", 805.0],..]

Daniel LaLiberte

unread,
Jun 20, 2017, 6:29:52 PM6/20/17
to Google Visualization API
This form of the data is similar to PieChart, where each subsequent row is stacked in a single pie, with proportional scaling. 

The ColumnChart is really designed for stacking multiple series in a single column, and then each row represents another stack.    So you could get what you want by changing the datatable structure so each of your clients is in a separate column.  Label the columns e.g. Client A, Client B, etc.

But if you can't change the datatable structure, you could add a 'style' role column to specify the color of each row.

--
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-visualization-api+unsub...@googlegroups.com.
To post to this group, send email to google-visualization-api@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/411ae937-6358-4a11-964e-0d6cc0fd54f4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--

Matt

unread,
Jun 20, 2017, 6:36:39 PM6/20/17
to Google Visualization API
Daniel,

Thanks for the quick response. I'm loving google charts - they've allowed me to create some really cool stuff.

My "clients" will be dynamic, so I can't define those. You're suggesting something like I have below. Is it possible to have each client in the legend? 

function drawStacked() {
      var data = new google.visualization.DataTable();
      data.addColumn('string', 'Week');
      data.addColumn({type: 'string', role: 'style'});
      data.addColumn('number', 'Hours');
      data.addRows( {{ sbl1|safe }} );

Daniel LaLiberte

unread,
Jun 20, 2017, 6:41:49 PM6/20/17
to Google Visualization API
The style role would go after the number column.  But if you do it this way, you won't get each item in the legend, unfortunately.

You can dynamically construct a datatable, or dataview, that has any number of columns, however, so that should result in a single stack, with each item in the legend as well.

--
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-visualization-api+unsub...@googlegroups.com.
To post to this group, send email to google-visualization-api@googlegroups.com.
Visit this group at https://groups.google.com/group/google-visualization-api.

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

Matt

unread,
Jun 20, 2017, 6:50:11 PM6/20/17
to Google Visualization API
Could you point me in the right direction to achieve that dynamically? I haven't been able to find any resources.
Reply all
Reply to author
Forward
0 new messages