Column Stacked Chart

2,940 views
Skip to first unread message

Satish

unread,
Nov 1, 2011, 1:22:10 PM11/1/11
to Google Visualization API
Hi Everyone,
This is my first post in this group and I have been
using Google chart api's for a while now. I would like to know how can
i draw COLUMN STACKED CHART using google chart apis. When i say column
stacked chart i refer to this:

http://peltiertech.com/Utility/pix/clusterstackcolumns.png

I have looked around the google chart apis but could
not find anything which can meet my requirement. Does google chart
api's support this functionality? Is yes, kindly suggest how can I
implement the same.

Thank You

Matt

unread,
Nov 1, 2011, 2:38:15 PM11/1/11
to Google Visualization API
First, goto this Google playground site for bar charts:
http://code.google.com/apis/ajax/playground/?type=visualization#bar_chart

In the editable code, near the very bottom, add:
isStacked: true
So it will look something like this:

new
google.visualization.BarChart(document.getElementById('visualization')).
draw(data,
{title:"Yearly Coffee Consumption by Country",
width:600, height:400,
isStacked: true,
vAxis: {title: "Year"},
hAxis: {title: "Cups"}}
);

Matt

unread,
Nov 1, 2011, 2:40:24 PM11/1/11
to Google Visualization API
I originally meant to send you this link, it works there as well for
your column charts.

http://code.google.com/apis/ajax/playground/?type=visualization#column_chart

On Nov 1, 11:38 am, Matt <mhe...@kixeye.com> wrote:
> First, goto this Google playground site for bar charts:http://code.google.com/apis/ajax/playground/?type=visualization#bar_c...

asgallant

unread,
Nov 1, 2011, 4:03:19 PM11/1/11
to google-visua...@googlegroups.com
Matt's post is good if you just want stacked bars, but if you are looking for a cluster-stacked chart (like the one you linked to), that is doable, but requires a bit of hackery to make it happen.

Satish

unread,
Nov 2, 2011, 5:57:06 PM11/2/11
to Google Visualization API
Hi asagallant,
Can you tell me how can i do this.

-Satish

asgallant

unread,
Nov 3, 2011, 10:24:46 AM11/3/11
to google-visua...@googlegroups.com
Basically, there are two techniques at work here:

1) You need to create 1 DataTable column for each data color you want.  Each chart column is its own row in the DataTable: set only the values you want to show in a particular column (everything else should be null).
2) You need to insert rows of null data to create the gaps between grouped columns

See my example code here: http://jsfiddle.net/yRnNk/1/

ibanhoe

unread,
Aug 1, 2012, 11:29:33 PM8/1/12
to google-visua...@googlegroups.com
Hi asgallant

I need something like the example you sent to Satish.

The difference y that i want to show the current value and the percentage that this value represents for the stacked bar. Please see the image attached

Is it possible?

Thanks a lot

chart.png

asgallant

unread,
Aug 2, 2012, 12:41:30 PM8/2/12
to google-visua...@googlegroups.com
You can do that by manually setting the formatted value of a cell to whatever you want the tooltip to show, ie in your example it would be "1,347.0 entradas, 45%".

minimoto

unread,
Apr 30, 2014, 2:08:08 PM4/30/14
to google-visua...@googlegroups.com
Its old post, but your solution worked for me, thank you for sharing!

N Lurie

unread,
Jun 16, 2014, 11:49:55 PM6/16/14
to google-visua...@googlegroups.com
I need to add a third stack to each column, and now I have 7 data.addColumn clauses, and 7 values in the data.addRow arrays. Any idea why it is note running? I simply grew everything proportionally. Thanks!

Andrew Gallant

unread,
Jun 17, 2014, 12:05:18 AM6/17/14
to google-visua...@googlegroups.com
Can you post example code that demonstrates the problem?
Reply all
Reply to author
Forward
0 new messages