Google Charts - No Data Available - Able To Display A Blank Chart?
How can I still have Google Charts still show a line chart if my data array looks like this? [['Date','Line']] i.e. just the axis are defined. Most of my charts have data imported
Solution 1:
Well, to draw the chart you need at least one data point. To archieve this, you could use this workaround:
var data = google.visualization.arrayToDataTable([
[{
f: 'Date',
type: 'date'// wont work whithout this
}, {
f: 'Line',
type: 'number'// wont work whithout this
}], ]);
var options = {
title: 'Company Performance'
};
if (data.getNumberOfRows() == 0) { // if you have no data, add a data point and make the series transparent
data.addRow([new Date(), 0])
options.series = {
0: {
color: 'transparent'
}
}
}
Full fiddle: http://jsfiddle.net/qaLgh955/
Post a Comment for "Google Charts - No Data Available - Able To Display A Blank Chart?"