diff --git a/Map.html b/Map.html new file mode 100644 index 0000000..a45dd92 --- /dev/null +++ b/Map.html @@ -0,0 +1,166 @@ + + +
+ + + + + + + + + \ No newline at end of file diff --git a/Map.json b/Map.json new file mode 100644 index 0000000..a0d3526 --- /dev/null +++ b/Map.json @@ -0,0 +1,152 @@ +{ + "$schema": "https://vega.github.io/schema/vega-lite/v5.json", + "autosize": {"resize": true}, + "data": { + "url": "https://raw.githubusercontent.com/FIT3179/Vega-Lite/main/3_choropleth_map/js/ne_110m_admin_0_countries.topojson", + "format": {"type": "topojson", "feature": "ne_110m_admin_0_countries"} + }, + "vconcat": [ + { + "title": "Life Expectancy World Bank", + "width": 800, + "height": 400, + "projection": {"type": "equalEarth"}, + "layer": [ + { + "transform": [ + { + "calculate": "'Data is not available in ' + datum.properties.NAME", + "as": "note" + } + ], + "mark": {"type": "geoshape", "fill": "lightgray", "stroke": "white"}, + "encoding": {"tooltip": {"field": "note"}} + }, + { + "data": { + "url": "https://raw.githubusercontent.com/FIT3179/Vega-Lite/main/7_others/oceans.topojson", + "format": {"type": "topojson", "feature": "oceans"} + }, + "mark": {"type": "geoshape", "fill": "white"} + }, + { + "data": { + "url": "https://raw.githubusercontent.com/FIT3179/Vega-Lite/main/2_symbol_map/js/WorldMapWithGraticules.topojson", + "format": {"type": "topojson", "feature": "ne_110m_graticules_30"} + }, + "mark": {"type": "geoshape", "fill": null, "stroke": "lightgray"} + }, + { + "transform": [ + { + "lookup": "properties.NAME", + "from": { + "data": { + "url": "https://raw.githubusercontent.com/sz0314/life_expansion/main/averaged_features_by_country.csv" + }, + "key": "Country Name", + "fields": ["Life_Expectancy"] + } + } + ], + "mark": {"type": "geoshape", "stroke": "white"}, + "params": [{"name": "countrySelection", "select": {"type": "point"}}], + "encoding": { + "color": { + "field": "Life_Expectancy", + "type": "quantitative", + "scale": { + "type": "threshold", + "domain": [50, 60, 70, 80, 90], + "range": ["#f0f9e8", "#ccebc5", "#a8ddb5", "#7bccc4", "#4eb3d3"] + } + }, + "tooltip": [ + { + "field": "properties.NAME", + "type": "nominal", + "title": "Country" + }, + { + "field": "Life_Expectancy", + "type": "quantitative", + "format": ".0f" + } + ] + } + }, + { + "transform": [ + { + "lookup": "properties.NAME", + "from": { + "data": { + "url": "https://raw.githubusercontent.com/FIT3179/Vega-Lite/main/3_choropleth_map/data/countryInfo.csv" + }, + "key": "name", + "fields": ["latitude", "longitude"] + } + } + ], + "mark": {"type": "text"}, + "encoding": { + "longitude": {"field": "longitude", "type": "quantitative"}, + "latitude": {"field": "latitude", "type": "quantitative"}, + "text": {"field": "properties.NAME", "type": "nominal"}, + "opacity": { + "condition": { + "test": "datum['properties.NAME'] == 'Sweden' || datum['properties.NAME'] == 'Japan' || datum['properties.NAME'] == 'Australia' || datum['properties.NAME'] == 'Switzerland' || datum['properties.NAME'] == 'Iceland' || datum['properties.NAME'] == 'Israel'|| datum['properties.NAME'] == 'Spain'|| datum['properties.NAME'] == 'Italy'|| datum['properties.NAME'] == 'Singapore' || (datum.latitude == 46.227638 && datum.longitude == 1.8213749)", + "value": 1 + }, + "value": 0 + } + } + }, + { + "data": { + "values": [ + { + "latitude": 46.227638, + "longitude": -15.8213749, + "text": "France" + } + ] + }, + "mark": {"type": "text", "fontSize": 10}, + "encoding": { + "longitude": {"field": "longitude", "type": "quantitative"}, + "latitude": {"field": "latitude", "type": "quantitative"}, + "text": {"field": "text", "type": "nominal"}, + "opacity": {"value": 1} + } + } + ] + }, + { + "width": 700, + "transform": [ + { + "lookup": "properties.NAME", + "from": { + "data": { + "url": "https://raw.githubusercontent.com/sz0314/life_expansion/main/averaged_features_by_country.csv" + }, + "key": "Country", + "fields": ["Life_Expectancy"] + } + }, + {"filter": {"param": "countrySelection", "empty": false}} + ], + "mark": {"type": "bar"}, + "encoding": { + "x": { + "field": "Life_Expectancy", + "type": "quantitative", + "title": "Life Expectancy Top 10 Countries" + }, + "y": {"field": "properties.NAME", "type": "nominal", "title": null} + } + } + ], + "config": {} +} \ No newline at end of file