Created
December 24, 2023 23:22
-
-
Save PBI-DataVizzle/bf7acb650dbe8f9d5299b026fe794df2 to your computer and use it in GitHub Desktop.
dumbell_vl
This file contains hidden or 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
| { | |
| "$schema": "https://vega.github.io/schema/vega-lite/v5.json", | |
| "description": "A ranged dot plot that uses 'layer' to convey changing life expectancy for the five most populous countries (between 1955 and 2000).", | |
| "data": { | |
| "values": [ | |
| {"country": "China", "year": 1955, "life_expect": 41}, | |
| {"country": "China", "year": 2000, "life_expect": 72}, | |
| {"country": "India", "year": 1955, "life_expect": 37}, | |
| {"country": "India", "year": 2000, "life_expect": 62}, | |
| {"country": "United States", "year": 1955, "life_expect": 68}, | |
| {"country": "United States", "year": 2000, "life_expect": 77}, | |
| {"country": "Indonesia", "year": 1955, "life_expect": 35}, | |
| {"country": "Indonesia", "year": 2000, "life_expect": 68}, | |
| {"country": "Brazil", "year": 1955, "life_expect": 50}, | |
| {"country": "Brazil", "year": 2000, "life_expect": 71} | |
| ] | |
| }, | |
| "transform": [{"filter": {"field": "year", "oneOf": [1955, 2000]}}], | |
| "encoding": { | |
| "x": { | |
| "field": "life_expect", | |
| "type": "quantitative", | |
| "title": "Life Expectancy (years)" | |
| }, | |
| "y": { | |
| "field": "country", | |
| "type": "nominal", | |
| "title": "Country", | |
| "axis": {"offset": 5, "ticks": false, "minExtent": 70, "domain": false} | |
| } | |
| }, | |
| "layer": [ | |
| { | |
| "mark": "line", | |
| "encoding": { | |
| "detail": {"field": "country", "type": "nominal"}, | |
| "color": {"value": "#db646f"} | |
| } | |
| }, | |
| { | |
| "mark": {"type": "point", "filled": true}, | |
| "encoding": { | |
| "color": { | |
| "field": "year", | |
| "type": "ordinal", | |
| "scale": {"domain": [1955, 2000], "range": ["#e6959c", "#911a24"]}, | |
| "legend": {"title": "Year", "orient": "right", "offset": 10} | |
| }, | |
| "size": {"value": 100}, | |
| "opacity": {"value": 1} | |
| } | |
| } | |
| ], | |
| "config": {"view": {"stroke": "transparent"}, "axis": {"domainWidth": 1}} | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment