Geochart Colors

912 views
Skip to first unread message

lcm133

unread,
Nov 2, 2011, 12:16:53 PM11/2/11
to Google Visualization API
Is it possible to change the GeoChart colors without specifying a
'number' column?

In the code below, the color defaults to Green when the 'number'
column code remmed out (the colors config option is ignored). However,
if I unremark those lines, the color turns to Red (the colors config
is NOT ignored).

function drawVisualization() {
var data = new google.visualization.DataTable();
data.addRows(5);
data.addColumn('string', 'State');
//data.addColumn('number', 'Number');
data.setValue(0, 0, 'Virginia');
//data.setValue(0, 1, 1);
data.setValue(1, 0, 'Maryland');
//data.setValue(1, 1, 1);
data.setValue(2, 0, 'District of Columbia');
//data.setValue(2, 1, 1);
data.setValue(3, 0, 'California');
//data.setValue(3, 1, 1);
data.setValue(4, 0, 'Texas');
//data.setValue(4, 1, 1);

var geochart = new google.visualization.GeoChart(
document.getElementById('visualization'));
geochart.draw(data, {width: 556,
height: 347,
region: 'US',
resolution: 'provinces',
colors:['red','red']

});
}

asgallant

unread,
Nov 3, 2011, 9:43:11 AM11/3/11
to google-visua...@googlegroups.com
I don't think the charts are meant to be rendered without any data.  If you are concerned about numbers showing up in the tooltips, you can get around that by setting the formatted value of the data to an empty string, like this:

function drawVisualization({
    var data new google.visualization.DataTable();
    data.addRows(5);
    data.addColumn('string''State');
    data.addColumn('number''Number');
    data.addRow(['virginia'{v1f''}]);
    data.addRow(['Maryland'{v1f''}]);
    data.addRow(['District of Columbia'{v1f''}]);
    data.addRow(['California'{v1f''}]);
    data.addRow(['Texas'{v1f''}]);

    var geochart new google.visualization.GeoChart(document.getElementById('visualization'));

lcm133

unread,
Nov 3, 2011, 2:10:52 PM11/3/11
to Google Visualization API
Thanks for the tip. Unfortunately, even if you make the value null or
format it to be empty, you are still stuck with a : below the label.

asgallant

unread,
Nov 3, 2011, 2:52:04 PM11/3/11
to google-visua...@googlegroups.com
I wrote a hack using jQuery a while back that messes with the tooltips; you may be able to adopt it to your needs (removing the ':' etc): https://groups.google.com/d/msg/google-visualization-api/22N0T30LY3k/D9sSQXbFuTQJ

Reply all
Reply to author
Forward
0 new messages