diff --git a/etl/customers/stonewater/map_app/map_page.py b/etl/customers/stonewater/map_app/map_page.py index 4fa2406c..bb85961e 100644 --- a/etl/customers/stonewater/map_app/map_page.py +++ b/etl/customers/stonewater/map_app/map_page.py @@ -7,6 +7,43 @@ import pandas as pd from config import MAPBOX_ACCESS_TOKEN +def make_real_epc_piechart(real_epc_breakdown): + labels = [x["is_real_epc"] for x in real_epc_breakdown] + values = [x["count"] for x in real_epc_breakdown] + + marker_colors = ["#027fa6", "rgb(225 225 225)"] + + fig = go.Figure( + data=[go.Pie(labels=labels, values=values, marker_colors=marker_colors)], + ) + + fig.update_layout(margin={"t": 0}) + + plot = dcc.Graph(figure=fig, config={"displayModeBar": False}) + + return plot + + +def make_epc_rating_piechart(epc_rating_breakdown): + # Re-order from G to A + epc_rating_breakdown = sorted(epc_rating_breakdown, key=lambda x: x["EPC"]) + + labels = [x["EPC"] for x in epc_rating_breakdown] + values = [x["count"] for x in epc_rating_breakdown] + + marker_colors = ["#117d58", "#2da55c", "#8dbd40", "#f7cd14", "#f3a96a", "#ef8026", "#e41e3b"] + + fig = go.Figure( + data=[go.Pie(labels=labels, values=values, marker_colors=marker_colors, sort=False)], + ) + + fig.update_layout(margin={"t": 0}) + + plot = dcc.Graph(figure=fig, config={"displayModeBar": False}) + + return plot + + def make_map(locations): if not locations: return None @@ -38,7 +75,7 @@ def make_map(locations): bearing=0, center=go.layout.mapbox.Center(lat=53, lon=-1.5), pitch=0, - zoom=4, + zoom=5, ), margin={"t": 0}, ) @@ -55,6 +92,14 @@ def layout(): with open("Stonewater Mapping Data.json", "r") as file: locations = json.load(file) + # Get the EPC breakdown data + with open("Stonewater real EPC breakdown.json") as file: + real_epc_breakdown = json.load(file) + + # Get the EPC ratings data + with open("Stonewater EPC rating breakdown.json") as file: + epc_rating_breakdown = json.load(file) + page = dbc.Container( [ dbc.Row( @@ -85,7 +130,8 @@ def layout(): ), dbc.Row( [ - dbc.Col("Powered by", style={"color": "#027fa6", "fontSize": "1rem", 'zIndex': 10}, width="auto"), + dbc.Col("Powered by", style={"color": "#027fa6", "fontSize": "1rem", 'zIndex': 10}, + width="auto"), dbc.Col( html.A( html.Img(src="assets/hestia-logo.png", height="50px"), @@ -120,7 +166,60 @@ def layout(): align="center", className="text-center" ), - className="metric-row", + justify="center" + ), + dbc.Row( + [ + dbc.Col( + [ + html.Div( + "Breakdown of real EPCs", + style={"fontSize": "1.5rem", "fontWeight": "bold", "marginBottom": "1em"}, + className='text-center' + ), + html.Div( + "This pie chart shows the proportion of real EPCs in the asset list. Currently, " + "there are EPCs for 3736 of the 5245 properties that have a UPRN in the asset list", + style={"marginBottom": "1em"} + ), + make_real_epc_piechart(real_epc_breakdown), + ], + width={"size": 5}, + ), + dbc.Col( + [ + html.Div( + "EPC Ratings for properties with an EPC", + style={"fontSize": "1.5rem", "fontWeight": "bold", "marginBottom": "1em"}, + className='text-center' + ), + html.Div( + [ + "This pie chart shows the breakdown of EPC ratings, for properties that currently " + "have an EPC. " + "The ratings range from A to G, where surprisingly, there are two EPC properties " + "that were initially " + "expected by Parity's modelled SAP, to be EPC D or below. These properties can be" + " seen ", + html.A("here", + href="https://find-energy-certificate.service.gov.uk/energy-certificate" + "/2708-5001-7327-6090-7284", + target="_blank"), + " and ", + html.A("here", + href="https://find-energy-certificate.service.gov.uk/energy-certificate" + "/1037-4032-1009-0361-7292", + target="_blank"), + "." + ], + style={"marginBottom": "1em"} + ), + make_epc_rating_piechart(epc_rating_breakdown), + ], + + width={"size": 5}, + ), + ], justify="center" ) ],