Search code examples
vega-lite

inconsistent selection filter behavior with brush vs select (click)


I have the same spec for the charts below, except for the selection

enter image description here

enter image description here

One with brush selection (editor, and one with click selection (editor)

As you can see, one has the orange and one has the blue---I only intend the orange colors to be used within a selection (e.g., a brush or a click). The second chart (with click) does what I wish, but the first (with brush) does not.

I'm not sure why selection vs. brush would have caused this difference.

Thanks so much for your help!


Solution

  • The difference is that your click selection specifies "empty": "none", while your brush selection does not.

    • "empty": "none" indicates that an empty selection should be treated as if it contains none of the points.
    • "empty": "all" (the default) indicates that an empty selection should be treated as if it contains all of the points.

    Add "empty": "none" to your brush selection, it will have the same behavior as your click selection. See Common Selection Properties in the docs for more details.