altair icon indicating copy to clipboard operation
altair copied to clipboard

Adapting Vega-Lite example "Bar Chart with Highlighting on Hover and Selection on Click"

Open ChristopherDavisUCI opened this issue 1 year ago • 5 comments

This is a follow-up to https://github.com/altair-viz/altair/discussions/3295

@mattijn Thanks for linking this Vega-Lite example which I didn't know existed.

In that example, condition seems to take an array, but I don't see any mention of that as an option in the condition documentation, nor does our code seem to allow using lists for a condition, as far as I can tell: https://github.com/altair-viz/altair/blob/d38409f8f50282d09507f90e490e65c0f0247b25/altair/vegalite/v5/api.py#L787-L796

Does that seem accurate to you? How would you suggest we approach that?

Needless to say, I'm happy for comments from anyone!

ChristopherDavisUCI avatar Dec 24 '23 13:12 ChristopherDavisUCI

Hi @ChristopherDavisUCI! This was discussed in this issue: https://github.com/altair-viz/altair/issues/2759.

It would be nice if we can extend and improve Altair by allowing for multiple predicates as part of a condition.

mattijn avatar Dec 24 '23 16:12 mattijn

Thanks @mattijn! Do you know anywhere that this array functionality is described on the Vega-Lite side?

ChristopherDavisUCI avatar Dec 24 '23 16:12 ChristopherDavisUCI

Is this page of help: https://vega.github.io/vega-lite/docs/condition.html?

mattijn avatar Dec 24 '23 16:12 mattijn

Not that I know of? I've tried searching that page for the word "array", and have skimmed through the examples and haven't seen anything that looks similar to the list/array usage in the Bar Chart example, but I could definitely believe that it's there and I'm missing it...

ChristopherDavisUCI avatar Dec 24 '23 16:12 ChristopherDavisUCI

You are right, it's not really clear from there. Maybe a bit from the Vega docs at this page: https://vega.github.io/vega/docs/marks/#encode. Scroll down to the section on Production Rules

mattijn avatar Dec 24 '23 17:12 mattijn