Skip to content

Commit

Permalink
feat: top-level selections (#6919)
Browse files Browse the repository at this point in the history
* refactor: rename unit `selection` property to `params`.

* feat: define selections at the top-level spec

* feat: handle partial/nested paths for top-level selection `views`.

* chore: update schema [CI]

* chore: update examples [CI]

* fix: add Parameter to unit params type signature for schema validation.

* chore: update schema [CI]

* Add comment about separate code path for assembling selection signals.

Co-authored-by: GitHub Actions Bot <vega-actions-bot@users.noreply.github.com>
  • Loading branch information
arvind and GitHub Actions Bot committed Nov 16, 2020
1 parent 3018f51 commit 9299a83
Show file tree
Hide file tree
Showing 132 changed files with 929 additions and 245 deletions.
533 changes: 497 additions & 36 deletions build/vega-lite-schema.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion examples/specs/airport_connections.vl.json
Expand Up @@ -59,7 +59,7 @@
},
{"filter": "datum.state !== 'PR' && datum.state !== 'VI'"}
],
"selection": [{
"params": [{
"name": "org",
"select": {
"type": "single",
Expand Down
2 changes: 1 addition & 1 deletion examples/specs/bar_count_minimap.vl.json
Expand Up @@ -22,7 +22,7 @@
}, {
"height": 200,
"width": 50,
"selection": [{
"params": [{
"name": "brush",
"select": {
"type": "interval",
Expand Down
2 changes: 1 addition & 1 deletion examples/specs/brush_table.vl.json
Expand Up @@ -6,7 +6,7 @@
"window": [{"op": "row_number", "as": "row_number"}]
}],
"hconcat": [{
"selection": [{"name": "brush", "select": "interval"}],
"params": [{"name": "brush", "select": "interval"}],
"mark": "point",
"encoding": {
"x": {"field": "Horsepower", "type": "quantitative"},
Expand Down
2 changes: 1 addition & 1 deletion examples/specs/circle_bubble_health_income.vl.json
Expand Up @@ -5,7 +5,7 @@
"data": {
"url": "data/gapminder-health-income.csv"
},
"selection": [{
"params": [{
"name": "view",
"select": "interval",
"bind": "scales"
Expand Down
2 changes: 1 addition & 1 deletion examples/specs/concat_bar_layer_circle.vl.json
Expand Up @@ -46,7 +46,7 @@
"width": 330,
"height": 120,
"mark": "bar",
"selection": [{
"params": [{
"name": "pts",
"select": {"type": "single", "encodings": ["x"]}
}],
Expand Down
4 changes: 2 additions & 2 deletions examples/specs/concat_hover.vl.json
Expand Up @@ -3,7 +3,7 @@
"description": "Drag out a rectangular brush to highlight points.",
"data": {"url": "data/cars.json"},
"hconcat": [{
"selection": [{
"params": [{
"name": "hover",
"select": {
"type": "single",
Expand All @@ -21,7 +21,7 @@
}
}
},{
"selection": [{
"params": [{
"name": "hover",
"select": {
"type": "single",
Expand Down
4 changes: 2 additions & 2 deletions examples/specs/concat_hover_filter.vl.json
Expand Up @@ -9,7 +9,7 @@
},
"layer": [
{
"selection": [{
"params": [{
"name": "hover",
"select": {
"type": "single",
Expand All @@ -32,7 +32,7 @@
"layer": [
{

"selection": [{
"params": [{
"name": "hover",
"select": {
"type": "single",
Expand Down
2 changes: 1 addition & 1 deletion examples/specs/interactive_area_brush.vl.json
Expand Up @@ -6,7 +6,7 @@
"y": {"aggregate": "sum", "field": "count"}
},
"layer": [{
"selection": [{
"params": [{
"name": "brush",
"select": {"type": "interval", "encodings": ["x"]}
}],
Expand Down
2 changes: 1 addition & 1 deletion examples/specs/interactive_bar_select_highlight.vl.json
Expand Up @@ -8,7 +8,7 @@
{"a": "G", "b": 19}, {"a": "H", "b": 87}, {"a": "I", "b": 52}
]
},
"selection": [
"params": [
{
"name": "highlight",
"select": {
Expand Down
2 changes: 1 addition & 1 deletion examples/specs/interactive_bin_extent.vl.json
Expand Up @@ -8,7 +8,7 @@
"vconcat": [{
"width": 963,
"height": 100,
"selection": [{
"params": [{
"name": "brush",
"select": {"type": "interval", "encodings": ["x"]}
}],
Expand Down
2 changes: 1 addition & 1 deletion examples/specs/interactive_brush.vl.json
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"description": "Drag out a rectangular brush to highlight points.",
"data": {"url": "data/cars.json"},
"selection": [{
"params": [{
"name": "brush",
"select": "interval",
"value": {"x": [55, 160], "y": [13, 37]}
Expand Down
2 changes: 1 addition & 1 deletion examples/specs/interactive_concat_layer.vl.json
Expand Up @@ -51,7 +51,7 @@
"width": 330,
"height": 120,
"mark": "bar",
"selection": [{
"params": [{
"name": "pts",
"select": {"type": "single", "encodings": ["x"]}
}],
Expand Down
6 changes: 3 additions & 3 deletions examples/specs/interactive_dashboard_europe_pop.vl.json
Expand Up @@ -308,7 +308,7 @@
{
"mark": "bar",
"height": 700,
"selection": [{
"params": [{
"name": "brush",
"select": {"type": "interval", "encodings": ["y"]}
}],
Expand All @@ -331,7 +331,7 @@
{
"mark": "bar",
"height": 700,
"selection": [{
"params": [{
"name": "brush",
"select": {"type": "interval", "encodings": ["y"]}
}],
Expand All @@ -355,7 +355,7 @@
"mark": "point",
"width": 260,
"height": 260,
"selection": [{"name": "brush", "select": "interval"}],
"params": [{"name": "brush", "select": "interval"}],
"encoding": {
"y": {
"field": "Population_ages_15_64_of_total",
Expand Down
2 changes: 1 addition & 1 deletion examples/specs/interactive_global_development.vl.json
Expand Up @@ -76,7 +76,7 @@
}
},
{
"selection": [
"params": [
{
"name": "year",
"value": {"year": 1955},
Expand Down
2 changes: 1 addition & 1 deletion examples/specs/interactive_index_chart.vl.json
Expand Up @@ -8,7 +8,7 @@
"height": 300,
"layer": [
{
"selection": [{
"params": [{
"name": "index",
"value": {"x": {"year": 2005, "month": 1, "date": 1}},
"select": {
Expand Down
2 changes: 1 addition & 1 deletion examples/specs/interactive_layered_crossfilter.vl.json
Expand Up @@ -8,7 +8,7 @@
"repeat": {"column": ["distance", "delay", "time"]},
"spec": {
"layer": [{
"selection": [{
"params": [{
"name": "brush",
"select": {"type": "interval", "encodings": ["x"]}
}],
Expand Down
Expand Up @@ -8,7 +8,7 @@
"repeat": {"column": ["distance", "delay", "time"]},
"spec": {
"layer": [{
"selection": [{
"params": [{
"name": "brush",
"select": {"type": "multi", "encodings": ["x"]}
}],
Expand Down
2 changes: 1 addition & 1 deletion examples/specs/interactive_legend.vl.json
Expand Up @@ -3,7 +3,7 @@
"width": 300, "height": 200,
"data": {"url": "data/unemployment-across-industries.json"},
"mark": "area",
"selection": [{
"params": [{
"name": "industry",
"select": {"type": "multi", "fields": ["series"]},
"bind": "legend"
Expand Down
2 changes: 1 addition & 1 deletion examples/specs/interactive_legend_dblclick.vl.json
Expand Up @@ -3,7 +3,7 @@
"width": 300, "height": 200,
"data": {"url": "data/unemployment-across-industries.json"},
"mark": "area",
"selection": [{
"params": [{
"name": "industry",
"select": {"type": "multi", "fields": ["series"]},
"bind": {"legend": "dblclick"}
Expand Down
2 changes: 1 addition & 1 deletion examples/specs/interactive_line_brush_cursor.vl.json
Expand Up @@ -17,7 +17,7 @@
"type": "quantitative"
}
},
"selection": [{
"params": [{
"name": "brush",
"select": {
"type": "interval",
Expand Down
2 changes: 1 addition & 1 deletion examples/specs/interactive_line_hover.vl.json
Expand Up @@ -25,7 +25,7 @@
},
"layer": [{
"description": "transparent layer to make it easier to trigger selection",
"selection": [{
"params": [{
"name": "hover",
"value": {"symbol": "AAPL"},
"select": {
Expand Down
2 changes: 1 addition & 1 deletion examples/specs/interactive_multi_line_label.vl.json
Expand Up @@ -15,7 +15,7 @@
"layer": [
{"mark": "line"},
{
"selection": [{
"params": [{
"name": "label",
"select": {
"type": "single",
Expand Down
Expand Up @@ -31,7 +31,7 @@
{"field": "MSFT", "type": "quantitative"}
]
},
"selection": [{
"params": [{
"name": "hover",
"select": {
"type": "single",
Expand Down
2 changes: 1 addition & 1 deletion examples/specs/interactive_multi_line_tooltip.vl.json
Expand Up @@ -21,7 +21,7 @@
}
}, {
"mark": "rule",
"selection": [{
"params": [{
"name": "hover",
"select": {"type": "single", "on": "mouseover", "empty": "none"}
}],
Expand Down
2 changes: 1 addition & 1 deletion examples/specs/interactive_overview_detail.vl.json
Expand Up @@ -17,7 +17,7 @@
"width": 480,
"height": 60,
"mark": "area",
"selection": [{
"params": [{
"name": "brush",
"select": {"type": "interval", "encodings": ["x"]}
}],
Expand Down
2 changes: 1 addition & 1 deletion examples/specs/interactive_paintbrush.vl.json
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"description": "Select multiple points with the shift key.",
"data": {"url": "data/cars.json"},
"selection": [{
"params": [{
"name": "paintbrush",
"select": {"type": "multi", "on": "mouseover", "nearest": true}
}],
Expand Down
2 changes: 1 addition & 1 deletion examples/specs/interactive_paintbrush_color.vl.json
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"description": "Select multiple points with the shift key.",
"data": {"url": "data/cars.json"},
"selection": [{
"params": [{
"name": "paintbrush",
"select": {
"type": "multi",
Expand Down
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"description": "Select multiple points with the shift key.",
"data": {"url": "data/cars.json"},
"selection": [{
"params": [{
"name": "paintbrush",
"select": {
"type": "multi",
Expand Down
2 changes: 1 addition & 1 deletion examples/specs/interactive_paintbrush_interval.vl.json
Expand Up @@ -2,7 +2,7 @@
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"description": "Select multiple points by dragging an interval.",
"data": {"url": "data/cars.json"},
"selection": [{"name": "paintbrush", "select": "interval"}],
"params": [{"name": "paintbrush", "select": "interval"}],
"mark": "point",
"encoding": {
"x": {"field": "Horsepower", "type": "quantitative"},
Expand Down
2 changes: 1 addition & 1 deletion examples/specs/interactive_paintbrush_simple_all.vl.json
@@ -1,7 +1,7 @@
{
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"data": {"url": "data/cars.json"},
"selection": [{
"params": [{
"name": "paintbrush",
"select": {"type": "multi", "on": "mouseover", "empty": "all"}
}],
Expand Down
2 changes: 1 addition & 1 deletion examples/specs/interactive_paintbrush_simple_none.vl.json
@@ -1,7 +1,7 @@
{
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"data": {"url": "data/cars.json"},
"selection": [{
"params": [{
"name": "paintbrush",
"select": {"type": "multi", "on": "mouseover", "empty": "none"}
}],
Expand Down
2 changes: 1 addition & 1 deletion examples/specs/interactive_panzoom_splom.vl.json
Expand Up @@ -6,7 +6,7 @@
"column": ["Miles_per_Gallon", "Acceleration", "Horsepower"]
},
"spec": {
"selection": [{
"params": [{
"name": "grid",
"select": "interval",
"bind": "scales"
Expand Down
2 changes: 1 addition & 1 deletion examples/specs/interactive_panzoom_vconcat_shared.vl.json
Expand Up @@ -3,7 +3,7 @@
"data": {"url": "data/cars.json"},
"vconcat": [
{
"selection": [{
"params": [{
"name": "region",
"select": "interval",
"bind": "scales"
Expand Down
2 changes: 1 addition & 1 deletion examples/specs/interactive_query_widgets.vl.json
Expand Up @@ -4,7 +4,7 @@
"data": {"url": "data/cars.json"},
"transform": [{"calculate": "year(datum.Year)", "as": "Year"}],
"layer": [{
"selection": [{
"params": [{
"name": "CylYr",
"value": {"Cylinders": 4, "Year": 1977},
"select": {"type": "single", "fields": ["Cylinders", "Year"]},
Expand Down
4 changes: 2 additions & 2 deletions examples/specs/interactive_seattle_weather.vl.json
Expand Up @@ -42,7 +42,7 @@
"width": 600,
"height": 300,
"mark": "point",
"selection": [{
"params": [{
"name": "brush",
"select": {"type": "interval", "encodings": ["x"]}
}],
Expand All @@ -66,7 +66,7 @@
},
"width": 600,
"mark": "bar",
"selection": [{
"params": [{
"name": "click",
"select": {"type": "multi", "encodings": ["color"]}
}],
Expand Down
2 changes: 1 addition & 1 deletion examples/specs/interactive_splom.vl.json
Expand Up @@ -7,7 +7,7 @@
"spec": {
"data": {"url": "data/cars.json"},
"mark": "point",
"selection": [
"params": [
{
"name": "brush",
"select": {
Expand Down
2 changes: 1 addition & 1 deletion examples/specs/interactive_stocks_nearest_index.vl.json
Expand Up @@ -15,7 +15,7 @@
}
},
{
"selection": [{
"params": [{
"name": "index",
"select": {
"type": "single",
Expand Down
2 changes: 1 addition & 1 deletion examples/specs/isotype_grid.vl.json
Expand Up @@ -124,5 +124,5 @@
},
"size": {"value": 90}
},
"selection": [{"name": "highlight", "select": "interval"}]
"params": [{"name": "highlight", "select": "interval"}]
}
Expand Up @@ -61,7 +61,7 @@
},
{"filter": "datum.state !== 'PR' && datum.state !== 'VI'"}
],
"selection": [
"params": [
{
"name": "org",
"select": {
Expand Down

0 comments on commit 9299a83

Please sign in to comment.