Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phil test 1 #119

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/core_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down
4 changes: 2 additions & 2 deletions app/pages/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
style={"height": "100%", "width": "100%"},
),
row=0,
col=0,
col=1,
)
grid.add_element(
dcc.Graph(
Expand All @@ -51,7 +51,7 @@
style={"height": "100%", "width": "100%"},
),
row=0,
col=1,
col=0,
)
grid.add_element(
dcc.Graph(
Expand Down
62 changes: 62 additions & 0 deletions app/pages/map.py
Original file line number Diff line number Diff line change
@@ -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,)
Loading