-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Setting it up with django-plotly-dash
- Loading branch information
Showing
8 changed files
with
59 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from datetime import datetime | ||
from decimal import Decimal | ||
import plotly.express as px | ||
from dash import dcc, html | ||
from django_plotly_dash import DjangoDash | ||
|
||
from station.models import Station | ||
from variable.models import Variable | ||
from validated.functions import daily_validation | ||
|
||
# Create a Dash app | ||
app = DjangoDash("DailyValidation") | ||
|
||
# Filters (in final app this will get data from forms) | ||
station: Station = Station.objects.order_by("station_code")[7] | ||
variable: Variable = Variable.objects.order_by("variable_code")[0] | ||
start_time: datetime = datetime.strptime("2023-03-01", "%Y-%m-%d") | ||
end_time: datetime = datetime.strptime("2023-03-31", "%Y-%m-%d") | ||
minimum: Decimal = Decimal(-5) | ||
maximum: Decimal = Decimal(28) | ||
|
||
# Load data | ||
data: dict = daily_validation( | ||
station=station, | ||
variable=variable, | ||
start_time=start_time, | ||
end_time=end_time, | ||
minimum=minimum, | ||
maximum=maximum, | ||
) | ||
|
||
# Create plot | ||
x = data["series"]["measurement"]["time"] | ||
y = data["series"]["measurement"]["average"] | ||
plot = px.line(x=x, y=y) | ||
|
||
# Create layout | ||
app.layout = html.Div([dcc.Graph(figure=plot)]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{% load plotly_dash %} | ||
|
||
{% plotly_app name="DailyValidation" %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters