9
9
import dash_html_components as html
10
10
import plotly .express as px
11
11
import plotly .graph_objs as go
12
+ from dash .dependencies import Input , Output
12
13
import plotly .figure_factory as ff
13
14
import pandas as pd
14
15
import numpy as np
25
26
PORT = CONFIG ["DB_PORT" ]
26
27
NAME = CONFIG ["DB_NAME" ]
27
28
INTERVAL = CONFIG ["INTERVAL" ]
29
+ SERVER_PORT = CONFIG ["PORT" ]
28
30
29
31
mc = MongoClient (host = HOST , port = PORT )
30
32
cw = mc [NAME ].weather_current
59
61
"tornado" : 30
60
62
}
61
63
64
+ app = dash .Dash (__name__ , title = "wdash" , update_title = "wdash" )
62
65
63
66
64
67
def convert_meteorological_deg2cardinal_dir (deg_measurement ):
@@ -404,8 +407,12 @@ def wind_direction_graph(df_wind, history_rgb, forecast_rgb):
404
407
)
405
408
return fig
406
409
407
-
408
- def generate_page ():
410
+ @app .callback (
411
+ Output (component_id = 'all_info' , component_property = "children" ),
412
+ Input (component_id = "interval" , component_property = "n_intervals" )
413
+ )
414
+ def generate_page (n_intervals ):
415
+ logging .info (f"Regenerating info div: times regenerated = { n_intervals } " )
409
416
df = create_df ()
410
417
411
418
fig_temp = create_time_figure (
@@ -634,11 +641,12 @@ def generate_page():
634
641
y = df_square_ints .index .tolist (),
635
642
x = df_square_ints .columns .tolist (),
636
643
annotation_text = df_square_statuses .values ,
637
- colorscale = "Viridis " ,
644
+ colorscale = "Turbo " ,
638
645
showscale = False ,
639
646
customdata = df_square_statuses .values ,
640
647
hovertemplate = "forecast:%{customdata}" ,
641
- name = "Forecast"
648
+ name = "Forecast" ,
649
+ font_colors = ["white" , "black" ],
642
650
)
643
651
figh .update_layout (
644
652
template = "plotly_dark" ,
@@ -682,8 +690,8 @@ def generate_page():
682
690
683
691
684
692
685
- app = dash . Dash ( __name__ , title = "wdash" , update_title = "wdash" )
686
- app . title = "wdash"
693
+
694
+
687
695
688
696
app .layout = html .Div (
689
697
children = [
@@ -693,15 +701,16 @@ def generate_page():
693
701
Updated with data from the OpenWeatherMaps API, pyOWM, and Windy.
694
702
''' , style = {"color" : "white" }),
695
703
html .Br (),
696
- generate_page ( ),
704
+ html . Div ( id = "all_info" ),
697
705
698
706
],
699
707
style = {"backgroundColor" : "rgb(17,17,17)" }
700
708
)
701
-
709
+ app . title = "wdash"
702
710
703
711
if __name__ == '__main__' :
704
712
pd .set_option ('display.max_rows' , 500 )
705
713
pd .set_option ('display.max_columns' , 500 )
706
714
pd .set_option ('display.width' , 1000 )
707
- app .run_server (debug = True )
715
+ # app.run_server(debug=True, port=SERVER_PORT)
716
+ app .run_server (debug = False , host = "0.0.0.0" , port = SERVER_PORT )
0 commit comments