Feature request: set signals from props
It would be useful to be able to set signal values from props, before the first draw.
Currently I'm doing this in onNewView, which isn't too efficient as I have to draw the vega plot twice.
I'm very much interested in this functionality as well.
Thanks for suggesting. I'm trying to define the expected behavior before making any change. Would the signal get passed again if the spec change and the chart has to re-initialized?
Hmm... having trouble seeing through all the implications here without having a deeper understanding of the state-model. Could you flesh out some of the implications one way or the other?
Any update on this? The behavior I am imagining is that the signal prop only updates (if we are talking about initial values of signals here) when the view is initialized / react-vega component is re-rendered for a spec-change.
@tehsenaus the way I am doing this without re-drawing the viz as of right now is setting fields in the data prop with the value of the signal I'd like to initialize, and setting the those signals in the spec like
{
"name": "my_signal",
"update": "data(\"my_signal_data\")[0].data"
},
Of course this only works if you are able to set their initial values through update as opposed to value, though a solution to problems dealing with initializing signal values with an expression seems to be in the works.
On second thought, I think a better default behavior is to have the signals update as the signal props change, not just on initialization. The feature that the Vega folks are working on (linked in my previous comment) will still allow the initialization of signals through an expression, but this would be a useful feature in order to allow signals to be set (on init and update) through react props.