Search code examples
vega-litevega

Vega chart interactive crossfilter populate other charts on click of first


I am referring to the below example of vega chart.

https://vega.github.io/vega-lite/examples/interactive_layered_crossfilter.html

I want to have the functionality that when distance bar of the chart is clicked then delay and time gets loaded with respect to the value of distance.


Solution

  • You can do this by changing the interval selection to a single selection (view in editor):

    The only difference in the chart at that link is that I changed this:

    "selection": {
      "brush": {"type": "interval", "encodings": ["x"]}
    },
    

    to this:

    "selection": {
      "brush": {"type": "single", "encodings": ["x"]}
    },
    

    And now you can select single bars by clicking.