altair
altair copied to clipboard
Access to slider.value
It's been suggested in https://github.com/altair-viz/altair/pull/1599 and in here to provide easy/easier access to slider.value. Have you had a chance to tackle this?
Not having slider.value, I'm looking for alternatives. From https://altair-viz.github.io/user_guide/transform/filter.html#selection-predicates
Selection predicates can be used to filter data based on a selection. While these can be constructed directly using a SelectionPredicate class, in Altair it is often more convenient to construct them using the selection() function. For example, this chart uses a multi-selection that allows the user to click or shift-click on the bars in the bottom chart to select the data to be shown in the top chart
- Could you give an example of using
SelectionPredicateclass? - is it possible to use the selector value in chart title, e.g.
alt.Chart(df, title=f"points greater than {selector.value}")
- I don't think that class is used directly, rather you use
alt.selection_as in the documentation you linked - You can't have dynamic axis title/labels https://github.com/altair-viz/altair/issues/2011#issuecomment-597781332, but you could use
mark_textas a workaround similar to https://stackoverflow.com/questions/71210072/can-i-turn-altair-axis-titles-into-links/71210807#71210807.
Does this mean that a chart like one isn't possible with Altair?

https://vega.github.io/vega-lite-v4/docs/text.html#properties
That's from V4 but uses "params" in the chart spec which as far as I can tell was undocumented in V4.
Is there any way to manually add to the chart spec that Altair produces? Like:
chart = alt.Chart(...)
chart.hack_hack({"params": ...)
It will be in the upcoming Altair v5, sneak peak of docs of this example: https://joelostblom.github.io/altair-docs/user_guide/marks/text.html
Now, you can do chart.to_dict() to serialize it to a Vega-Lite specification that you can modify to your needs like a normal dictionary. But you won't be able to render it anymore in Altair v4.
OK cool, thanks!