-
Notifications
You must be signed in to change notification settings - Fork 627
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
**This PR relies on the refactoring introduced by #4068, so please merge that one first.** This PR adds an `init` property to selection definitions to initialize them using the fields or encoding channels a selection is projected over. For example, here is an updated version of our `interactive_query_widgets` example that initializes the selection to select cars with 8 cylinders manufactured in 1971. ```json { "$schema": "https://vega.github.io/schema/vega-lite/v2.json", "description": "Drag the sliders to highlight points.", "data": {"url": "data/cars.json"}, "transform": [{"calculate": "year(datum.Year)", "as": "Year"}], "layer": [{ "selection": { "CylYr": { "type": "single", "fields": ["Cylinders", "Year"], "init": {"Cylinders": 4, "Year": 1977}, "bind": { "Cylinders": {"input": "range", "min": 3, "max": 8, "step": 1}, "Year": {"input": "range", "min": 1969, "max": 1981, "step": 1} } } }, "mark": "circle", "encoding": { "x": {"field": "Horsepower", "type": "quantitative"}, "y": {"field": "Miles_per_Gallon", "type": "quantitative"}, "color": { "condition": {"selection": "CylYr", "field": "Origin", "type": "nominal"}, "value": "grey" } } }, { "transform": [{"filter": {"selection": "CylYr"}}], "mark": "circle", "encoding": { "x": {"field": "Horsepower", "type": "quantitative"}, "y": {"field": "Miles_per_Gallon", "type": "quantitative"}, "color": {"field": "Origin", "type": "nominal"}, "size": {"value": 100} } }] } ``` Similarly, an updated `interactive_brush` example to initialize the brush selection is as follows: ```json { "$schema": "https://vega.github.io/schema/vega-lite/v2.json", "description": "Drag out a rectangular brush to highlight points.", "data": {"url": "data/cars.json"}, "selection": { "brush": { "type": "interval", "init": {"x": [55, 160], "y": [13, 37]} } }, "mark": "point", "encoding": { "x": {"field": "Horsepower", "type": "quantitative"}, "y": {"field": "Miles_per_Gallon", "type": "quantitative"}, "color": { "condition": {"selection": "brush", "field": "Cylinders", "type": "ordinal"}, "value": "grey" } } } ``` Fixes #3409, #3431, and vega/altair#599. /cc @jakevdp
- Loading branch information
Showing
89 changed files
with
1,223 additions
and
1,233 deletions.
There are no files selected for viewing
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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.