google / google-visualization-issues

288 stars 35 forks source link

Bug: ChartWrapper::getChart() returns always null with AnnotationChart #1493

Open orwant opened 9 years ago

orwant commented 9 years ago
What steps will reproduce the problem? Please provide a link to a
demonstration page if at all possible, or attach code.
1.See attached file
2.
3.

What component is this issue related to (PieChart, LineChart, DataTable,
Query, etc)?
AnnotationChart via ChartWrapper

Are you using the test environment (version 1.1)?
(If you are not sure, answer NO)
YES

What operating system and browser are you using?
Chrome

*********************************************************
For developers viewing this issue: please click the 'star' icon to be
notified of future changes, and to let us know how many of you are
interested in seeing it resolved.
*********************************************************

Original issue reported on code.google.com by pascal@clickndecide.eu on 2014-02-21 15:03:57


orwant commented 9 years ago
This behavior is what happens with all chart wrappers.  You have to draw the chartwrapper
which draws the chart, and then wait for the ready event from the chartwrapper so you
can call getChart().  Like so:

        chartWrapper.draw();
        var chart = chartWrapper.getChart();

        google.visualization.events.addListener(chartWrapper, 'ready',
          function () {
            alert('wrapper.getChart(): ' + chart);
          });

However, the AnnotationChart currently doesn't support any of the events it should.
 This will be fixed in the near future.  I'll leave this bug up to remind me.

Original issue reported on code.google.com by dlaliberte@google.com on 2014-03-03 21:41:23

orwant commented 9 years ago
Sorry. I wrote that wrong.  The getChart() call should be inside the event listener.

        chartWrapper.draw();

        google.visualization.events.addListener(chartWrapper, 'ready',
          function () {
            var chart = chartWrapper.getChart();
            alert('wrapper.getChart(): ' + chart);
          });

Original issue reported on code.google.com by dlaliberte@google.com on 2014-03-03 22:02:21

orwant commented 9 years ago
Thanks for your solution,

But in the attached sample, no ready event is sent.

Cdlt,

Pascal Jubeaux

Original issue reported on code.google.com by pascal@clickndecide.eu on 2014-03-05 10:28:16