Re: GetChart() returns a chart from a different wrapper

113 views
Skip to first unread message

asgallant

unread,
Nov 5, 2012, 12:22:36 PM11/5/12
to google-visua...@googlegroups.com
Can you post a working example demonstrating the problem?

On Monday, November 5, 2012 4:56:46 AM UTC-5, Mozi wrote:
Hi

I'm having a strange issue with GetChart().

I have 4 chart wrappers on one page. Each chart wrapper has it's own var name and containerID. I've added a listener to each chart to catch when the user clicks on a specific column in a chart. 

Regardless of which chart the user clicks on, getChart().getSelection() always returns the data from the first chart. If I check the container ID, it returns the correct ID, but getChart() always seems to reference the first chart. Why? 

Below are 2 bits of code where I've setup a listener for the event. 
          google.visualization.events.addListener(chart, 'select', function () {
               var selection = chart.getChart().getSelection();
               var viewData = chart.getDataTable();
               GetErrorDetails(viewData.getValue(selection[0].row, 0), viewData.getColumnId(selection[0].column));
           });
 
           google.visualization.events.addListener(chartFirstTest, 'select', function () {
               var selection = chartFirstTest.getChart().getSelection();
               var viewData = chartFirstTest.getDataTable();
               GetErrorDetails(viewData.getValue(selection[0].row, 0), viewData.getColumnId(selection[0].column));
           });
Thanks for any help.
Reply all
Reply to author
Forward
0 new messages