I have the following code and found Incompatible data table: Error: Table contains more columns than expected (Expecting 3 columns)
function drawMarkersMap() {
var data = google.visualization.arrayToDataTable([
['State', 'User', 'Company','data'],
['Australian Capital Territory', 100, 160, 100],
['Northern Territory', 250, 250, 200 ],
['Western Australia', 150, 350, 300],
['New South Wales', 300, 100, 400],
['Victoria', 50, 156, 50],
['Queensland', 10, 150, 20],
['South Australia', 160, 168, 23],
['Tasmania', 250, 568, 3443]
]);
var options = {
region : 'AU',
displayMode : 'markers',
colorAxis : {
colors: ['blue', 'red']
}
};
var chart = new google.visualization.GeoChart(document.getElementById('chart_div_geo'));
chart.draw(data, options);
};
Geocharts do not support having 3 different data columns as you have.
For region charts, the data should include only:
For marker charts, the data should include only:
Currently your example is a marker chart with a third data category, which isn't supported (your User
will determine color, and Company
will determine size).
This is your solution:
var view = new google.visualization.DataView(data);
view.setColumns([0, {
type: 'number',
label: 'Total Staff',
calc: function (dt, row) {
return {
v: dt.getValue(row, 1),
f: dt.getFormattedValue(row, 1) + ' (' + dt.getFormattedValue(row, 2) + ' IT, ' + dt.getFormattedValue(row, 3) + ' HR, ' + dt.getFormattedValue(row, 4) + ' Sales)'
}
}
}]);
chart.draw(view, {...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With