Created
April 22, 2021 08:05
-
-
Save Cansu987/dfb1b05c1a96b4bb10c7b7ecef58956f to your computer and use it in GitHub Desktop.
This file contains 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 population pyramid for Energy Consumption over Years", | |
"data": { "url": "https://raw.githubusercontent.com/mkeutgen/dataviz_energy/main/Sub-Meansumry2.csv", "format":{"type":"csv"}}, | |
"params": [{ | |
"name": "filter", "value":"Africa", | |
"select": {"type": "point", "fields": ["continent"]}, | |
"bind": {"input": "select", "options": ["Africa", "Americas", "Asia", "Europe", "Oceania"]} | |
}], | |
"transform": [ | |
{"filter":{ "field":"energy_type" , "oneOf":["fossil", "low_carbon"]}}, | |
{"filter":{"param":"filter"}} | |
], | |
"spacing": 0, | |
"hconcat": [{ | |
"transform": [{ | |
"filter": {"field": "energy_type", "equal": "fossil"} | |
}], | |
"title": "Fossil", | |
"mark": "bar", | |
"encoding": { | |
"y": { | |
"field": "year", "axis": null, "sort": "ascending" | |
}, | |
"x": { | |
"field": "meanconsmp", "type":"quantitative", | |
"title": "Mean Consumption", | |
"axis": {"format": "s"}, | |
"sort": "descending", | |
"scale":{"domain":[0,2850]} | |
}, | |
"color": { | |
"field": "energy_type", | |
"scale": {"range": ["#675193", "#ca8861"]}, | |
"legend": null | |
} | |
} | |
}, { | |
"width": 20, | |
"view": {"stroke": null}, | |
"mark": { | |
"type": "text", | |
"align": "center" | |
}, | |
"encoding": { | |
"y": {"field": "year", "type": "ordinal", "axis": null, "sort": "ascending"}, | |
"text": {"field": "year", "type": "quantitative"} | |
} | |
}, { | |
"transform": [{ | |
"filter": {"field": "energy_type", "equal": "low_carbon"} | |
}], | |
"title": "Low Carbon", | |
"mark": "bar", | |
"encoding": { | |
"y": { | |
"field": "year", "title": null, | |
"axis": null, "sort": "ascending" | |
}, | |
"x": { | |
"field": "meanconsmp", "type":"quantitative", | |
"title": "Mean Consumption", | |
"axis": {"format": "s"}, | |
"scale":{"domain":[0,2850]} | |
}, | |
"color": { | |
"field": "energy_type"} | |
} | |
} | |
], | |
"config": { | |
"view": {"stroke": null}, | |
"axis": {"grid": true} | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment