Before the questions, make sure you can: define a dashboard and distinguish operational, analytical and strategic dashboards; design a dashboard from its audience and task chain; present KPIs with context and compute week-over-week changes and target gaps; lay out panels by priority and keep information density manageable; explain Streamlit's rerun model, caching with TTL and session state; build and test a small Streamlit dashboard; compare code frameworks with BI tools; and plan deployment, security and data freshness.
A dashboard is where everything in this course meets a real user: data acquisition, task analysis, encoding, interaction — on one screen, refreshed with live data, used under time pressure. AI copilots can now generate a whole dashboard from a sentence, and the result usually has the same problems: too many charts, numbers without context, no clear first view, and no idea how fresh the data is. A good dashboard is not a collection of charts; it is a designed product for a specific audience and decision.
What a dashboard is
Stephen Few's classic definition: a visual display of the most important information needed to achieve one or more objectives, consolidated and arranged on a single screen so it can be monitored at a glance. Research has since shown much more variety (Sarikaya et al., IEEE VIS 2018, "What do we talk about when we talk about dashboards?"): dashboards for operations, analysis, strategy, communication to the public, and personal tracking, with different needs for interactivity, freshness and narrative.
| Genre | Users | Time scale | Example (CityPulse) |
|---|---|---|---|
| Operational | operators, on-call staff | seconds–minutes | bike stations empty now, sensor failures |
| Analytical | analysts | days–months | which factors drive trips? |
| Strategic | managers, officials | months–years | air quality vs. targets by district |
| Public / communicative | citizens | today | "Is it safe to run?" |
Design from tasks, not from data
Start with the audience and their task chain (Chapter 3): what must they see first (the overview or the alert), what do they do next (locate, identify, compare), and what decision follows? Then:
- Visual hierarchy: put the most important panel where the eye starts (top-left in left-to-right cultures); size and position follow priority; group related panels.
- One screen, few panels: Few's guidance is a single screen; beyond roughly 7–9 panels, users stop seeing the whole.
- Consistent encodings: the same colour means the same district everywhere; shared time ranges.
- Text matters: clear titles that state what is shown, units, short annotations for events.
KPIs need context
A number alone ("1,333 trips per day") is not information. Give it context:
- comparison with the previous period (+8.7 % vs. last week), the same period last year, or a benchmark;
- target and status (−11.1 % vs. a target of 1,500 → off track);
- direction of "good": more trips is better, more PM2.5 is worse — colour deltas accordingly (Streamlit:
delta_color="inverse"); - trend: a sparkline (Tufte's word-sized graphic) shows the last 14 days in a few characters: ▅▆▅▆▇▁▁▆▇▆▇█▂▂ — the weekend dips are obvious.
Few's bullet graph replaces gauges and speedometers: one bar for the measure, a tick for the target, background bands for qualitative ranges — compact, comparable, honest (length on a common scale).
Data freshness and trust
Every dashboard must say how fresh its data is ("updated 09:15"), and what happens when a source fails ("bike data unavailable since 08:40"). Operational dashboards need near-real-time data; strategic ones daily or monthly data — mixing them without labels causes wrong decisions.
Tools: frameworks and BI
| Tool | Model | Good for |
|---|---|---|
| Streamlit | Python script re-run top to bottom on every interaction | fast data apps and prototypes, ML demos |
| Dash (Plotly) | layout + callbacks (Input → Output) | complex production apps with fine control |
| Panel (HoloViz), Bokeh server | widgets + Python callbacks | scientific apps, large data with HoloViz tools |
| Tableau, Power BI | drag-and-drop BI | business users, governance, enterprise data |
| Apache Superset, Metabase | open-source BI on SQL databases | self-hosted analytics |
| Grafana | time-series panels on monitoring data | operations and observability (Chapter 13) |
Code frameworks give flexibility, versioning and testing; BI tools give speed for standard charts and governance (permissions, certified data). Many organizations use both.
Streamlit essentials
import streamlit as st
@st.cache_data(ttl=300) # re-query at most every 5 minutes
def load(district):
return pd.read_sql_query("SELECT ... WHERE district = ?", con, params=(district,))
district = st.selectbox("District", districts) # every change re-runs the script
df = load(district)
c1, c2 = st.columns(2)
c1.metric("Latest PM2.5", f"{latest:g}", f"{delta:+g}", delta_color="inverse")
c2.metric("Days above 35", n_bad)
st.altair_chart(chart)
st.caption(f"Data up to {last_time:%Y-%m-%d %H:%M}")
- Rerun model: each widget change re-executes the whole script — simple to reason about, but slow steps must be cached.
st.cache_datacaches returned data (keyed by arguments, optionalttl);st.cache_resourcecaches shared resources (database connections, ML models).st.session_statekeeps values across reruns for one user (e.g., a selected station).- Secrets (database passwords, API keys) go in
.streamlit/secrets.tomlor environment variables, never in the code. - Testing:
streamlit.testing.v1.AppTestruns the app headless, lets you set widget values and check the displayed metrics — dashboards can have automated tests (Lab V9.2).
Caching trades speed for staleness: with a 5-minute TTL, users may see data up to 299 s old, but the database answers 4 queries instead of 7 in Lab V9.3's example. Choose the TTL from the task (operational: short; strategic: long) and show the data time.
Deployment and performance
Options: Streamlit Community Cloud or Hugging Face Spaces (public demos), a Docker container on a university or company server, BI platforms' own servers. Production concerns: authentication (who may see which data), performance (aggregate in the database, cache, avoid sending raw rows to the browser), monitoring (errors, slow queries), cost, and accessibility (Chapter 6).
BI vendors now ship AI copilots that create dashboards and summaries from natural language (Power BI Copilot, Tableau Pulse, Looker with Gemini). They speed up drafting, but organizations still need certified metrics (one agreed definition of "active user"), data governance and human review — otherwise each AI-generated dashboard computes a slightly different number.
Dashboard research studies how people actually read dashboards (eye tracking shows they rarely look at everything), how to adapt layouts to screen sizes, and how to generate dashboards automatically from data and tasks. Several studies find that automatically generated dashboards need human curation of what matters — the task and priority decisions this chapter emphasizes.
Key takeaways
- Dashboards serve specific audiences and tasks: operational, analytical, strategic, public.
- Hierarchy (most important top-left), few panels, consistent encodings, clear text.
- KPIs need context: comparisons, targets, direction of good, trend (sparklines, bullet graphs).
- Show data freshness; handle source failures visibly.
- Streamlit: rerun model,
cache_data/cache_resourcewith TTL,session_state, secrets, AppTest for automated tests; Dash, Panel, Bokeh server, BI tools for other needs. - Deploy with authentication, performance (aggregate and cache) and monitoring in mind.
Ready? Close the notes and practise.
30 questions. Predict the output before you check — that is the skill the exam measures.