Possible Duplicate:
Can someone help me create a simple vertical bar chart using google charts?
Im using new Google Chart Tools, and I want to create stacked bar chart format.
The Google Developers site gives some details on the bar chart format: https://developers.google.com/chart/interactive/docs/gallery/barchart
To make a normal bar chart stacked, you need to user the isStacked: true
option. You can copy and paste the following code into the Chart Tools playground to see a working example:
http://code.google.com/apis/ajax/playground/?type=visualization
function drawVisualization() {
// Create and populate the data table.
var data = google.visualization.arrayToDataTable([
['Year', 'Austria', 'Bulgaria', 'Denmark', 'Greece'],
['2003', 1336060, 400361, 1001582, 997974],
['2004', 1538156, 366849, 1119450, 941795],
['2005', 1576579, 440514, 993360, 930593],
['2006', 1600652, 434552, 1004163, 897127],
['2007', 1968113, 393032, 979198, 1080887],
['2008', 1901067, 517206, 916965, 1056036]
]);
// Create and draw the visualization.
new google.visualization.BarChart(document.getElementById('visualization')).
draw(data,
{title:"Yearly Coffee Consumption by Country",
width:600, height:400,
vAxis: {title: "Year"},
hAxis: {title: "Cups"},
isStacked: true}
);
}
You might also be interested in a Stacked Area Chart, depending on what data you are trying to display.
There is also a question which gives an example of a stacked bar chart using the Chart Tools Image API: Bar chart in Javascript: stacked bars + grouped bars
Note that the Image Charts portion of Google Chart Tools was officially deprecated on the 20th April, 2012. Image charts will still work for a while as per Google's deprecation policy, but I recommend you concentrate on the interactive HTML5+SVG implementation described above.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With