GeoChart columns

1,119 views
Skip to first unread message

avy

unread,
Jan 20, 2012, 10:54:51 AM1/20/12
to google-visua...@googlegroups.com
Hi! I create a GeoChart for view some data. Chart render very nice, yes. But when i create 4 columns, my chart is broken. My code for example:
function drawRegionsMap() {
    var data = new google.visualization.DataTable();
    data.addColumn('string', 'Country');
    data.addColumn('number', 'Users');
    data.addColumn('number', 'DDCC');
    data.addColumn('number', 'Non DDCC');
    data.addRows([['Germany', 200, 100, 500],['United States', 300, 200, 504]]);
 This is raise a error:
Incompatible data table: Error: Table contains more columns than expected (Expecting 3 columns)
But if i remove 1 column - all works. Why i cannot create 4 columns? Thanks.

asgallant

unread,
Jan 20, 2012, 2:46:50 PM1/20/12
to google-visua...@googlegroups.com
The geoCharts only accepts 2 or 3 columns (depending on whether you are using regions or markers mode): 1 for location, 1 for location value (used to color the data point), and 1 for marker size (in marker mode only).  The chart doesn't know what to do with a 4th column.

If you need the 4th column for something else, you can hide it from the geoChart by using a DataView:

var view = new google.visualization.DataView(data);
view.setColumns([0,1,2]);
// chart is the geoChart, options is an object of chart options
chart.draw(view, options);
Reply all
Reply to author
Forward
0 new messages