Altair: selection: getting selected data

Created on 4 Oct 2018  Â·  4Comments  Â·  Source: altair-viz/altair

Is there a way, given a selection to give back the selected data as a dataframe for example?

question

Most helpful comment

Yes, it would be nice, and no, there is still no way to do this, because the selection happens in the Javascript layer and there is no mechanism for the Javascript to communicate back to Python. Enabling this would require changes to Altair, vega-embed, the vega IPython extension, and the vega Jupyter extension. I don't know of anybody working on this – if it's important to you, you might consider exploring what it would take.

All 4 comments

I've never seen that in Altair but perhaps Jake knows a way. Something similar might be to have the selection displayed as a table (like a heat map but with text marks in the cells), but I know this is not exactly what you are asking.

sort of like this after a selection

No, there's no easy way to do that at the moment.

If you write a custom javascript frontend, it is theoretically possible via the vega view api, but I don't know of any example of that.

Making this easier is on the Vega-Lite roadmap, and once it's developed there we can think about how to support it from the Python side.

It would be nice to use the altair chart as a way to let user select input for some other part of code.

Currently I am using streamlit and such a usecase is coming up but I cannot really do anything about it.

Yes, it would be nice, and no, there is still no way to do this, because the selection happens in the Javascript layer and there is no mechanism for the Javascript to communicate back to Python. Enabling this would require changes to Altair, vega-embed, the vega IPython extension, and the vega Jupyter extension. I don't know of anybody working on this – if it's important to you, you might consider exploring what it would take.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

LukeMathWalker picture LukeMathWalker  Â·  3Comments

galloramiro picture galloramiro  Â·  3Comments

morberg picture morberg  Â·  3Comments

mroswell picture mroswell  Â·  4Comments

floringogianu picture floringogianu  Â·  3Comments