google-chart icon indicating copy to clipboard operation
google-chart copied to clipboard

Add a property `value` to expose the data specified in the `selection` property.

Open ahrobinson opened this issue 8 years ago • 3 comments

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?

ahrobinson avatar Sep 23 '16 21:09 ahrobinson

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?

wesalvaro avatar Oct 08 '16 03:10 wesalvaro

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:

scrshot

Is this the proper way to do this?

ahrobinson avatar Oct 10 '16 15:10 ahrobinson

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.

wesalvaro avatar Oct 11 '16 05:10 wesalvaro