I have a dataTable with several columns. I'm building a chart from a view of this dataTable. When an item from the legend of the chart is clicked I'd like to get the column of the underlying dataTable.
Code:
var score_select = google.visualization.events.addListener(score_chart, 'select', function(){
var chrt = score_chart.getChart().getSelection()[0].column;//I'm using a chartWrapper
var dt = score_chart.getDataTable().getColumnId(chrt);
var dt_check = score_chart.getDataTable().getNumberOfColumns();
alert(dt);
\\ alert(dt_check) returns proper number of columns
});
Problem:
The column number referred to by chrt
is equal to the column number of the view NOT the column number of the underlying dataTable. By this I mean, if the dataTable has 10 columns and the view of the dataTable used by score_chart
has only 2 columns chrt
will return either 1 or 2 regardless of what columns from the dataTable were used in the view. This is causing getColumnId(...) to return a column different from that which I would like.
Any advice would be a great help. Thanks