Add timer-based signals to Vega
See original GitHub issueOne of the constant asks I hear is how to do animations in Vega. Animations require timer-based event mechanism, so one solution is to add a signal that changes on timer. This issue is to discuss the best interface/approach. It doesn’t have to be implemented in core vega, but would be good to get everyone’s opinions.
Simple - name-based
This, somewhat hacky approach, allow addition of timers with the minimal Vega code changes. A Vega plugin could iterate over all signals, and if any signal names match /^timer_([0-9]+)$/
, automatically update signal’s value with the new Date()
object every (number) milliseconds. The timer can be paused/resumed by setting its value to truthy/falsy value.
signals: [{
"name": "timer_1000", // will be updated once a second
"value": true
}]
Complex - core support
Extend core event parsing mechanism to allow parameter passing. This approach might be more flexible in some cases, but also makes it harder to suspect/resume timer as needed.
signals: [{
"name": "myTimerSignal",
"on": [{"events": "timer(1000)", "update": "..."}]
}]
Issue Analytics
- State:
- Created 5 years ago
- Comments:15 (10 by maintainers)
Top GitHub Comments
I believe we could use this to implement games in Vega 😃
@domoritz good idea, but i think this shouldn’t be a core feature yet - maybe a plugin? Several reasons:
As for Hans Rosling viz - agree, I think I misunderstood @g3o2 to mean streaming data support, not (looped) time animation.