``` { "layer": [ { "params": [ { "name": "com_sel", "select": { "type": "point", "fields": ["Comune"], "on": "click", "clear": "doubleclick", "toggle": true } }, { "name": "com_hov", "select": { "type": "point", "fields": ["Comune"], "on": "pointerover" } } ], "data": { "name": "liv_comunale", "url": "https://raw.githubusercontent.com/MikeADL/ATS-Lombardia/main/Limiti_IT_Comuni_Lombardia_topojson.json", "format": { "type": "topojson", "feature": "data" } }, "transform": [ { "lookup": "properties.com_istat_code", "from": { "data": {"name": "dataset"}, "key": "COD_ISTAT_TEXT", "fields": [ "Provincia", "Comune", "__selected__", "Interventi", "Investimento" ] } }, { "filter": "datum.__selected__ == 'on' || datum.__selected__ == 'neutral'" } ], "projection": { "type": "mercator" }, "mark": { "type": "geoshape", "stroke": {"expr": "isValid(com_hov.Comune) === true ? '#C74970' : 'white'"} }, "encoding": { "color": { "field": "Interventi", "type": "quantitative", "scale": { "type": "linear", "range": [ "#AEAEB7", "#1B3257" ] }, "legend": null }, "opacity": { "condition": { "param": "com_hov", "value": 1 }, "value": 0.6 }, "strokeWidth": { "condition": { "param": "com_hov", "value": {"expr": "isValid(prov_hov.Provincia) === true ? 2 : 1"} }, "value": 0 }, "tooltip": [ { "field": "Comune", "title": "Sede intervento", "type": "nominal" }, { "field": "Interventi", "title": "Interventi", "format": ",.0f", "type": "quantitative" } ] } }, { "params": [{ "name": "prov_hov", "value": null, "select": { "type": "point", "fields": ["Provincia"], "on": "pointerover" } }], "data": { "name": "liv_provinciale", "url": "https://raw.githubusercontent.com/MikeADL/ATS-Lombardia/main/Limiti_IT_Province_Lombardia_topojson.json", "format": { "type": "topojson", "feature": "data" } }, "transform": [ { "lookup": "properties.prov_name", "from": { "data": {"name": "dataset"}, "key": "Provincia", "fields": [ "Provincia", "Interventi per provincia", "Investimento per provincia", "__selected__" ] } }, { "filter": "datum.__selected__ == 'on' || datum.__selected__ == 'off' ? datum.Provincia == null : datum.Provincia != null" } ], "projection": { "type": "mercator" }, "mark": { "type": "geoshape", "stroke": {"expr": "isValid(prov_hov.Provincia) === true ? '#C74970' : 'white'"} }, "encoding": { "color": { "field": "Interventi per provincia", "type": "quantitative" }, "opacity": { "condition": { "param": "prov_hov", "value": 1 }, "value": 0.9 }, "strokeWidth": { "condition": { "param": "prov_hov", "value": {"expr": "isValid(prov_hov.Provincia) === true ? 1.5 : 0.5"} }, "value": 0.1 }, "tooltip": [ { "field": "Provincia", "title": "Sede intervento", "type": "nominal" }, { "field": "Interventi", "type": "quantitative", "format": ",.2f" } ] } }, { "data": { "name": "prov_centr", "url": "https://raw.githubusercontent.com/MikeADL/Varie/main/Limiti_IT_Comuni_Lombardia_conCentroideComProv.csv" }, "transform": [ { "aggregate": [ { "op": "min", "field": "prov_centr_long", "as": "centr_long" }, { "op": "max", "field": "prov_centr_lati", "as": "centr_lati" } ], "groupby": ["prov_name"] }, { "calculate": "datum.prov_name === 'Sondrio' ? datum.centr_lati*0.999 : datum.prov_name === 'Monza e della Brianza' ? datum.centr_lati*1.0004 : datum.centr_lati*1.001", "as": "new_centr_lati" }, { "calculate": "datum.prov_name === 'Sondrio' ? datum.centr_long*0.991 : datum.prov_name === 'Lodi' ? datum.centr_long*0.991 : datum.prov_name === 'Cremona' ? datum.centr_long*0.991 : datum.centr_long ", "as": "new_centr_long" }, { "calculate": "datum.prov_name === 'Monza e della Brianza' ? 'Monza' : datum.prov_name", "as": "new_prov_name" }, { "lookup": "prov_name", "from": { "data": {"name": "dataset"}, "key": "Provincia", "fields": ["Interventi per provincia", "__selected__"] } }, { "filter": "datum.__selected__ == 'on' || datum.__selected__ == 'off' ? datum.prov_name == null : datum.prov_name != null" } ], "mark": { "type": "text", "fontSize": 15, "fontWeight": "bold", "color": "#D6C6B8", "font": "Segoe UI Light" }, "encoding": { "latitude": {"field": "new_centr_lati"}, "longitude": {"field": "new_centr_long"}, "text": { "field": "new_prov_name", "type": "ordinal" } } }, { "data": { "name": "dati_per_prov", "url": "https://raw.githubusercontent.com/MikeADL/Varie/main/Limiti_IT_Comuni_Lombardia_conCentroideComProv.csv" }, "transform": [ { "aggregate": [ { "op": "min", "field": "prov_centr_long", "as": "centr_long" }, { "op": "max", "field": "prov_centr_lati", "as": "centr_lati" } ], "groupby": ["prov_name"] }, { "calculate": "datum.prov_name === 'Sondrio' ? datum.centr_lati*0.9971 : datum.centr_lati*0.99919", "as": "new_centr_lati" }, { "calculate": "datum.prov_name === 'Sondrio' ? datum.centr_long*0.991 : datum.prov_name === 'Lodi' ? datum.centr_long*0.999 : datum.prov_name === 'Cremona' ? datum.centr_long*0.999 : datum.centr_long ", "as": "new_centr_long" }, { "lookup": "prov_name", "from": { "data": {"name": "dataset"}, "key": "Provincia", "fields": ["Interventi per provincia", "__selected__"] } }, { "filter": "datum.__selected__ == 'on' || datum.__selected__ == 'off' ? datum.prov_name == null : datum.prov_name != null" } ], "mark": { "type": "text", "fontSize": 13, "color": "white", "fontWeight": "bold", "font": "Segoe UI Light" }, "encoding": { "latitude": {"field": "new_centr_lati"}, "longitude": {"field": "new_centr_long"}, "text": { "field": "Interventi per provincia", "type": "quantitative", "format": "," } } } ] } ```