google-chart
google-chart copied to clipboard
Add a property `value` to expose the data specified in the `selection` property.
I am listening for the google-chart-select event, but it is passing back the raw chart object. Is there any way to grab the data from the selection?
I'm not sure what you mean. You can see exactly what you want (I believe) in the google-chart demo page. See the "area selection" demo. Or did you mean something else?
I meant like if you click a slice of the pie like in the "area selection" instead of getting the row, I would be able to get the actual data for the slice (i.e. Jan, 31(17.1%)).
I ended up finding the actual chart within the raw chart data and being able to get the data back. Inside my Polymer element:

Is this the proper way to do this?
I see your predicament. You should not be referencing those compiled properties (['J']['J']
). It's presumed you will access to the data specified for the chart.
e.g. (using the rows
property):
let chart = e.currentTarget;
chart.rows[chart.selection[0].row];
e.g. (using the data
property with a DataTable
):
let chart = this.$.myChart;
let value = chart.data.getValue(chart.selection[0].row, 0);
Selection is meant to mirror the selection property of the chart, however, perhaps exposing the actual value via value may be a good idea... My immediate thought about that is that there is probably a performance issue or otherwise a problem with different chart type's selection values... But I can take a look.