Worked Examples
Create interactive research dashboards — Visualization & Graphing
Create interactive research dashboards — Visualization & Graphing Cross-application area: Visualization & Graphing Status: Initial scientific graphics guidance; platform-specific features not verified. Goal Separate user-selected
Application area: Visualization & Graphing
Article classification: Practical tutorial / Scientific dashboards / Reproducible analysis
Audience: Researchers, scientific programmers, data analysts, visualization developers, and research publication editors
Technical level: Intermediate
Reference environment: Python 3, pandas, NumPy, Streamlit, Plotly, and pytest
Example classification: Synthetic educational dataset
Primary outputs: Interactive dashboard, validated numerical summary, analytical-state manifest, and reproducibility tests
Estimated reading time: 14–17 minutes; approximately 30–45 minutes including practical exercises
1. Goal and expected outcome
The goal is to construct an interactive scientific dashboard that helps users explore observations while preserving the distinction between temporary selections and accepted research evidence.
At the end of the exercise, the reference dashboard should allow a user to:
- Inspect a documented synthetic dataset.
- Select experimental groups and a time interval.
- Display the corresponding observations in an interactive chart.
- Recalculate numerical summaries from the selected records.
- Inspect the source revision, selected record count, and active filters.
- Download the selected numerical records and an analytical-state manifest.
- Distinguish an exploratory result from a reviewed or published result.
Primary acceptance condition: Dynamic results disclose their source identity, input state, analytical method, and relevant uncertainty or an explicit statement that uncertainty has not been estimated.
A working interactive chart is not, by itself, a validated research dashboard.
2. Define the research question before building the interface
Start by identifying a question that the dashboard can answer using the available dataset.
For this example:
How do synthetic control and treatment measurements differ across selected observation times?
The question requires an observation-time variable, a group variable, and a measured response.
Before selecting a visualization, record:
- The intended comparison.
- The observational unit.
- The variables and measurement units.
- The authoritative dataset and version.
- The temporal or geographic reference system.
- The available uncertainty information.
- The intended users and their analytical tasks.
Do not use chart interactivity as a substitute for a clearly defined analytical purpose.
3. Separate exploratory, analytical, and publication state
Interactive research requires explicit distinctions among several types of state.
| State | Meaning | Expected treatment |
|---|---|---|
| Source state | Dataset identity, version, provenance, and rights | Preserve as authoritative input |
| Exploratory state | Current group, time, or other user selections | Clearly identify as temporary |
| Analytical state | Filter rules, numerical methods, and computed results | Make reproducible |
| Rendering state | Chart type, scales, colors, and display controls | Preserve for figure reproduction |
| Snapshot state | Recorded inputs, parameters, outputs, and environment | Retain as an identifiable artifact |
| Review state | Verification evidence and actual reviewer decision | Do not infer approval |
| Publication state | Accepted scientific output and citation context | Use an approved revision |
A local download can capture analytical state, but it does not provide durable server-side persistence, independent review, or publication approval.
4. Design the dashboard architecture
The reference implementation separates data validation and numerical analysis from the interactive user interface.
Documented source dataset
|
v
Schema and data validation
|
v
User-selected filter state
|
v
Deterministic numerical analysis
|
+----> Numerical summary
|
+----> Interactive chart
|
+----> Selected data table
|
v
Analytical-state manifest
|
v
Downloaded evidence package
Separate, later governance process:
Validation → Review → Approval → Publication
This separation helps prevent a user-interface change from silently altering the authoritative scientific data.
5. Select and verify the input data
In a real research project, use a dataset whose license, provenance, variable definitions, and access rights have been verified.
For this tutorial, use the following synthetic dataset.
| Record ID | Day | Group | Value (synthetic units) |
|---|---|---|---|
| C00 | 0 | Control | 10 |
| C07 | 7 | Control | 11 |
| C14 | 14 | Control | 12 |
| T00 | 0 | Treatment | 10 |
| T07 | 7 | Treatment | 14 |
| T14 | 14 | Treatment | 17 |
Expected full-dataset means:
Control:
(10 + 11 + 12) / 3 = 11
Treatment:
(10 + 14 + 17) / 3 = 13.666666...
Expected means for days 7–14:
Control:
(11 + 12) / 2 = 11.5
Treatment:
(14 + 17) / 2 = 15.5
No replicate-level uncertainty, sampling variance, or causal evidence is supplied. The dashboard must not describe these values as statistically significant.
6. Prepare the development environment
Create a separate directory and Python virtual environment.
mkdir interactive-research-dashboard
cd interactive-research-dashboard
python3 -m venv .venv
source .venv/bin/activate
python -m pip install \
pandas numpy streamlit plotly pytest
python --version
python -m pip freeze > requirements-lock.txt
The example uses Streamlit for interactive inputs and Plotly for graphical rendering. These are illustrative development tools, not verified components of the deployed Sustainable Catalyst platform.
For controlled research or production release, use approved dependency versions and record the runtime environment. A freeze file generated after installation documents the installed packages but is not a substitute for dependency review.
7. Implement the numerical analysis layer
The analytical layer must remain separate from interface controls so calculations can be tested without starting a browser.
7.1 Create the analysis module
Save as dashboard_analysis.py.
from dataclasses import dataclass
import hashlib
import numpy as np
import pandas as pd
SOURCE_ID = "synthetic-dashboard-source"
SOURCE_REVISION = "1.0"
ANALYSIS_VERSION = "tutorial-analysis-1"
@dataclass(frozen=True)
class Selection:
groups: tuple[str, ...]
start_day: int
end_day: int
def load_source():
return pd.DataFrame({
"record_id": [
"C00", "C07", "C14",
"T00", "T07", "T14"
],
"day": [0, 7, 14, 0, 7, 14],
"group": [
"Control", "Control", "Control",
"Treatment", "Treatment", "Treatment"
],
"value": [
10.0, 11.0, 12.0,
10.0, 14.0, 17.0
]
})
def source_checksum(data):
canonical = data.to_csv(
index=False,
lineterminator="\n"
).encode("utf-8")
return hashlib.sha256(
canonical
).hexdigest()
def validate_source(data):
required = {
"record_id",
"day",
"group",
"value"
}
if not required.issubset(data.columns):
raise ValueError("Missing source fields")
if data.empty:
raise ValueError("Empty source")
if data["record_id"].isna().any():
raise ValueError("Missing record ID")
if not data["record_id"].is_unique:
raise ValueError("Duplicate record ID")
if data["group"].isna().any():
raise ValueError("Missing group")
for column in ("day", "value"):
values = pd.to_numeric(
data[column],
errors="coerce"
).to_numpy(dtype=float)
if not np.isfinite(values).all():
raise ValueError("Invalid numeric data")
return True
def analyze(data, selection):
validate_source(data)
if selection.start_day > selection.end_day:
raise ValueError("Invalid day range")
if len(selection.groups) != len(
set(selection.groups)
):
raise ValueError("Duplicate groups")
allowed = set(data["group"])
if not set(selection.groups).issubset(allowed):
raise ValueError("Unknown group")
selected = data.loc[
data["group"].isin(selection.groups)
& data["day"].between(
selection.start_day,
selection.end_day
)
].copy()
selected = selected.sort_values(
["group", "day", "record_id"]
).reset_index(drop=True)
summary = {}
for group, subset in selected.groupby(
"group",
sort=True
):
values = subset["value"].to_numpy(
dtype=float
)
summary[group] = {
"count": int(len(values)),
"mean": float(np.mean(values)),
"minimum": float(np.min(values)),
"maximum": float(np.max(values))
}
return selected, summary
This module defines a deterministic analytical operation for a simple, fully observed dataset.
Its limitations are deliberate: it does not implement uncertainty estimation, unit conversion, complex calendars, geospatial coordinates, or missing-value imputation.
8. Create the interactive dashboard
Save the following as app.py in the same directory.
import json
import plotly.graph_objects as go
import streamlit as st
from dashboard_analysis import (
ANALYSIS_VERSION,
SOURCE_ID,
SOURCE_REVISION,
Selection,
analyze,
load_source,
source_checksum
)
st.set_page_config(
page_title="Synthetic Research Dashboard",
layout="wide"
)
st.title("Interactive Research Dashboard")
st.warning(
"Synthetic educational data. "
"Exploratory results are not reviewed "
"scientific findings."
)
source = load_source()
checksum = source_checksum(source)
st.subheader("Source and analytical context")
st.write("Dataset:", SOURCE_ID)
st.write("Revision:", SOURCE_REVISION)
st.write("Source SHA-256:", checksum)
st.write("Units: synthetic units")
st.write("Uncertainty: not estimated")
st.write("Analysis status: exploratory")
st.sidebar.header("Analytical filters")
groups = st.sidebar.multiselect(
"Experimental groups",
options=["Control", "Treatment"],
default=["Control", "Treatment"]
)
start_day, end_day = st.sidebar.slider(
"Observation interval (days)",
min_value=0,
max_value=14,
value=(0, 14),
step=1
)
selection = Selection(
groups=tuple(groups),
start_day=start_day,
end_day=end_day
)
selected, summary = analyze(
source,
selection
)
st.subheader("Current analytical state")
st.write({
"groups": list(selection.groups),
"start_day": selection.start_day,
"end_day": selection.end_day,
"selected_records": len(selected)
})
if selected.empty:
st.info(
"No observations match the current "
"selection. No summary statistic "
"has been calculated."
)
else:
fig = go.Figure()
styles = {
"Control": {
"symbol": "circle",
"dash": "solid",
"color": "#174a67"
},
"Treatment": {
"symbol": "square",
"dash": "dash",
"color": "#a43b28"
}
}
for group in selection.groups:
subset = selected.loc[
selected["group"] == group
].sort_values("day")
if subset.empty:
continue
style = styles[group]
fig.add_trace(
go.Scatter(
x=subset["day"],
y=subset["value"],
mode="lines+markers",
name=group,
line={
"dash": style["dash"],
"color": style["color"]
},
marker={
"symbol": style["symbol"],
"size": 10
},
customdata=subset[
["record_id"]
].to_numpy(),
hovertemplate=(
"Day %{x}"
"<br>Value %{y}"
"<br>Record %{customdata[0]}"
"<extra></extra>"
)
)
)
fig.update_layout(
title="Selected synthetic observations",
xaxis_title="Time (days)",
yaxis_title="Measurement (synthetic units)",
xaxis_range=[0, 14],
yaxis_range=[0, 20]
)
st.plotly_chart(
fig,
use_container_width=True
)
st.subheader("Selected numerical records")
st.dataframe(
selected,
hide_index=True
)
st.subheader("Descriptive statistics")
st.dataframe(summary)
manifest = {
"classification": "synthetic",
"status": "exploratory_not_reviewed",
"source": {
"dataset_id": SOURCE_ID,
"revision": SOURCE_REVISION,
"sha256": checksum
},
"analysis": {
"version": ANALYSIS_VERSION,
"selection": {
"groups": list(selection.groups),
"start_day": selection.start_day,
"end_day": selection.end_day
},
"record_ids": selected[
"record_id"
].tolist(),
"record_count": len(selected),
"statistics": summary,
"uncertainty": "not_estimated"
},
"rendering": {
"engine": "plotly",
"x_axis": "day",
"y_axis": "value",
"x_range": [0, 14],
"y_range": [0, 20]
},
"review": {
"numerical_acceptance": "not_tested",
"scientific_review": "not_tested",
"publication_approval": "not_approved"
}
}
st.subheader("Download analysis evidence")
st.download_button(
"Download analytical-state manifest",
data=json.dumps(
manifest,
indent=2
),
file_name="dashboard-state.json",
mime="application/json"
)
st.download_button(
"Download selected observations",
data=selected.to_csv(index=False),
file_name="selected-observations.csv",
mime="text/csv"
)
st.caption(
"Downloads preserve the current selection "
"as local artifacts. They do not constitute "
"server-side persistence or scientific approval."
)
The dashboard includes live filters, numerical recalculation, a data table, a graphical view, and downloadable evidence.
Streamlit’s local widget/session state should not be treated as durable research storage. Streamlit documents that session state is associated with a browser WebSocket connection and may reset when the connection is recreated (Streamlit, n.d.).
9. Launch the dashboard
From the project directory:
streamlit run app.py
Open the local address displayed by Streamlit. The default local development address is commonly http://localhost:8501, although the actual port can differ.
The expected interface includes:
- A source and verification-status section.
- Group-selection controls.
- An observation-interval slider.
- An interactive time-series chart.
- A selected-records table.
- Descriptive statistics.
- Analytical-state and data-download controls.
Use the actual locally running application to inspect these controls. This procedure is not a verified walkthrough of the Sustainable Catalyst website.
10. Verify filter behavior
Use the following manual test sequence.
| Selection | Expected result |
|---|---|
| Both groups, days 0–14 | Six records; control mean 11; treatment mean approximately 13.667 |
| Both groups, days 7–14 | Four records; control mean 11.5; treatment mean 15.5 |
| Control only, days 0–14 | Three control records; control mean 11 |
| Treatment only, days 7–14 | Two treatment records; treatment mean 15.5 |
| Both groups, days 1–6 | No matching observations; explicit empty state |
| No groups selected | No records; no invented numerical summary |
The observed record count must change consistently with the active filters. The source dataset and checksum should remain unchanged throughout these interactions.
11. Add automated analytical tests
Save as test_dashboard_analysis.py.
import numpy as np
import pandas as pd
import pytest
from dashboard_analysis import (
Selection,
analyze,
load_source,
source_checksum
)
def test_full_selection():
data = load_source()
selected, summary = analyze(
data,
Selection(
("Control", "Treatment"),
0, 14
)
)
assert len(selected) == 6
assert summary["Control"]["mean"] == 11.0
assert summary["Treatment"]["mean"] == (
pytest.approx(41 / 3)
)
def test_filtered_selection():
selected, summary = analyze(
load_source(),
Selection(
("Control", "Treatment"),
7, 14
)
)
assert len(selected) == 4
assert summary["Control"]["mean"] == 11.5
assert summary["Treatment"]["mean"] == 15.5
def test_empty_selection():
selected, summary = analyze(
load_source(),
Selection(
("Control",),
1, 6
)
)
assert selected.empty
assert summary == {}
def test_unknown_group_rejected():
with pytest.raises(ValueError):
analyze(
load_source(),
Selection(
("Unknown",),
0, 14
)
)
def test_invalid_interval_rejected():
with pytest.raises(ValueError):
analyze(
load_source(),
Selection(
("Control",),
14, 0
)
)
def test_duplicate_ids_rejected():
data = load_source()
data.loc[1, "record_id"] = "C00"
with pytest.raises(ValueError):
analyze(
data,
Selection(
("Control",),
0, 14
)
)
@pytest.mark.parametrize(
"invalid",
[np.nan, np.inf, -np.inf]
)
def test_invalid_values_rejected(invalid):
data = load_source()
data.loc[0, "value"] = invalid
with pytest.raises(ValueError):
analyze(
data,
Selection(
("Control",),
0, 14
)
)
def test_source_remains_unchanged():
data = load_source()
original = data.copy(deep=True)
analyze(
data,
Selection(
("Treatment",),
7, 14
)
)
pd.testing.assert_frame_equal(
data,
original
)
def test_checksum_deterministic():
data = load_source()
assert source_checksum(data) == (
source_checksum(load_source())
)
Run:
python -m pytest -v test_dashboard_analysis.py
The reference suite defines eleven individual test cases after expanding the parameterized non-finite-value test.
Passing numerical tests must be confirmed through execution. They do not replace browser interaction tests, access-control tests, accessibility review, or deployment acceptance.
12. Preserve reproducible analytical state
After selecting a view worth retaining, download both the analytical-state manifest and selected numerical records.
The two files serve different purposes:
- Analytical-state manifest: Records the source identifier, source revision, filters, selected record IDs, computed statistics, and declared review status.
- Selected records: Contains the actual numerical observations represented by the selected view.
For a more complete evidence package, also retain:
- The original authoritative dataset or immutable reference.
- The full analysis and dashboard code.
- The dependency lockfile.
- The actual plotting-library version.
- The chart specification and exported figure.
- The numerical validation report.
- Checksums of the archived artifacts.
The downloaded manifest is not automatically immutable, independently authenticated, or approved.
12.1 Review before publication
A governed research workflow should distinguish:
Exploratory selection
|
v
Recorded analytical snapshot
|
v
Numerical validation
|
v
Scientific interpretation review
|
v
Authorization and publication review
|
v
Approved research output
Do not change an exploratory status to approved merely because its numerical values pass a unit test.
13. Validate graphical presentation
Scientific dashboard graphics must faithfully represent the numerical state.
Check:
- Axis variable identity and units.
- Correct temporal or spatial ordering.
- Scale limits and transformations.
- Visible sample counts.
- Missing observations.
- Color and marker meaning.
- Interpolation and smoothing policies.
- Uncertainty representation.
- Figure captions and source citations.
In the reference example, lines connect successive observations for visual comparison. They should not be described as newly measured intermediate values.
If intermediate states are estimated, introduce a separate interpolation method and label derived values explicitly.
14. Add accessible descriptions and numerical equivalents
An interactive chart should not be the only representation of essential research information.
The example dashboard includes a numerical table, but additional accessibility review is necessary.
Recommended content includes:
- A descriptive chart title.
- Axis labels and scientific units.
- Non-color-only distinctions between series.
- An explanation of the displayed trend.
- A structured numerical table.
- Accessible filters and controls.
- Meaningful empty-state messages.
- Keyboard-accessible interactions.
- Appropriate focus and contrast behavior.
A suitable extended description of the full synthetic fixture is:
The control series increases from 10 to 12 synthetic units between days 0 and 14. The treatment series increases from 10 to 17 synthetic units over the same period. Both series contain three observations. The values are synthetic and do not support an inferential conclusion.
Descriptions must update or be clearly scoped when filters change. W3C guidance requires meaningful alternatives for non-text content and keyboard access to applicable controls (W3C, 2024).
15. Scientific uncertainty and responsible interpretation
The example does not estimate uncertainty because the fixture contains no replicate-level information or suitable sampling model.
A real research dashboard may need to display:
- Measurement uncertainty.
- Sample standard deviations.
- Confidence or credible intervals.
- Prediction intervals.
- Model ensemble spread.
- Spatial or temporal coverage uncertainty.
For each uncertainty representation, identify its definition, calculation, assumptions, units, and contributing observations.
Filtering observations may change both statistical estimates and their uncertainty.
Where uncertainty cannot be estimated appropriately, disclose that limitation rather than displaying an invented error bar or unjustified confidence interval.
16. Data access and export security
The educational example is intended for local execution with synthetic data. It is not configured for restricted research datasets or public multi-user deployment.
Production dashboards require controls for:
- Authentication and user authorization.
- Dataset-level and record-level permissions.
- Separation of user-specific analytical state.
- Safe handling of user-supplied filters.
- Prevention of cross-user cache leakage.
- Safe HTML and SVG output handling.
- Controlled analytical snapshot persistence.
- Approved publication and export permissions.
- Sanitized logging and error reporting.
Never assume that a hidden control prevents unauthorized data access. Authorization must be enforced by the data-serving layer.
Similarly, locally downloaded files may be edited after export. Governed publication requires separately verified artifact identity, retention, review, and approval controls.
17. Practical acceptance checklist
| Requirement | Pass condition |
|---|---|
| Research question | Dashboard supports a clearly defined analytical purpose |
| Source identification | Dataset ID, version, rights, and units documented |
| Filter correctness | Selections produce the expected record subset |
| Numerical summaries | Statistics reconcile with selected observations |
| Source preservation | Interaction does not mutate authoritative data |
| Missing-data handling | Empty and missing states are explicit |
| Graphical integrity | Marks and scales correspond to selected data |
| State disclosure | Active filters, source version, and sample count identifiable |
| Uncertainty | Correctly calculated or explicitly identified as unavailable |
| Evidence export | Selected values and analytical configuration can be retained |
| Reproducibility | Saved inputs and methods regenerate the required results |
| Accessibility | Essential controls and information pass applicable checks |
| Authorization | Access and export permissions enforced where applicable |
| Publication governance | Exploratory output remains separate from approved evidence |
Acceptance rule: Record each applicable requirement as Pass, Fail, or Not Tested. A dashboard cannot be designated publication-ready solely because the local application runs and its filters appear responsive.
18. Sustainable Catalyst application workflow
The following describes an intended cross-application workflow, not a verified set of deployed interfaces.
| Application | Intended role |
|---|---|
| Library | Register and preserve source data, versions, metadata, citations, and rights |
| Workbench | Execute reproducible calculations, transformations, and notebooks where implemented |
| Research Lab | Examine scientific methods, model assumptions, and quantitative evidence |
| Visualization & Graphing | Provide graphical encodings, interactive analytical views, and export methods |
| Site Intelligence | Supply spatial data and geographic analytical views where supported |
| Decision Studio | Support comparisons of modeled scenarios and decision evidence where implemented |
| Workspace | Manage analytical snapshots, ownership, validation, review, and release decisions |
| Research | Publish approved figures, analytical methods, datasets, and supporting references |
A proposed integrated workflow is:
Library
|
v
Source registration and verification
|
v
Workbench / scientific analysis
|
v
Interactive research dashboard
|
v
Selected and recorded analytical state
|
v
Workspace review and validation
|
v
Approved Research publication
Each transition requires an implemented and tested contract. The existence of an application or repository does not establish that the entire workflow is operational.
19. Source audit and deployment verification
Before publishing platform-specific dashboard instructions for Sustainable Catalyst, identify:
- Actual owning repository and code revision.
- Implemented dashboard framework and version.
- Data-serving API and schema.
- Source-artifact and analysis-result persistence mechanisms.
- Filter-state and session-state behavior.
- Numerical processing and renderer code paths.
- Authentication and authorization controls.
- Export formats and permission checks.
- Accessibility test results.
- Actual screenshots or inspected runtime artifacts.
- Executed acceptance receipts and known defects.
Until this evidence is available, treat the practical implementation as a reference example rather than a certified Sustainable Catalyst user-interface guide.
20. Technical references
- Streamlit (n.d.). Streamlit Documentation. Available at: https://docs.streamlit.io/.
- Streamlit (n.d.). Session State. Available at: Streamlit API documentation.
- Plotly Technologies Inc. (n.d.). Graph Objects in Python. Available at: Plotly documentation.
- Vega-Lite Developers (n.d.). Selection Parameters. Available at: Vega-Lite documentation.
- McKinney, W. (2010). ‘Data Structures for Statistical Computing in Python’, Proceedings of the 9th Python in Science Conference, pp. 56–61. Available at: https://doi.org/10.25080/Majora-92bf1922-00a.
- Harris, C.R. et al. (2020). ‘Array programming with NumPy’, Nature, 585, pp. 357–362. Available at: https://doi.org/10.1038/s41586-020-2649-2.
- pytest Development Team (n.d.). pytest Documentation. Available at: https://docs.pytest.org/en/stable/.
- World Wide Web Consortium (W3C) (2024). Web Content Accessibility Guidelines (WCAG) 2.2. Available at: https://www.w3.org/TR/WCAG22/.
- OWASP Foundation (n.d.). Cross Site Scripting Prevention Cheat Sheet. Available at: OWASP Cheat Sheet Series.
21. Completion and verification record
Document the actual results of the practical exercise or platform-specific implementation.
| Field | Required evidence |
|---|---|
| Dashboard identifier | Application, component, and revision |
| Source data | Dataset ID, version, and checksum |
| Filter tests | Pass, Fail, or Not Tested |
| Numerical validation | Pass, Fail, or Not Tested |
| Source immutability | Pass, Fail, or Not Tested |
| Rendering verification | Pass, Fail, or Not Tested |
| Export integrity | Pass, Fail, or Not Tested |
| Snapshot reproducibility | Pass, Fail, or Not Tested |
| Accessibility | Pass, Fail, or Not Tested |
| Authorization | Pass, Fail, or Not Tested |
| Scientific review | Pass, Fail, or Not Tested |
| Publication approval | Approved, Not Approved, or Not Applicable |
| Reviewer | Actual reviewer and date |
| Evidence artifacts | Code, selected records, manifest, screenshots, logs, and test receipts |
| Outstanding limitations | Unresolved software or scientific concerns |
Completion criterion: The dashboard must implement transparent filtering, preserve authoritative source data, produce independently checkable numerical results, disclose its analytical state, and provide reproducible evidence for any result selected for further scientific review.
Scientific limitation: An interactive dashboard supports exploration and comparison but cannot independently correct biased sampling, establish causal relationships, validate model assumptions, or justify inferential statistical claims.
Current implementation status: Practical reference workflow, synthetic dataset, analytical module, example Streamlit interface, downloadable state manifest, and automated test definitions documented. No Sustainable Catalyst production dashboard, persistent snapshot system, or publication approval workflow is certified without source-code inspection, executed integration tests, runtime verification, and release-specific acceptance evidence.
