diff --git a/app/core_api.py b/app/core_api.py index 6777fef..3d3676e 100644 --- a/app/core_api.py +++ b/app/core_api.py @@ -35,7 +35,7 @@ def html(page: str) -> dict[str, str | dict[str, str | dict[str, str]]]: """Initial config for sections.""" INIT_SECTIONS = { "Control": {"space": "Tablet", "app": html("control")}, - "NMX": {"space": "PC01-Top", "app": webrtc}, + "Map View": {"space": "PC01-Top", "app": html("map")}, "Balance of Supply and Demand": {"space": "PC01-Left", "app": html("market")}, "Markets and Reserve": {"space": "PC01-Right", "app": html("marketsreserve")}, "NMX Geographic Map": {"space": "PC02-Top", "app": webrtc}, diff --git a/app/pages/agent.py b/app/pages/agent.py index b8e36f2..647c4bc 100644 --- a/app/pages/agent.py +++ b/app/pages/agent.py @@ -42,7 +42,7 @@ style={"height": "100%", "width": "100%"}, ), row=0, - col=0, + col=1, ) grid.add_element( dcc.Graph( @@ -51,7 +51,7 @@ style={"height": "100%", "width": "100%"}, ), row=0, - col=1, + col=0, ) grid.add_element( dcc.Graph( diff --git a/app/pages/map.py b/app/pages/map.py new file mode 100644 index 0000000..40f5a15 --- /dev/null +++ b/app/pages/map.py @@ -0,0 +1,62 @@ +"""Map view page in dash app. + +This is a cut down copy of the agent page +One plots: +- Agent and EV Locations +""" + +import dash # type: ignore +import pandas as pd +import plotly.graph_objects as go # type: ignore +from dash import Input, Output, callback, dcc # type: ignore + +from .. import log +from ..figures import ( + generate_map_fig, +) +from ..layout import GridBuilder + +dash.register_page(__name__) + +df = pd.DataFrame({"Col": [0]}) + +map_fig = generate_map_fig(df) + +grid = GridBuilder(rows=1, cols=1) +grid.add_element( + dcc.Graph( + id="big_map_fig", + figure=map_fig, + style={"height": "100%", "width": "100%"}, + ), + row=0, + col=0, +) +layout = grid.layout + + +@callback( + [ + Output("big_map_fig", "figure"), + ], + [Input("figure_interval", "data")], +) +def update_figures( + n_intervals: int, +) -> tuple[go.Figure]: + """Function to update the plots in this page. + + Args: + n_intervals (int): The number of times this page has updated. + indexes by 1 every interval. + + Returns: + tuple[go.Figure, go.Figure, go.Figure, go.Figure, px.line]: + The new figures. + """ + from ..data import DF_OPAL + + # TODO: ensure each figure is using the correct dataframe + map_fig = generate_map_fig(DF_OPAL) + log.debug("Updating figures on Map page") + return (map_fig,)