Hi there,
I'm trying to build a stacked bar chart in Code Playground that uses
text for the horizontal axis (row) labels instead of an ordered set of
values. So, for example, with the following bit of code, how would I
go about changing the labels under the 'Years' field into something
other than numbers, i.e. just a random text name? Whenever I change
the [2003 ... 2006] string to anything other than numbers it breaks
the chart.
Any help would be greatly appreciated!
-CVL
function drawVisualization() {
// Create and populate the data table.
var data = new google.visualization.DataTable();
var raw_data = [['Old', 203, 92, 33, 25],
['New', 212, 84, 72, 22],
['Left', 729, 968, 1039, 1097]];
var years = [2003, 2004, 2005, 2006];
data.addColumn('string', 'Years');
for (var i = 0; i < raw_data.length; ++i) {
data.addColumn('number', raw_data[i][0]);
}
data.addRows(years.length);
for (var j = 0; j < years.length; ++j) {
data.setValue(j, 0, years[j].toString());
}
for (var i = 0; i < raw_data.length; ++i) {
for (var j = 1; j < raw_data[i].length; ++j) {
data.setValue(j-1, i+1, raw_data[i][j]);
}
}
// 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 received this message because you are subscribed to the Google Groups
"Google Chart API" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-chart-api?hl=en.