Closed FCalderon3006 closed 1 month ago
Thanks for your request. This is already possible using the alt.JupyterChart
method, see: https://altair-viz.github.io/user_guide/jupyter_chart.html#observing-selections. Closing this issue as it is not actionable. If you face any issues with the examples in the mentioned link, please raise a new issue.
Thanks again for this request!
What is your suggestion?
Hi Guys,
I have tried to assign a new value in a new column with the selected points in altair.chart but I was struggle on this. Anyone who can help me please? The idea is just select in the graph and the original source dataframe should update with a value for example "OUTLIER" only the selected points please. Maybe if was possible, any idea with another library ? The original code for select, from the library of Altair is this, this code selection and update a table, but doesnt allow to export in a new dataframe import altair as alt from vega_datasets import data
source = data.cars()
Brush for selection
brush = alt.selection_interval()
Scatter Plot
points = alt.Chart(source).mark_point().encode( x='Horsepower:Q', y='Miles_per_Gallon:Q', color=alt.condition(brush, alt.value('steelblue'), alt.value('grey')) ).add_params(brush)
Base chart for data tables
ranked_text = alt.Chart(source).mark_text(align='right').encode( y=alt.Y('row_number:O').axis(None) ).transform_filter( brush ).transform_window( row_number='row_number()' ).transform_filter( alt.datum.row_number < 15 )
Data Tables
horsepower = ranked_text.encode(text='Horsepower:N').properties( title=alt.Title(text='Horsepower', align='right') ) mpg = ranked_text.encode(text='Miles_per_Gallon:N').properties( title=alt.Title(text='MPG', align='right') ) origin = ranked_text.encode(text='Origin:N').properties( title=alt.Title(text='Origin', align='right') ) text = alt.hconcat(horsepower, mpg, origin) # Combine data tables
Build chart
alt.hconcat( points, text ).resolve_legend( color="independent" ).configure_view( stroke=None )
Have you considered any alternative solutions?
No response