Skip to content

Instantly share code, notes, and snippets.

@ties
Last active December 18, 2022 22:57
Show Gist options
  • Save ties/b1c0dec259d317d7e6eb772cdf2520f0 to your computer and use it in GitHub Desktop.
Save ties/b1c0dec259d317d7e6eb772cdf2520f0 to your computer and use it in GitHub Desktop.
{
"$schema": "https://vega.github.io/schema/vega-lite/v2.json",
"description": "A scatterplot template with URL.",
"data": {"url": "https://gist.githubusercontent.com/ties/ddfedd35f9b34c23a8c2ffb9d7a83d4d/raw/7d5de711ff35cb1fdaefeba9055380b1209432c9/life_expectancy_income_population.json"},
"mark": "point",
"encoding": {
"x": {"field": "corrected_income","type": "quantitative"},
"y": {"field": "population","type": "quantitative"}
}
}
{
"$schema": "https://vega.github.io/schema/vega-lite/v2.1.json",
"vconcat": [
{
"width": 500,
"height": 300,
"layer": [
{
"data": {
"url": "https://raw.githubusercontent.com/ties/cbs_gebiedsindelingen_topojson/master/Buurt_2014_layer_q1e3.json",
"format": {"type": "topojson", "feature": "layer"}
},
"transform": [{"filter": "substring(datum.id, 0, 6) == 'BU0153'"}],
"projection": {"type": "mercator", "center": [52.2215, 6.8937]},
"mark": {"type": "geoshape", "fill": "lightgray", "stroke": "white"}
},
{
"data": {
"url": "https://gist.githubusercontent.com/ties/d1b86c2a17b7c9f7105212080011d611/raw/f7e3b5255df478f7eb7e53c2c86e253d44a7a64c/openbare_ruimte_enschede.json"
},
"projection": {"type": "mercator", "center": [52.2215, 6.8937]},
"transform": [
{"filter": {"selection": "brush"}}
],
"mark": "circle",
"encoding": {
"longitude": {"field": "lon", "type": "quantitative"},
"latitude": {"field": "lat", "type": "quantitative"},
"color": {"field": "categorie", "type": "nominal"}
}
}
]
},
{
"width": 500,
"selection": {
"brush": {"type": "interval", "encodings": ["x"]}
},
"data": {
"url": "https://gist.githubusercontent.com/ties/d1b86c2a17b7c9f7105212080011d611/raw/f7e3b5255df478f7eb7e53c2c86e253d44a7a64c/openbare_ruimte_enschede.json"
},
"mark": "area",
"encoding": {
"x": {"field": "begindatum", "type": "temporal", "timeUnit": "yearmonthdate"},
"y": {"field": "categorie", "aggregate": "count"}
}
}
]
}
{
"$schema": "https://vega.github.io/schema/vega-lite/v2.1.json",
"data": {
"url": "data/us-10m.json",
"format": {"type": "topojson", "feature": "counties"}
},
"transform": [
{
"lookup": "id",
"from": {
"data": {
"url": "https://gist.githubusercontent.com/ties/fb0f28c3608ec6c1e02579de3132b26a/raw/b68ed5cd39bd9b1cd968422cd8ac733c3993acc5/pres_unemploy_income.json",
"format": {"type": "json"}
},
"key": "id",
"fields": [
"Unemployment_rate_2016",
"Median_Household_Income_2016",
"per_dem",
"per_gop",
"Civilian_labor_force_2016"
]
}
},
{"calculate": "datum.per_dem - datum.per_gop", "as": "win_perc"}
],
"vconcat": [
{
"projection": {"type": "albersUsa"},
"mark": "geoshape",
"encoding": {
"color": {
"condition": {
"selection": "brush",
"field": "win_perc",
"type": "quantitative",
"scale": {
"domain": [-1, 0, 1],
"range": ["#ff0000", "#ffffff", "#0000ff"]
}
},
"value": "grey"
}
},
"width": 500,
"height": 300
},
{
"width": 500,
"height": 300,
"selection": {"brush": {"type": "interval"}},
"mark": "point",
"encoding": {
"x": {"field": "Unemployment_rate_2016", "type": "quantitative"},
"y": {"field": "Median_Household_Income_2016", "type": "quantitative"},
"color": {
"condition": {
"selection": "brush",
"type": "quantitative"
},
"value": "grey"
},
"size": {
"field": "Civilian_labor_force_2016"
}
}
}
]
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment