0

In one of my view's layers I have

  "params": [
    {
      "name": "selectedFeature",
      "select": {
        "type": "point",
        "fields": ["order"]
      }
    }

I'm using vega-embed and added a signal listener.

vegaInstance.view.addSignalListener('selectedFeature', async function (signalName, e) {
    console.debug(signalName, JSON.stringify(e))
    // Returns e.g. 
    // selectedFeature {"order":[2],"vlPoint":{"or":[{"order":2}]}}
}

This works ok. But I would like to trigger the signal from outside of the chart too (without binding it to an element), like it is explained in the View API docs.

I tried things like

vegaInstance.view.signal('selectedFeature', {order: 2})

and

vegaInstance.view.signal('selectedFeature', {
    order: [2],
    vlPoint: {
        or: [{
            order: 2
        }]
    }
});

but no luck. The debug message log prints out

selectedFeature {}

meaning the signal name is being picked up, but not its value. What format should value be?

Mathieu Dhondt
  • 8,405
  • 5
  • 37
  • 58

2 Answers2

0

I solved it by adding a hidden input field and binding the param to that input field. I then trigger an input event on that input field.

Mathieu Dhondt
  • 8,405
  • 5
  • 37
  • 58
0

I solved the same issue by updating the selection with vegaInstance.view.signal('selectedFeature**_tuple**', {...}) instead of vegaInstance.view.signal('selectedFeature', {...}). Got that from here

maartenzam
  • 136
  • 1
  • 5