1+ # -*- coding: utf-8 -*-
2+ ###############################################################################
3+ # Copyright (c), Forschungszentrum Jülich GmbH, IAS-9, Germany. #
4+ # All rights reserved. #
5+ # This file is part of the survey_dashboard package. #
6+ # #
7+ # The code is hosted on GitHub at #
8+ # https://github.com/Materials-Data-Science-and-Informatics/survey_dashboard #
9+ # For further information on the license, see the LICENSE file #
10+ ###############################################################################
11+ """
12+ Simplified entry point for the HMC Survey Dashboard.
13+ This app.py orchestrates the creation of the dashboard using the new modular structure.
14+ """
15+
16+ print ("Initializing HMC Survey Dashboard..." )
17+
18+ # Import core components
19+ from survey_dashboard .core .data import DataProcessor
20+ from survey_dashboard .core .charts import ChartManager
21+
22+ # Import UI components
23+ from survey_dashboard .ui .widgets import WidgetFactory
24+ from survey_dashboard .ui .layout import LayoutManager
25+ from survey_dashboard .ui .callbacks import CallbackManager
26+
27+ print ("Loading configuration and data..." )
28+
29+ # Initialize core components
30+ data_processor = DataProcessor ()
31+ chart_manager = ChartManager (data_processor )
32+
33+ # Initialize UI components
34+ widget_factory = WidgetFactory (data_processor )
35+ layout_manager = LayoutManager ()
36+ callback_manager = CallbackManager (data_processor , chart_manager )
37+
38+ print ("Creating widgets..." )
39+
40+ # Create all widgets
41+ widgets = widget_factory .create_all_widgets ()
42+ control_groups = widget_factory .get_control_groups (widgets )
43+
44+ # Get initial filter values
45+ data_filters = widgets ["global_filters" ]["research_area" ].value
46+ data_filters_method = widgets ["global_filters" ]["method" ].value
47+
48+ print ("Creating visualizations..." )
49+
50+ # Create all visualizations using chart manager
51+ overview_charts = chart_manager .create_overview_charts (data_filters , data_filters_method )
52+ exploration_charts = chart_manager .create_exploration_charts (
53+ widgets ["exploration" ]["question1" ],
54+ widgets ["exploration" ]["question2" ],
55+ data_filters ,
56+ data_filters_method
57+ )
58+ correlation_chart = chart_manager .create_correlation_chart (
59+ widgets ["exploration" ]["question1" ],
60+ widgets ["exploration" ]["question2" ],
61+ data_filters ,
62+ data_filters_method
63+ )
64+ methods_tools_tabs , wordcloud_panes = chart_manager .create_wordcloud_tabs (data_filters , data_filters_method )
65+
66+ print ("Setting up callbacks..." )
67+
68+ # Create update callbacks
69+ callbacks = callback_manager .create_update_callbacks (widgets )
70+
71+ # Bind callbacks to widgets and charts
72+ def bind_callbacks ():
73+ """Bind all interactive callbacks to their respective widgets and charts."""
74+ # Global filter callbacks for overview charts
75+ for i , chart_key in enumerate (['ov1' , 'ov2' , 'ov3' , 'ov4' ]):
76+ widgets ["global_filters" ]["research_area" ].param .watch (
77+ callbacks ["overview" ][i ], "value"
78+ )
79+ widgets ["global_filters" ]["method" ].param .watch (
80+ callbacks ["overview" ][i ], "value"
81+ )
82+ overview_charts [chart_key ].param .watch (callbacks ["overview" ][i ], "object" )
83+
84+ # Exploration chart callbacks
85+ for widget_key in ["question1" , "question2" , "chart_type1" , "chart_type2" ]:
86+ if "question" in widget_key :
87+ callback_idx = 0 if "1" in widget_key else 1
88+ widgets ["exploration" ][widget_key ].param .watch (
89+ callbacks ["exploration" ][callback_idx ], "value"
90+ )
91+
92+ # Global filter callbacks for exploration charts
93+ for callback in callbacks ["exploration" ]:
94+ widgets ["global_filters" ]["research_area" ].param .watch (callback , "value" )
95+ widgets ["global_filters" ]["method" ].param .watch (callback , "value" )
96+
97+ # Correlation chart callbacks
98+ widgets ["exploration" ]["question1" ].param .watch (callbacks ["correlation" ], "value" )
99+ widgets ["exploration" ]["question2" ].param .watch (callbacks ["correlation" ], "value" )
100+ widgets ["global_filters" ]["research_area" ].param .watch (callbacks ["correlation" ], "value" )
101+ widgets ["global_filters" ]["method" ].param .watch (callbacks ["correlation" ], "value" )
102+
103+ # Word cloud callbacks
104+ for callback in callbacks ["wordclouds" ]:
105+ widgets ["global_filters" ]["research_area" ].param .watch (callback , "value" )
106+ widgets ["global_filters" ]["method" ].param .watch (callback , "value" )
107+
108+ print ("Creating layout..." )
109+
110+ # Create complete layout
111+ layout = layout_manager .create_complete_layout (
112+ control_groups = control_groups ,
113+ overview_charts = overview_charts ,
114+ exploration_charts = exploration_charts ,
115+ correlation_chart = correlation_chart ,
116+ methods_tools_tabs = methods_tools_tabs
117+ )
118+
119+ print ("Setting up template..." )
120+
121+ # Setup template and make servable
122+ template = layout_manager .setup_template_variables (layout )
123+ bind_callbacks ()
124+
125+ print ("Dashboard ready! Making servable..." )
126+ template = layout_manager .make_servable ()
127+
128+ print ("HMC Survey Dashboard initialized successfully!" )
0 commit comments