Google Geo Chart Incompatible data table: Error: the table contains more columns than expected (expecting 3 columns)

I have the following code and a table of incompatible data was found: Error: the 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); }; 
+6
source share
2 answers

Geocharts does not support the presence of 3 different data columns, as you have.

Region Charts

For regional charts, data should include only:

  • Region (country, subcontinent, continent, etc.).
  • Color (determines the color for each region based on one data category)

Marker Charts

For marker diagrams, data should include only:

  • Location (latitude / longitude or location bar)
  • (optional) Location name for latitude / longitude only locations
  • Color (marker color based on one data category)
  • Size (marker size based on one data category)

Your example at present is a marker chart with a third category of data that is not supported (your User will determine the color, and Company will determine the size).

+6
source

It's your decision:

 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, {... 
+3
source

All Articles