Re: How can I click on my small chart to open a web page (bigger chart)

31 views
Skip to first unread message

asgallant

unread,
Sep 12, 2012, 6:51:56 PM9/12/12
to google-visua...@googlegroups.com
How you go about it depends on whether or not you have set the "forceIFrame" option to false or not (currently defaults to true, will soon default to false) - setting it to true renders the charts in an iFrame, false without the iFrame (in all browsers other than IE < 9).  If you have not set the forceIFrame option to false, then use this:

google.visualization.events.addListener(chart'ready'function ({
    if ($.browser.msie && $.browser.version 9{
        $('#chart_div').find('iframe').contents().find('group').click(function ({
            alert('test');
        });
    }
    else {
        $('#chart_div').find('iframe').contents().find('svg').click(function ({
            alert('test');
        });
    }
}); 

if you have set it to false, then use this:

google.visualization.events.addListener(chart'ready'function ({
    if ($.browser.msie && $.browser.version 9{
        $('#chart_div').find('iframe').contents().find('group').click(function ({
            alert('test');
        });
    }
    else {
        $('#chart_div').find('svg').click(function ({
            alert('test');
        });
    }
}); 

The latter case is recommended, as the default value of the option will change soon anyway.

On Wednesday, September 12, 2012 5:47:48 PM UTC-4, Nate Sanden wrote:
I tried jquery:

    $('#dan_basic_chart_1').click(function () {
       alert('test');
    });

but alert is not firing.

I see a 'select' event but from what I understand that only works when I click a data point, bar or line, etc in a chart.

Nate Sanden

unread,
Sep 12, 2012, 7:57:49 PM9/12/12
to google-visua...@googlegroups.com
Amazing answer, thanks, works perfectly.

Nate

asgallant

unread,
Sep 13, 2012, 12:41:15 AM9/13/12
to google-visua...@googlegroups.com
You're welcome.
Reply all
Reply to author
Forward
0 new messages