Spaces:
Sleeping
Sleeping
Update dashboard.py
Browse files- dashboard.py +56 -1
dashboard.py
CHANGED
@@ -167,6 +167,23 @@ def loadTaskMethodTimeSeries(topic,task):
|
|
167 |
return task_method_ts
|
168 |
|
169 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
170 |
################################# CREATE CHARTS ############################
|
171 |
################################# CREATE CHARTS ############################
|
172 |
|
@@ -585,11 +602,49 @@ def CreatePage7():
|
|
585 |
align="center",
|
586 |
)
|
587 |
|
|
|
588 |
|
|
|
589 |
|
|
|
|
|
|
|
|
|
590 |
|
591 |
|
592 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
593 |
|
594 |
task_data = dict()
|
595 |
|
|
|
167 |
return task_method_ts
|
168 |
|
169 |
|
170 |
+
def loadTaskTimeSeries(topic):
|
171 |
+
#cluster_{cluster_id}_TASK_time_series.csv
|
172 |
+
task_ts = pd.read_csv(os.path.join(data_folder+'/time_series', f"""cluster_{topic}_TASK_time_series.csv"""),
|
173 |
+
header=0, sep=',', lineterminator='\n', low_memory=False)
|
174 |
+
|
175 |
+
task_ts.set_index(task_ts.columns[0], inplace=True)
|
176 |
+
return task_ts
|
177 |
+
|
178 |
+
def loadMethodTimeSeries(topic):
|
179 |
+
|
180 |
+
method_ts = pd.read_csv(os.path.join(data_folder+'/time_series', f"""cluster_{topic}_METHOD_time_series.csv"""),
|
181 |
+
header=0, sep=',', lineterminator='\n', low_memory=False)
|
182 |
+
|
183 |
+
method_ts.set_index(method_ts.columns[0], inplace=True)
|
184 |
+
return method_ts
|
185 |
+
|
186 |
+
|
187 |
################################# CREATE CHARTS ############################
|
188 |
################################# CREATE CHARTS ############################
|
189 |
|
|
|
602 |
align="center",
|
603 |
)
|
604 |
|
605 |
+
def load_Task_Method_trends(topic, **kwargs):
|
606 |
|
607 |
+
task_data = dict()
|
608 |
|
609 |
+
# Check if macro_topics_mapping exists
|
610 |
+
if topic not in macro_topics_mapping:
|
611 |
+
raise ValueError(f"Topic '{topic}' not found in macro_topics_mapping")
|
612 |
+
macro_topic_str = str(macro_topics_mapping[topic])
|
613 |
|
614 |
|
615 |
+
#load the tasks and methods timeseries dataframe for the selected topic
|
616 |
+
task_ts_df = loadTaskTimeSeries(macro_topic_str)
|
617 |
+
method_ts_df = loadMethodTimeSeries(macro_topic_str)
|
618 |
+
|
619 |
+
task_overlay = create_overlay_plot(task_ts_df)
|
620 |
+
method_overlay = create_overlay_plot(method_ts_df)
|
621 |
+
|
622 |
+
# Recolor and relabel elements in overlays
|
623 |
+
|
624 |
+
task_overlay_colored = hv.Overlay([
|
625 |
+
curve.opts(color='red', legend_label=curve.label if curve.label else f"Series {i + 1}")
|
626 |
+
for i, curve in enumerate(task_overlay)
|
627 |
+
])
|
628 |
+
method_overlay_colored = hv.Overlay([
|
629 |
+
curve.opts(color='blue', legend_label=curve.label if curve.label else f"Series {i + 1}")
|
630 |
+
for i, curve in enumerate(method_overlay)
|
631 |
+
])
|
632 |
+
|
633 |
+
# Merge overlays into one plot
|
634 |
+
merged_overlay = task_overlay_colored * method_overlay_colored
|
635 |
+
merged_overlay.opts(
|
636 |
+
show_legend=True,
|
637 |
+
legend_position='right',
|
638 |
+
width=1400,
|
639 |
+
height=900
|
640 |
+
)
|
641 |
+
return pn.Column(
|
642 |
+
merged_overlay
|
643 |
+
)
|
644 |
+
|
645 |
+
|
646 |
+
|
647 |
+
def load_Task_Method_triple_trends(topic, **kwargs):
|
648 |
|
649 |
task_data = dict()
|
650 |
|