Geochart simple enhancement request

157 views
Skip to first unread message

Ben

unread,
Nov 2, 2011, 5:59:20 PM11/2/11
to Google Visualization API
The request is simply to provide the showLegend option that the prior
Flash version provided. It might also be useful (in some cases) to
allow the absolute values to be hidden.

Here's my rational. I like the Geochart and use it both in the
traditional sense and in a non-traditional sense. Specifically, I use
it in a traditional sense to display a spread of values (mapped to the
min/max colors) but I also use it as a geo selector. In this case, I
use only two values, zero and one and map them to gray and red
respectively (so selectable geos show up as a dark grey and selected
geos show up in red). I then add a selection handler that toggles the
selection and also apply the selection through an outside filter
selector menu so the Geochart reflects/reenforces the current geo
filter selection even if it was selected using a different control.

This works very well aside from the tool tip and legend. I can live
with the tool tip which I use to suggest that the user can toggle a
selection but it also displays 0 or 1 which might be confusing. More
control over what is displayed in the tooltip would be welcome
though. However, The legend is more problematic since it also shows
the zero to one range and color range even though it's really a binary
choice (the gradient is confusing for min/max spread of one). To
avoid this, I'm currently applying a hack to hide the legend but
porting the showLegend option would be a welcome addition and a simple
fix. Either that or consider modifying the legend to switch to a non-
gradient version if the difference is one (not sure how that would
work esthetically though, haven't really tried to mock it up).

Thanks for the great products and support.

asgallant

unread,
Nov 3, 2011, 10:40:55 AM11/3/11
to google-visua...@googlegroups.com
There may be a hack around the legend if you can identify it in the chart's SVG with some degree of reliability.  The tooltips you can control by setting the formatted value of data points, which will be displayed instead of the numerical value.  If you don't want anything to show up, set the formatted value to an empty string.

I got this code to work using the GeoChart example on the visualization playground (requires jQuery):

google.visualization.events.addListener(geochart'ready'function ({
    $('#visualization').find('iframe').contents().find('svg').children('g').last().prev().remove();
});

This may or may not be reliable, as the playground chart is the only one I tested it on.  You should be able to tweak it to your own needs, though.

Ben

unread,
Nov 3, 2011, 3:22:13 PM11/3/11
to Google Visualization API
asgallant,

Thanks for the reply. I do have a reliable method (for now) of
identifying the rect element within the svg/vml element (remember,
this visualization falls back to vml for IE 7/8 so you have to check
for "g->rect" AND group->rect to cover supported browsers). I've
wrapped the visualization in a GWT class since it's not officially
available yet in GWT so I've done the work mostly within GWT/Java
rather than having to add the jQuery requirement (and additional
footprint). It's just that it's a hack that is sensitive to
structural changes within the svg/vml so a new release could break
it. I've also set it up so it falls back to a div that floats on top
to hide it but, since the addition of the min/max values, the mask div
covers up a portion of the tip of South America in order to
effectively hide the legend. Another more general solution would be
to provide a method within the API that reliably returns the element
so a user could have a variety of options (hide it all, hide the
numbers, manipulate the numbers, move it to another location, etc).

Thanks for the suggestion on the tooltip. That's a good workaround.

Marc Lucchini

unread,
Jun 1, 2012, 9:33:50 AM6/1/12
to google-visua...@googlegroups.com
I was looking for a better bypass but I have the impression that what I do is a bit more perennial and it seems to work well. Totally hides the legend for me.

visualization.setOption('legend', {
'textStyle': {'fontSize': 1}
});

Marc Lucchini

unread,
Jun 1, 2012, 9:36:31 AM6/1/12
to google-visua...@googlegroups.com
And legend back on:

visualization.setOption('legend', {
'textStyle': {'fontSize': 'inherited'}
});
Reply all
Reply to author
Forward
0 new messages