just coded something that might help you. Tested for BarChart, ColumnChart, LineChart and AreaChart, it works well for me (it will not work correctly for PieCharts by design).
Chief Designer Code:
function Charts (options){
var self = this;
self.chart = [];
self.dataTable = new google.visualization.DataTable();
self.settings = $.extend({
colors:['#98D8F4','#E85500','#B3CF2F', '#FEB800', '#FFA1C5', '#D984FF', '#DD9D75'],
width: 960, height: 600,
}, options);
self.add = function(type, element){
self.chart.push({
element: $(element),
o: new google.visualization[type]($(element)[0]),
draw: function(dataTable, options){
this.element.html('');
this.o.draw(dataTable, options);
}
});
};
self.draw = function(options){
var settings = $.extend({}, this.settings, options);
$.each(self.chart, function(i, chart){
chart.draw(self.dataTable, settings)
})
};
self.parseData = function(labels, legends, data){
var countRows = data[0].length;
self.dataTable.addColumn('string', 'Name');
$.each(legends, function(i, legend){
self.dataTable.addColumn('number', legend);
})
self.dataTable.addRows(countRows);
$.each(labels, function(i, label){
self.dataTable.setValue(i, 0, label);
$.each(data, function(k, entry){
self.dataTable.setValue(i, k+1, data[k][i]);
})
})
return self.dataTable;
};
}
( )
var labels = [ "Kaspersky","Symantec","G-Data","Avira" ],
legends = [ "Antivirensoftware (kostenpflichtig)","Antivirensoftware (kostenlos)","Internetsecurity (kostenpflichtig)","Internetsecurity (kostenlos)","Sonstiges, keine Angabe","Beta-Test KIS 2010", "Something Else" ],
data = [ [46,4,7,33],[3,1,2,38],[42,12,14,7],[2,0,1,1],[43,8,14,18],[4,3,0,1],[1,2,4,2]];
, script , .
var charts = new Charts();
charts.parseData(labels, legends, data);
charts.add('ColumnChart', '#column-chart');
charts.add('BarChart', '#bar-chart');
charts.draw({title: 'Antivirus Comparison Chart', titleY:'Points'});
charts.parseData(otherLabels, otherLegends, otherData);
charts.draw({title: 'Antivirus Comparison Chart with Other Data', titleY:'Points'});
, :)
, script , .
google.load("jquery", "1.3.2");
google.load('visualization', '1', {'packages':['piechart','barchart','columnchart']});
google.setOnLoadCallback(function() {
});