Re: ChartRangeFilter and linechart

309 views
Skip to first unread message

asgallant

unread,
Aug 13, 2012, 4:35:34 PM8/13/12
to google-visua...@googlegroups.com
The row property of the event returns the row in the DataView used to draw the chart, which you can get by calling the chart wrapper's #getDataTable method.   The view then has a method #getTableRowIndex which translates the row index into the index of the DataTable/DataView that was used to draw the dashboard (typically this is your DataTable, but you could have a different setup).

google.visualization.events.addListener(chart.getChart()'onmouseover'function (e{
    var view chart.getDataTable();
    var tableRow view.getTableRowIndex(e.row);
    // do something with tableRow
});

On Monday, August 13, 2012 1:05:07 PM UTC-4, Luca Bulegato wrote:
Hi all,
I have some problem with changerangefilter and linechart or probably I am missing something,.
I am drawing a linechart with a ChartRangeFilter control.
I have a listner for onmouseover on the chart and when I pass the mouse over the chart i get the events with the overHandler(e) function.
Then I get the e.row element in order to get the row in the datatable "under" the chart.
This works great but when I change the range of the ChartRangeFilter the e.row value is about the point in the graph ..not in the datatable...

So in general How can i Get the right row in the datatable after a mouseover event in the chart ?

thanks a lot

asgallant

unread,
Aug 13, 2012, 5:18:05 PM8/13/12
to google-visua...@googlegroups.com
Incidentally, if you are just fetching data, you can use the view rather than translating back to the original DataTable, as long as the view has the columns you need.

Luca Bulegato

unread,
Aug 14, 2012, 5:13:41 AM8/14/12
to google-visua...@googlegroups.com
Thanks a lot this is what  I need !!

Is there a mirror method of view.getTableRowIndex which return the position in the graph from the tablerow index ?
This could be done in this way but I am wondering if there is a more beutiful way:

         var rows =   view.getViewRows();  
        for(var i =0 ;i< rows.length;i++)
        {
            if(tablerow_index == rows[i])
                {
                    chart_position = i;
                    break;
                }
        }

Thanka again

asgallant

unread,
Aug 14, 2012, 12:09:08 PM8/14/12
to google-visua...@googlegroups.com
There is the #getViewRowIndex method, which translates the row index from the underlying DataTable into the row's index in the view. 

Luca Bulegato

unread,
Aug 16, 2012, 3:23:43 AM8/16/12
to google-visua...@googlegroups.com
Thanks a lot
your help is veru useful !!

asgallant

unread,
Aug 16, 2012, 12:19:09 PM8/16/12
to google-visua...@googlegroups.com
You're welcome.
Reply all
Reply to author
Forward
0 new messages