-
Notifications
You must be signed in to change notification settings - Fork 623
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: frame animations with time encoding and timer param (#8921)
This change implements basic features of [Animated Vega-Lite](https://vis.csail.mit.edu/pubs/animated-vega-lite/). With this change, users can create frame animations using a `time` encoding, a `timer` point selection, and a `filter` transform. This change does _not_ include more complex features e.g.: interpolation, custom predicates, rescale, interactive sliders, or data-driven pausing. - Adds a `time` encoding channel - Adds `isTimerSelection` function to check if a selection is an animation selections - Builds `_curr` animation dataset for `timer` selections to store the current animation frame - Adds animation signals to track the elapsed time (`anim_clock`), current animation value (`anim_value`), current position in the animation field's domain (`t_index`), etc. - When `time` encoding is present, updates associated marks' `from.data` to use the animation dataset (current frame). Relevant issue: #4060 Coauthor: @joshpoll ## Example specs Hop example: ```json { "$schema": "https://vega.github.io/schema/vega-lite/v5.json", "data": { "url": "data/seattle-weather.csv" }, "mark": "tick", "config": { "tick": { "thickness": 3 } }, "params": [ { "name": "date", "select": { "type": "point", "fields": [ "date" ], "on": "timer" } } ], "transform": [ { "filter": { "param": "date" } } ], "encoding": { "y": { "field": "precipitation", "type": "quantitative" }, "time": { "field": "date" } } } ``` Gapminder: ```json { "$schema": "https://vega.github.io/schema/vega-lite/v5.json", "data": { "url": "data/gapminder.json" }, "mark": "point", "params": [ { "name": "avl", "select": { "type": "point", "fields": [ "year" ], "on": "timer" } } ], "transform": [ { "filter": { "param": "avl" } } ], "encoding": { "color": { "field": "country" }, "x": { "field": "fertility", "type": "quantitative" }, "y": { "field": "life_expect", "type": "quantitative" }, "time": { "field": "year" } } } ``` --------- Co-authored-by: Josh Pollock <jopo@mit.edu> Co-authored-by: mattijn <mattijn@gmail.com>
- Loading branch information
1 parent
6839bd9
commit e3f9620
Showing
41 changed files
with
1,292 additions
and
69 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
{ | ||
"$schema": "https://vega.github.io/schema/vega-lite/v5.json", | ||
"data": { | ||
"url": "data/gapminder.json" | ||
}, | ||
"mark": "point", | ||
"params": [ | ||
{ | ||
"name": "animation_frame", | ||
"select": { | ||
"type": "point", | ||
"fields": [ | ||
"year" | ||
], | ||
"on": "timer" | ||
} | ||
} | ||
], | ||
"transform": [ | ||
{ | ||
"filter": { | ||
"param": "animation_frame" | ||
} | ||
} | ||
], | ||
"encoding": { | ||
"color": { | ||
"field": "country" | ||
}, | ||
"x": { | ||
"field": "fertility", | ||
"type": "quantitative" | ||
}, | ||
"y": { | ||
"field": "life_expect", | ||
"type": "quantitative" | ||
}, | ||
"time": { | ||
"field": "year", | ||
"type": "ordinal" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"$schema": "https://vega.github.io/schema/vega-lite/v5.json", | ||
"data": { | ||
"url": "data/seattle-weather.csv" | ||
}, | ||
"mark": "tick", | ||
"config": { | ||
"tick": { | ||
"thickness": 3 | ||
} | ||
}, | ||
"params": [ | ||
{ | ||
"name": "animation_frame", | ||
"select": { | ||
"type": "point", | ||
"fields": [ | ||
"date" | ||
], | ||
"on": "timer" | ||
} | ||
} | ||
], | ||
"transform": [ | ||
{ | ||
"filter": { | ||
"param": "animation_frame" | ||
} | ||
} | ||
], | ||
"encoding": { | ||
"y": { | ||
"field": "precipitation", | ||
"type": "quantitative" | ||
}, | ||
"time": { | ||
"field": "date", | ||
"type": "ordinal" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.