From 2e0ded9fd6e0f6cdece154744fc8c6fd9f6d9f81 Mon Sep 17 00:00:00 2001 From: Taras Novak Date: Sat, 12 Sep 2020 10:18:56 -0500 Subject: [PATCH] #111 update vega-lite v4.15.0 examples --- examples/arc_pie_pyramid.vl.json | 2 +- examples/connected_scatterplot.vl.json | 2 +- examples/geo_line.vl.json | 3 +- .../interactive_global_development.vl.json | 147 ++++++++++++++++++ ...naggregate_mean_difference_by_year.vl.json | 2 +- examples/stacked_bar_h_order_custom.vl.json | 2 +- 6 files changed, 152 insertions(+), 6 deletions(-) create mode 100644 examples/interactive_global_development.vl.json diff --git a/examples/arc_pie_pyramid.vl.json b/examples/arc_pie_pyramid.vl.json index 04a4909..bfe9209 100644 --- a/examples/arc_pie_pyramid.vl.json +++ b/examples/arc_pie_pyramid.vl.json @@ -30,7 +30,7 @@ } }, "order": { - "field": "order", "type": "quantitative" + "field": "order" } }, "view": {"stroke": null} diff --git a/examples/connected_scatterplot.vl.json b/examples/connected_scatterplot.vl.json index 9ea17d3..4778d70 100644 --- a/examples/connected_scatterplot.vl.json +++ b/examples/connected_scatterplot.vl.json @@ -11,6 +11,6 @@ "field": "gas", "type": "quantitative", "scale": {"zero": false} }, - "order": {"field": "year", "type": "temporal"} + "order": {"field": "year"} } } diff --git a/examples/geo_line.vl.json b/examples/geo_line.vl.json index f9c7025..e159e93 100644 --- a/examples/geo_line.vl.json +++ b/examples/geo_line.vl.json @@ -88,8 +88,7 @@ "type": "quantitative" }, "order": { - "field": "order", - "type": "ordinal" + "field": "order" } } } diff --git a/examples/interactive_global_development.vl.json b/examples/interactive_global_development.vl.json new file mode 100644 index 0000000..84cef60 --- /dev/null +++ b/examples/interactive_global_development.vl.json @@ -0,0 +1,147 @@ +{ + "$schema": "https://vega.github.io/schema/vega-lite/v4.json", + "description": "An interactive scatter plot of global health statistics by country and year.", + "data": {"url": "data/gapminder.json"}, + "width": 800, + "height": 500, + "layer": [ + { + "transform": [ + {"filter": {"field": "country", "equal": "Afghanistan"}}, + {"filter": {"selection": "year"}} + ], + "mark": { + "type": "text", + "fontSize": 100, + "x": 420, + "y": 250, + "opacity": 0.06 + }, + "encoding": {"text": {"field": "year"}} + }, + { + "transform": [ + { + "lookup": "cluster", + "from": { + "key": "id", + "fields": ["name"], + "data": { + "values": [ + {"id": 0, "name": "South Asia"}, + {"id": 1, "name": "Europe & Central Asia"}, + {"id": 2, "name": "Sub-Saharan Africa"}, + {"id": 3, "name": "America"}, + {"id": 4, "name": "East Asia & Pacific"}, + {"id": 5, "name": "Middle East & North Africa"} + ] + } + } + } + ], + "encoding": { + "x": { + "field": "fertility", + "type": "quantitative", + "scale": {"domain": [0, 9]}, + "axis": {"tickCount": 5, "title": "Fertility"} + }, + "y": { + "field": "life_expect", + "type": "quantitative", + "scale": {"domain": [20, 85]}, + "axis": {"tickCount": 5, "title": "Life Expectancy"} + } + }, + "layer": [ + { + "mark": { + "type": "line", + "size": 4, + "color": "lightgray", + "strokeCap": "round" + }, + "encoding": { + "detail": {"field": "country"}, + "order": {"field": "year"}, + "opacity": { + "condition": { + "test": { + "or": [{"selection": "hovered"}, {"selection": "clicked"}] + }, + "value": 0.8 + }, + "value": 0 + } + } + }, + { + "selection": { + "year": { + "type": "single", + "fields": ["year"], + "bind": { + "input": "range", + "min": 1955, + "max": 2005, + "step": 5, + "name": "Year" + }, + "init": {"year": 1955} + }, + "hovered": { + "type": "single", + "fields": ["country"], + "on": "mouseover", + "empty": "none" + }, + "clicked": {"type": "multi", "fields": ["country"], "empty": "none"} + }, + "transform": [{"filter": {"selection": "year"}}], + "mark": {"type": "circle", "size": 100, "opacity": 0.9}, + "encoding": {"color": {"field": "name", "title": "Region"}} + }, + { + "transform": [ + { + "filter": { + "and": [ + {"selection": "year"}, + {"or": [{"selection": "clicked"}, {"selection": "hovered"}]} + ] + } + } + ], + "mark": { + "type": "text", + "yOffset": -12, + "fontSize": 12, + "fontWeight": "bold" + }, + "encoding": { + "text": {"field": "country"}, + "color": {"field": "name", "title": "Region"} + } + }, + { + "transform": [ + {"filter": {"selection": "hovered"}}, + {"filter": {"not": {"selection": "year"}}} + ], + "layer": [ + { + "mark": { + "type": "text", + "yOffset": -12, + "fontSize": 12, + "color": "gray" + }, + "encoding": {"text": {"field": "year"}} + }, + {"mark": {"type": "circle", "color": "gray"}} + ] + } + ] + } + ] +} diff --git a/examples/joinaggregate_mean_difference_by_year.vl.json b/examples/joinaggregate_mean_difference_by_year.vl.json index 8da8d13..d17942a 100644 --- a/examples/joinaggregate_mean_difference_by_year.vl.json +++ b/examples/joinaggregate_mean_difference_by_year.vl.json @@ -6,7 +6,7 @@ }, "transform": [ {"filter": "datum['IMDB Rating'] != null"}, - {"timeUnit": "year", "field": "Release_Date", "as": "year"}, + {"timeUnit": "year", "field": "Release Date", "as": "year"}, { "joinaggregate": [{ "op": "mean", diff --git a/examples/stacked_bar_h_order_custom.vl.json b/examples/stacked_bar_h_order_custom.vl.json index 6abd602..e30cb4a 100644 --- a/examples/stacked_bar_h_order_custom.vl.json +++ b/examples/stacked_bar_h_order_custom.vl.json @@ -10,6 +10,6 @@ "x": {"aggregate": "sum", "field": "yield"}, "y": {"field": "variety"}, "color": {"field": "site"}, - "order": {"field": "siteOrder", "type": "quantitative"} + "order": {"field": "siteOrder"} } }