It is nominally possible to add data from multiple columns to the tooltip,
but GeoCharts don't yet have fully customizable tooltips. You can use a
DataView to join multiple columns together and present the chart with two
columns containing the country and the color value, with the color value
column formatted with the additional information. Something like this:
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, {...
On Wednesday, March 13, 2013 8:12:21 AM UTC-4, Torbjorn Zetterlund wrote:
>
> Hi,
>
> I have the following Table
>
> Office Total Staff # of IT staff # of HR staff # of Sales staff
> Belgium 53 15 13 14
> France 96 50 14 21
>
> My Code is
>
> <html>
> <head>
> <script type='text/javascript'
> src='https://www.google.com/jsapi'></script>
> <script type='text/javascript'>
> google.load('visualization', '1', {'packages': ['geochart']});
> google.setOnLoadCallback(drawMarkersMap);
>
> function drawMarkersMap() {
> var data = google.visualization.arrayToDataTable([
> ['Office', 'Total Staff', '# of IT Staff', '# of HR staff', '#of
> Sales staff'],
> ['Belgium', 53, 15, 13, 14
> ],
> ['France', 96, 50, 14, 21
> ],
> ]);
>
> var options = {
> region: 'IT',
> displayMode: 'markers',
> colorAxis: {colors: ['green', 'blue']}
> };
>
> var chart = new
> google.visualization.GeoChart(document.getElementById('chart_div'));
> chart.draw(data, options);
> };
> </script>
> </head>
> <body>
> <div id="chart_div"</div>
> </body>
> </html>
>
> See attached image on how the information is displayed with 3 columns, I
> additional columns to be displayed when hover over a country.
>
> Now when I add additional columns, I get an error saying - Incompatible
> data table: Error: Table contains more columns than expected (Expecting 3
> columns)
>
> I'm aware that there is a limitation to number of columns, what wonder is
> there a workaround to get more information to display in the box showing up
> when hover over a country?
>
> Torbjorn
>
>
>
>
>
>
>
>
>
>
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at
http://groups.google.com/group/google-visualization-api?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.