Skip to content

Commit

Permalink
fix: normalize selections across multi-views and selection emptiness (#…
Browse files Browse the repository at this point in the history
…7204)

* fix: normalize selections in views w/o selection definitions, and for conditional arrays

* fix: normalize selection emptiness

* chore: update examples [CI]

* fix: use null coalescing, and util functions for obj traversal

Co-authored-by: GitHub Actions Bot <vega-actions-bot@users.noreply.github.com>
  • Loading branch information
arvind and GitHub Actions Bot committed Feb 5, 2021
1 parent d8c61f5 commit a72ea91
Show file tree
Hide file tree
Showing 37 changed files with 573 additions and 379 deletions.
36 changes: 18 additions & 18 deletions examples/specs/normalized/airport_connections_normalized.vl.json
Expand Up @@ -18,6 +18,12 @@
{
"mark": {"type": "rule", "color": "#000", "opacity": 0.35},
"data": {"url": "data/flights-airport.csv"},
"encoding": {
"latitude": {"field": "latitude"},
"longitude": {"field": "longitude"},
"latitude2": {"field": "lat2"},
"longitude2": {"field": "lon2"}
},
"transform": [
{"filter": {"param": "org", "empty": false}},
{
Expand All @@ -38,29 +44,11 @@
"as": ["lat2", "lon2"]
}
],
"encoding": {
"latitude": {"field": "latitude"},
"longitude": {"field": "longitude"},
"latitude2": {"field": "lat2"},
"longitude2": {"field": "lon2"}
},
"projection": {"type": "albersUsa"}
},
{
"mark": {"type": "circle"},
"data": {"url": "data/flights-airport.csv"},
"transform": [
{"aggregate": [{"op": "count", "as": "routes"}], "groupby": ["origin"]},
{
"lookup": "origin",
"from": {
"data": {"url": "data/airports.csv"},
"key": "iata",
"fields": ["state", "latitude", "longitude"]
}
},
{"filter": "datum.state !== 'PR' && datum.state !== 'VI'"}
],
"params": [
{
"name": "org",
Expand All @@ -83,6 +71,18 @@
},
"order": {"field": "routes", "sort": "descending"}
},
"transform": [
{"aggregate": [{"op": "count", "as": "routes"}], "groupby": ["origin"]},
{
"lookup": "origin",
"from": {
"data": {"url": "data/airports.csv"},
"key": "iata",
"fields": ["state", "latitude", "longitude"]
}
},
{"filter": "datum.state !== 'PR' && datum.state !== 'VI'"}
],
"projection": {"type": "albersUsa"}
}
],
Expand Down
4 changes: 2 additions & 2 deletions examples/specs/normalized/area_horizon_normalized.vl.json
Expand Up @@ -50,7 +50,6 @@
}
},
{
"transform": [{"calculate": "datum.y - 50", "as": "ny"}],
"mark": {"type": "area", "clip": true, "orient": "vertical"},
"encoding": {
"x": {
Expand All @@ -65,7 +64,8 @@
"axis": {"title": "y"}
},
"opacity": {"value": 0.3}
}
},
"transform": [{"calculate": "datum.y - 50", "as": "ny"}]
}
],
"config": {"area": {"interpolate": "monotone"}}
Expand Down
@@ -1,11 +1,11 @@
{
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"data": {"url": "data/population.json"},
"config": {"view": {"stroke": "transparent"}, "axis": {"domainWidth": 1}},
"transform": [
{"filter": "datum.year == 2000"},
{"calculate": "datum.sex == 2 ? 'Female' : 'Male'", "as": "gender"}
],
"config": {"view": {"stroke": "transparent"}, "axis": {"domainWidth": 1}},
"spacing": {"row": 10},
"facet": {"row": {"field": "age"}},
"spec": {
Expand Down
2 changes: 1 addition & 1 deletion examples/specs/normalized/bar_grouped_normalized.vl.json
@@ -1,11 +1,11 @@
{
"$schema": "https://vega.github.io/schema/vega-lite/v4.json",
"data": {"url": "data/population.json"},
"config": {"view": {"stroke": "transparent"}, "axis": {"domainWidth": 1}},
"transform": [
{"filter": "datum.year == 2000"},
{"calculate": "datum.sex == 2 ? 'Female' : 'Male'", "as": "gender"}
],
"config": {"view": {"stroke": "transparent"}, "axis": {"domainWidth": 1}},
"spacing": {"column": 10},
"facet": {"column": {"field": "age", "type": "ordinal"}},
"spec": {
Expand Down
Expand Up @@ -63,12 +63,12 @@
}
},
{
"transform": [{"flatten": ["outliers"]}],
"mark": {"type": "point", "style": "boxplot-outliers"},
"encoding": {
"y": {"field": "Species", "type": "nominal", "title": null},
"x": {"field": "outliers", "type": "quantitative"}
}
},
"transform": [{"flatten": ["outliers"]}]
}
]
}
Expand Up @@ -139,7 +139,7 @@
"field": "to"
},
"shape": {
"condition": {"test": "datum.to > 0", "value": "triangle-right"},
"condition": {"value": "triangle-right", "test": "datum.to > 0"},
"value": "triangle-left"
}
}
Expand All @@ -151,15 +151,15 @@
"style": "arrow-label",
"text": ["Polestar", "More Valuable"]
},
"transform": [{"filter": "datum.label === 'PoleStar'"}],
"encoding": {
"x": {
"type": "quantitative",
"scale": {"zero": false},
"axis": null,
"field": "from"
}
}
},
"transform": [{"filter": "datum.label === 'PoleStar'"}]
},
{
"mark": {
Expand All @@ -168,15 +168,15 @@
"style": "arrow-label",
"text": ["Voyager / Voyager 2", "More Valuable"]
},
"transform": [{"filter": "datum.label !== 'PoleStar'"}],
"encoding": {
"x": {
"type": "quantitative",
"scale": {"zero": false},
"axis": null,
"field": "from"
}
}
},
"transform": [{"filter": "datum.label !== 'PoleStar'"}]
}
]
}
Expand Down
36 changes: 18 additions & 18 deletions examples/specs/normalized/geo_repeat_normalized.vl.json
Expand Up @@ -9,6 +9,12 @@
{
"width": 500,
"height": 300,
"projection": {"type": "albersUsa"},
"mark": "geoshape",
"encoding": {
"shape": {"field": "geo", "type": "geojson"},
"color": {"field": "population", "type": "quantitative"}
},
"transform": [
{
"lookup": "id",
Expand All @@ -22,17 +28,17 @@
"as": "geo"
}
],
"projection": {"type": "albersUsa"},
"mark": "geoshape",
"encoding": {
"shape": {"field": "geo", "type": "geojson"},
"color": {"field": "population", "type": "quantitative"}
},
"name": "child__row_population"
},
{
"width": 500,
"height": 300,
"projection": {"type": "albersUsa"},
"mark": "geoshape",
"encoding": {
"shape": {"field": "geo", "type": "geojson"},
"color": {"field": "engineers", "type": "quantitative"}
},
"transform": [
{
"lookup": "id",
Expand All @@ -46,17 +52,17 @@
"as": "geo"
}
],
"projection": {"type": "albersUsa"},
"mark": "geoshape",
"encoding": {
"shape": {"field": "geo", "type": "geojson"},
"color": {"field": "engineers", "type": "quantitative"}
},
"name": "child__row_engineers"
},
{
"width": 500,
"height": 300,
"projection": {"type": "albersUsa"},
"mark": "geoshape",
"encoding": {
"shape": {"field": "geo", "type": "geojson"},
"color": {"field": "hurricanes", "type": "quantitative"}
},
"transform": [
{
"lookup": "id",
Expand All @@ -70,12 +76,6 @@
"as": "geo"
}
],
"projection": {"type": "albersUsa"},
"mark": "geoshape",
"encoding": {
"shape": {"field": "geo", "type": "geojson"},
"color": {"field": "hurricanes", "type": "quantitative"}
},
"name": "child__row_hurricanes"
}
]
Expand Down
Expand Up @@ -13,8 +13,8 @@
}
},
{
"transform": [{"filter": {"param": "brush"}}],
"mark": {"type": "area", "color": "goldenrod"},
"transform": [{"filter": {"param": "brush"}}],
"encoding": {
"x": {"timeUnit": "yearmonth", "field": "date"},
"y": {"aggregate": "sum", "field": "count"}
Expand Down

0 comments on commit a72ea91

Please sign in to comment.