feat: add pathway data loading callback bridging filters to chart-data (Task 3.2)
This commit is contained in:
@@ -172,11 +172,11 @@ Drawer selection → update_drug_selection → app-state store → load_pathway_
|
|||||||
- **Checkpoint**: Page loads reference data, filter dropdowns update app-state store (verify via browser dev tools → dcc.Store)
|
- **Checkpoint**: Page loads reference data, filter dropdowns update app-state store (verify via browser dev tools → dcc.Store)
|
||||||
|
|
||||||
### 3.2 Pathway data loading callback
|
### 3.2 Pathway data loading callback
|
||||||
- [ ] Create `dash_app/callbacks/chart.py` (or add to filters.py):
|
- [x] Create `dash_app/callbacks/chart.py` (or add to filters.py):
|
||||||
- `load_pathway_data` callback: Input=`app-state` store, Output=`chart-data` store
|
- `load_pathway_data` callback: Input=`app-state` store, Output=`chart-data` store
|
||||||
- Calls `queries.load_pathway_data(filter_id, chart_type, selected_drugs, selected_directorates)`
|
- Calls `queries.load_pathway_data(filter_id, chart_type, selected_drugs, selected_directorates)`
|
||||||
- Runs on page load AND whenever `app-state` changes
|
- Runs on page load AND whenever `app-state` changes
|
||||||
- **Checkpoint**: Changing date filter updates chart-data store with new pathway nodes
|
- **Checkpoint**: Changing date filter updates chart-data store with new pathway nodes ✓
|
||||||
|
|
||||||
### 3.3 KPI update callback
|
### 3.3 KPI update callback
|
||||||
- [ ] Create `dash_app/callbacks/kpi.py`:
|
- [ ] Create `dash_app/callbacks/kpi.py`:
|
||||||
|
|||||||
@@ -4,5 +4,7 @@
|
|||||||
def register_callbacks(app):
|
def register_callbacks(app):
|
||||||
"""Register all Dash callbacks with the app instance."""
|
"""Register all Dash callbacks with the app instance."""
|
||||||
from dash_app.callbacks.filters import register_filter_callbacks
|
from dash_app.callbacks.filters import register_filter_callbacks
|
||||||
|
from dash_app.callbacks.chart import register_chart_callbacks
|
||||||
|
|
||||||
register_filter_callbacks(app)
|
register_filter_callbacks(app)
|
||||||
|
register_chart_callbacks(app)
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
"""Callback for loading pathway data from SQLite into chart-data store."""
|
||||||
|
from dash import Input, Output, callback, no_update
|
||||||
|
|
||||||
|
|
||||||
|
def register_chart_callbacks(app):
|
||||||
|
"""Register pathway data loading callback."""
|
||||||
|
|
||||||
|
@app.callback(
|
||||||
|
Output("chart-data", "data"),
|
||||||
|
Input("app-state", "data"),
|
||||||
|
)
|
||||||
|
def load_pathway_data(app_state):
|
||||||
|
"""Load pathway nodes when app-state changes (filter or chart type)."""
|
||||||
|
if not app_state:
|
||||||
|
return no_update
|
||||||
|
|
||||||
|
from dash_app.data.queries import load_pathway_data as query_pathway_data
|
||||||
|
|
||||||
|
filter_id = app_state.get("date_filter_id", "all_6mo")
|
||||||
|
chart_type = app_state.get("chart_type", "directory")
|
||||||
|
selected_drugs = app_state.get("selected_drugs") or None
|
||||||
|
selected_directorates = app_state.get("selected_directorates") or None
|
||||||
|
|
||||||
|
return query_pathway_data(
|
||||||
|
filter_id=filter_id,
|
||||||
|
chart_type=chart_type,
|
||||||
|
selected_drugs=selected_drugs,
|
||||||
|
selected_directorates=selected_directorates,
|
||||||
|
)
|
||||||
Reference in New Issue
Block a user