Reputation: 386
For some reason Google Visualization API stopped working for me since last night. I keep getting an Unknown Header Type error in the javascript console which doesn't seem to be very common. I have not found a single reference to this error in relation to the google charts api.
Here is the code I use to generate my datatable
var gData = new google.visualization.DataTable();
gData.addColumn("string", "Interval");
var mtw=false;
var maxColumns=0;
$.each(data, function(key, val){
if(j==0){
$.each(val, function(key2, val2){
j++;
gData.addColumn("number", key2);
if(key2.length==3 || key2.length==4){
mtw=true;
}
});
}
var row = new Array();
var k=0;
row[k] = key;
$.each(val, function(key3, val3){
k++;
row[k] = parseInt(val3);
if(maxColumns < k){
maxColumns = k;
}
});
while(maxColumns > k){
k++;
row[k]=0;
}
rows[i] = row;
i++;
});
gData.addRows(rows);
I have been loggin the gData object and this is the column headers
Ve: Array[6]
0: Object
id: ""
label: "Interval"
pattern: ""
type: "string"
__proto__: Object
1: Object
id: ""
label: "11/18/2013"
pattern: ""
type: "number"
__proto__: Object
2: Object
id: ""
label: "11/19/2013"
pattern: ""
type: "number"
__proto__: Object
3: Object
id: ""
label: "11/20/2013"
pattern: ""
type: "number"
__proto__: Object
4: Object
id: ""
label: "11/21/2013"
pattern: ""
type: "number"
__proto__: Object
5: Object
id: ""
label: "11/22/2013"
pattern: ""
type: "number"
__proto__: Object
length: 6
__proto__: Array[0]
I am not sure why this stopped working all of a sudden.
Upvotes: 1
Views: 6827
Reputation: 20482
addColumn(type, opt_label, opt_id)
where opt_label is a string.
Maybe key2 needs to be a 'string' gData.addColumn("number", key2);
Also, i can't see where val2 and key2 are defined.
So my 'best-guess' answer is : look into your json object and notice you sledgehammered it .
Upvotes: 2