Thanks, this looks better. I will try the dashboard on ready. I had the
idea that the events did not bubble up all time the way I had.
Peter
Op donderdag 12 april 2012 17:53:28 UTC+2 schreef asgallant het volgende:
>
> The 'select' events don't bubble up to the wrapper, you need to ping them
> off the charts built by the wrapper using the ChartWrapper#getChart method,
> like this (assumes that chart1 and chart2 are chart wrappers):
>
> // since event handlers for one chart require the other chart to be
> available,
> // we must wait for both wrappers' 'ready' events to fire
> var ready = {chart1: false, chart2: false};
>
> google.visualization.events.addListener(chart1, 'ready', function() {
> ready.chart1 = true;
> // whichever listener fires second should fire set up the 'select'
> event handlers
> if (ready.chart2) {
> createListeners();
> }
> });
> google.visualization.events.addListener(chart1, 'ready', function() {
> ready.chart2 = true;
> // whichever listener fires second should fire set up the 'select'
> event handlers
> if (ready.chart1) {
> createListeners();
> }
> });
>
> function createListeners () {
> google.visualization.events.addListener(chart1.getChart(), 'select',
> function() {
> chart2.getChart().setSelection(chart1.getChart().getSelection());
> });
> google.visualization.events.addListener(chart2.getChart(), 'select',
> function() {
> chart1.getChart().setSelection(chart2.getChart().getSelection());
> });
> }
>
> If your charts are reasonably fast to draw, it would actually be
> marginally better to draw the second chart from the 'ready' event handler
> of the first and then create the 'select' event handlers from the 'ready'
> event handler of the second wrapper. If you're drawing these as part of a
> Dashboard, then you can skip this cross-ready event handling code and
> create the 'select' event handlers from the Dashboard's 'ready' event
> handler.
>
> On Thursday, April 12, 2012 8:53:14 AM UTC-4, Peetzer wrote:
>>
>> I have two chartwrappers on a dashboard, one contains controlType
>> Linechart and the other Table.
>>
>> Why does the chartWrapper does not have the getSelection method?
>>
>> This is tucked away in the visualization...
>>
>> google.visualization.events.addListener(chart1, 'select', function() {
>> chart2.*visualization*.setSelection(chart1.*visualization*
>> .getSelection());
>> });
>>
>> google.visualization.events.addListener(chart2, 'select', function() {
>> chart1.*visualization*.setSelection(chart2.*visualization*
>> .getSelection());
>> });
>>
>
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-visualization-api/-/UlSfxnTRCZcJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-visualization-api?hl=en.