Highcharts in the full tooltip
I've been experimenting with adding highcharts to my map's
interactivity, but I've run in to a problem that has me stumped.
When I put the attached code in the full tooltip, the chart works
fine in the preview, but it doesn't render when I click on an item
in my interactivity layer, I just get a blank div. My best guess is
that this has something to do with the difference between how a
full page handles javascript and how it is handled (or isn't) when
it is part of the tooltip. Do you think that including this chart
in the full tooltip is possible, and if so, any ideas on what I'd
need to do to get it working?
Thanks!
Matthew
- bioenergychart.txt 2.7 KB
Comments are currently closed for this discussion. You can start a new one.
Support Staff 2 Posted by Will White on 31 Oct, 2011 02:35 AM
Hi Matthew,
Unfortunately, the attached code includes
<script>tags, which we can't support in tooltips for security purposes. It won't possible to generate them dynamically inside the tooltip. This is why we generally recommend the Google Charts API for embedded graphs.You can use highcharts directly by setting up a map on your site with Wax and overriding the
clickHandlerfunction of the interaction control. The customclickHandlerfunction you provide can set up and render the chart any way you wish.Let me know if that helps!
Will
3 Posted by Matthew Loveless on 31 Oct, 2011 02:32 PM
Will,
Thanks, that makes sense. I've been using the Google charts API to create static charts, but I wanted to try adding some interactivity to the full tooltip. Based on your response, I assume that http://code.google.com/apis/chart/ wouldn't work, either, right?
Do you know of any way, other than using a custom clickHandler, to add interactive charts to the full tooltip? Or is it possible to stick the custom clickHandler into a map's embed code?
Thanks!
Matthew
Support Staff 4 Posted by Will White on 31 Oct, 2011 05:38 PM
Hi Matthew,
Right, only the Google Charts Image API will work because it doesn't require JavaScript and
<script>tags. Unfortunately, there is no other way to embed JavaScript into MBTiles tooltips for security reasons. You must implement JavaScript behaviors on the application side.Will
5 Posted by Matthew Loveless on 31 Oct, 2011 10:16 PM
Makes sense, thanks!
Matthew Loveless closed this discussion on 31 Oct, 2011 10:16 PM.