Reputation: 458
I do have the issue that I have several events in one year, which I want to group.
function drawVisualization() {
// Create and populate the data table.
var data = google.visualization.arrayToDataTable([
['Year', 'Austria'],
['2003', 1336060],
['2004', 1538156],
['2005', 1576579],
['2006', 1600652],
['2007', 1968113],
['2007', 1968113],
['2007', 1968113],
['2007', 1968113],
['2008', 1901067]
]);
// 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"}}
);
}
Result of this code is this:
Is it possible customize this to get this result?
If i can't get this result with Google Visualization API is there an JS-Framework which has this ability?
Upvotes: 0
Views: 117
Reputation: 1394
You're looking for a column chart. Here's a fiddle that does what you want, I think.
var data = google.visualization.arrayToDataTable([
['Year', 'Austria', 'New Zealand', 'New Guinea'],
['2003', 1336060,0,0],
['2004', 1538156,0,0],
['2005', 1576579,0,0],
['2006', 1600652,0,0],
['2007', 1968113,1968113,1968113],
['2008', 1901067,0,0]]);
var options = {
width: 600,
height: 400,
legend: { position: 'top', maxLines: 3 },
bar: { groupWidth: '75%' },
isStacked: true,
};
var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
chart.draw(data, options);
Upvotes: 2
Reputation: 609
Try this:
var data = google.visualization.arrayToDataTable([
['Year', 'Austria'],
['2003', '', '', '1336060'],
['2004', '', '', '1538156'],
['2005', '', '', '1576579'],
['2006', '', '', '1600652'],
['2007', '1968113', '1968113', '1968113'],
['2008', '', '', 1901067]
]);
Upvotes: 2