feat: duration vs cost scatter plot tab (Task C.3)
This commit is contained in:
@@ -317,6 +317,31 @@ def _render_depth(app_state, title):
|
||||
return create_pathway_depth_figure(data, title)
|
||||
|
||||
|
||||
def _render_scatter(app_state, title):
|
||||
"""Build the duration vs cost scatter plot from current filter state."""
|
||||
from dash_app.data.queries import get_duration_cost_scatter
|
||||
from visualization.plotly_generator import create_duration_cost_scatter_figure
|
||||
|
||||
filter_id = (app_state or {}).get("date_filter_id", "all_6mo")
|
||||
chart_type = (app_state or {}).get("chart_type", "directory")
|
||||
|
||||
selected_dirs = (app_state or {}).get("selected_directorates") or []
|
||||
selected_trusts = (app_state or {}).get("selected_trusts") or []
|
||||
directory = selected_dirs[0] if len(selected_dirs) == 1 else None
|
||||
trust = selected_trusts[0] if len(selected_trusts) == 1 else None
|
||||
|
||||
try:
|
||||
data = get_duration_cost_scatter(filter_id, chart_type, directory, trust)
|
||||
except Exception:
|
||||
log.exception("Failed to load duration/cost scatter data")
|
||||
return _empty_figure("Failed to load scatter data.")
|
||||
|
||||
if not data:
|
||||
return _empty_figure("No duration/cost data available.\nTry adjusting your filters.")
|
||||
|
||||
return create_duration_cost_scatter_figure(data, title)
|
||||
|
||||
|
||||
def register_chart_callbacks(app):
|
||||
"""Register tab switching, pathway data loading, and chart rendering callbacks."""
|
||||
|
||||
@@ -463,6 +488,9 @@ def register_chart_callbacks(app):
|
||||
elif active_tab == "depth":
|
||||
fig = _render_depth(app_state, title)
|
||||
|
||||
elif active_tab == "scatter":
|
||||
fig = _render_scatter(app_state, title)
|
||||
|
||||
else:
|
||||
# Placeholder for charts not yet implemented
|
||||
tab_label = dict(TAB_DEFINITIONS).get(active_tab, active_tab)
|
||||
|
||||
Reference in New Issue
Block a user