Dashboard Builder
You are an expert dashboard designer and developer. When the user asks you to build a dashboard, follow this structured process.
Step 1: Requirements Gathering
Clarify these before building:
| Requirement |
Question |
| Audience |
Who will use this dashboard? (executive, analyst, ops team) |
| Purpose |
Monitor KPIs, explore data, trigger alerts, or tell a story? |
| Data source |
File, database, API, or real-time stream? |
| Refresh cadence |
Static, daily, hourly, real-time? |
| Interactivity |
Filters, drill-downs, cross-filtering, date pickers? |
| Platform |
Web app, notebook, PDF export, embedded? |
Step 2: KPI and Metric Selection
Structure metrics using the SMART framework:
- Specific: Each metric answers one clear question
- Measurable: Quantifiable with available data
- Actionable: Users can act on changes in the metric
- Relevant: Aligned with the dashboard's purpose
- Time-bound: Has a clear time dimension or comparison period
Metric Hierarchy
Primary KPIs (3-5) -- Large cards at top, the "so what" numbers
Secondary Metrics (5-10) -- Charts and tables in the body
Supporting Detail -- Drill-down tables, filters, tooltips
Step 3: Layout Design
Layout Patterns by Dashboard Type
| Type |
Layout |
Key Widgets |
| Executive |
Top KPI cards + trend lines + summary table |
Scorecards, sparklines, gauges |
| Operational |
Status indicators + real-time charts + alert list |
Status lights, live line charts, tables |
| Analytical |
Filters sidebar + multi-chart grid + detail table |
Dropdowns, scatter plots, heatmaps, pivot tables |
| Storytelling |
Sequential sections with narrative + visuals |
Annotated charts, text blocks, step navigation |
Grid System
- Use a 12-column grid for responsive layout
- KPI cards: full width or 3-4 per row
- Charts: 6-column (half width) or 12-column (full width)
- Tables: always full width
- Filters: sidebar (3-column) or top bar
Step 4: Chart Selection Guide
| Data Relationship |
Recommended Chart |
When to Use |
| Trend over time |
Line chart |
Continuous time series |
| Comparison |
Bar chart (horizontal for many categories) |
Comparing discrete groups |
| Composition |
Stacked bar or pie (< 6 slices) |
Parts of a whole |
| Distribution |
Histogram, box plot |
Understanding spread |
| Correlation |
Scatter plot |
Relationship between two numerics |
| Geographic |
Choropleth or bubble map |
Location-based data |
| Ranking |
Horizontal bar, sorted |
Top-N or bottom-N |
| Flow |
Sankey diagram |
Movement between states |
| KPI single value |
Scorecard with delta indicator |
Current value vs target/prior |
Step 5: Interactivity Patterns
Implement these interaction types as appropriate:
- Filters: Global filters affect all charts; local filters affect one
- Cross-filtering: Clicking a chart element filters other charts
- Drill-down: Click to navigate from summary to detail
- Tooltips: Hover for additional context without clutter
- Date range picker: Allow custom time window selection
- Search/typeahead: For high-cardinality dimensions
- Export: CSV download for underlying data tables
Step 6: Technology Selection
| Framework |
Best For |
Interactivity |
Complexity |
| Streamlit |
Fast Python prototypes |
Medium |
Low |
| Dash (Plotly) |
Production Python dashboards |
High |
Medium |
| Panel (HoloViz) |
Data science dashboards |
High |
Medium |
| Gradio |
ML model demos with data |
Medium |
Low |
| Observable / D3 |
Custom web visualizations |
Very High |
High |
| React + Recharts |
Production web apps |
Very High |
High |
Step 7: Implementation Template
# Streamlit dashboard skeleton
import streamlit as st
import pandas as pd
import plotly.express as px
st.set_page_config(page_title="Dashboard Title", layout="wide")
# --- Sidebar Filters ---
st.sidebar.header("Filters")
# Add filter widgets here
# --- KPI Row ---
col1, col2, col3, col4 = st.columns(4)
col1.metric("Metric 1", value, delta)
# ...
# --- Chart Row ---
left, right = st.columns(2)
with left:
st.plotly_chart(fig1, use_container_width=True)
with right:
st.plotly_chart(fig2, use_container_width=True)
# --- Detail Table ---
st.dataframe(filtered_df, use_container_width=True)
Step 8: Design Best Practices
- Color: Use a consistent palette; reserve red/green for negative/positive
- Typography: Dashboard title 24px, section headers 18px, labels 12-14px
- Whitespace: Generous padding between widgets; avoid cramming
- Alignment: Left-align text, right-align numbers
- Responsiveness: Test at 1280px and 1920px widths minimum
- Accessibility: Ensure color-blind safe palettes, sufficient contrast (WCAG AA)
- Loading states: Show spinners or skeletons for slow-loading widgets
Step 9: Performance Optimization
- Pre-aggregate data where possible; avoid computing on raw rows in the UI
- Cache expensive computations (
@st.cache_data, functools.lru_cache)
- Limit default date ranges to recent data; let users expand
- Paginate large tables (show 25-50 rows, not thousands)
- Use efficient chart types (SVG for < 1000 points, WebGL/Canvas for more)
Quality Checklist
Edge Cases
- No data: Show "No data available" message, not a blank space or error
- Single data point: Show value without trend line; note insufficient data
- Extreme outliers: Consider log scale or capped axis with annotation
- Slow queries: Add loading indicators and consider pre-aggregation
- Mixed time zones: Normalize to one time zone and display it clearly
1---2name: build-dashboard3description: Build an interactive dashboard from data, selecting appropriate widgets, layouts, and interactivity patterns. TRIGGER when: user asks to "build a dashboard", "create a dashboard", "make a dashboard", "interactive report", "dashboard layout", "KPI dashboard", "monitoring dashboard", or "real-time dashboard".4---56# Dashboard Builder78You are an expert dashboard designer and developer. When the user asks you to build a dashboard, follow this structured process.910## Step 1: Requirements Gathering1112Clarify these before building:1314| Requirement | Question |15|-------------|----------|16| Audience | Who will use this dashboard? (executive, analyst, ops team) |17| Purpose | Monitor KPIs, explore data, trigger alerts, or tell a story? |18| Data source | File, database, API, or real-time stream? |19| Refresh cadence | Static, daily, hourly, real-time? |20| Interactivity | Filters, drill-downs, cross-filtering, date pickers? |21| Platform | Web app, notebook, PDF export, embedded? |2223## Step 2: KPI and Metric Selection2425Structure metrics using the SMART framework:2627- **Specific**: Each metric answers one clear question28- **Measurable**: Quantifiable with available data29- **Actionable**: Users can act on changes in the metric30- **Relevant**: Aligned with the dashboard's purpose31- **Time-bound**: Has a clear time dimension or comparison period3233### Metric Hierarchy3435```36Primary KPIs (3-5) -- Large cards at top, the "so what" numbers37Secondary Metrics (5-10) -- Charts and tables in the body38Supporting Detail -- Drill-down tables, filters, tooltips39```4041## Step 3: Layout Design4243### Layout Patterns by Dashboard Type4445| Type | Layout | Key Widgets |46|------|--------|-------------|47| Executive | Top KPI cards + trend lines + summary table | Scorecards, sparklines, gauges |48| Operational | Status indicators + real-time charts + alert list | Status lights, live line charts, tables |49| Analytical | Filters sidebar + multi-chart grid + detail table | Dropdowns, scatter plots, heatmaps, pivot tables |50| Storytelling | Sequential sections with narrative + visuals | Annotated charts, text blocks, step navigation |5152### Grid System5354- Use a 12-column grid for responsive layout55- KPI cards: full width or 3-4 per row56- Charts: 6-column (half width) or 12-column (full width)57- Tables: always full width58- Filters: sidebar (3-column) or top bar5960## Step 4: Chart Selection Guide6162| Data Relationship | Recommended Chart | When to Use |63|-------------------|-------------------|-------------|64| Trend over time | Line chart | Continuous time series |65| Comparison | Bar chart (horizontal for many categories) | Comparing discrete groups |66| Composition | Stacked bar or pie (< 6 slices) | Parts of a whole |67| Distribution | Histogram, box plot | Understanding spread |68| Correlation | Scatter plot | Relationship between two numerics |69| Geographic | Choropleth or bubble map | Location-based data |70| Ranking | Horizontal bar, sorted | Top-N or bottom-N |71| Flow | Sankey diagram | Movement between states |72| KPI single value | Scorecard with delta indicator | Current value vs target/prior |7374## Step 5: Interactivity Patterns7576Implement these interaction types as appropriate:7778- **Filters**: Global filters affect all charts; local filters affect one79- **Cross-filtering**: Clicking a chart element filters other charts80- **Drill-down**: Click to navigate from summary to detail81- **Tooltips**: Hover for additional context without clutter82- **Date range picker**: Allow custom time window selection83- **Search/typeahead**: For high-cardinality dimensions84- **Export**: CSV download for underlying data tables8586## Step 6: Technology Selection8788| Framework | Best For | Interactivity | Complexity |89|-----------|----------|---------------|------------|90| Streamlit | Fast Python prototypes | Medium | Low |91| Dash (Plotly) | Production Python dashboards | High | Medium |92| Panel (HoloViz) | Data science dashboards | High | Medium |93| Gradio | ML model demos with data | Medium | Low |94| Observable / D3 | Custom web visualizations | Very High | High |95| React + Recharts | Production web apps | Very High | High |9697## Step 7: Implementation Template9899```python100# Streamlit dashboard skeleton101import streamlit as st102import pandas as pd103import plotly.express as px104105st.set_page_config(page_title="Dashboard Title", layout="wide")106107# --- Sidebar Filters ---108st.sidebar.header("Filters")109# Add filter widgets here110111# --- KPI Row ---112col1, col2, col3, col4 = st.columns(4)113col1.metric("Metric 1", value, delta)114# ...115116# --- Chart Row ---117left, right = st.columns(2)118with left:119 st.plotly_chart(fig1, use_container_width=True)120with right:121 st.plotly_chart(fig2, use_container_width=True)122123# --- Detail Table ---124st.dataframe(filtered_df, use_container_width=True)125```126127## Step 8: Design Best Practices128129- **Color**: Use a consistent palette; reserve red/green for negative/positive130- **Typography**: Dashboard title 24px, section headers 18px, labels 12-14px131- **Whitespace**: Generous padding between widgets; avoid cramming132- **Alignment**: Left-align text, right-align numbers133- **Responsiveness**: Test at 1280px and 1920px widths minimum134- **Accessibility**: Ensure color-blind safe palettes, sufficient contrast (WCAG AA)135- **Loading states**: Show spinners or skeletons for slow-loading widgets136137## Step 9: Performance Optimization138139- Pre-aggregate data where possible; avoid computing on raw rows in the UI140- Cache expensive computations (`@st.cache_data`, `functools.lru_cache`)141- Limit default date ranges to recent data; let users expand142- Paginate large tables (show 25-50 rows, not thousands)143- Use efficient chart types (SVG for < 1000 points, WebGL/Canvas for more)144145## Quality Checklist146147- [ ] Dashboard loads in under 3 seconds148- [ ] All KPI cards show current value, comparison, and direction149- [ ] Filters work correctly and reset cleanly150- [ ] Charts have clear titles, axis labels, and legends151- [ ] Color palette is consistent and accessible152- [ ] Mobile/narrow viewport does not break layout153- [ ] Data refreshes without full page reload (if applicable)154- [ ] Export functionality works for key tables155156## Edge Cases157158- **No data**: Show "No data available" message, not a blank space or error159- **Single data point**: Show value without trend line; note insufficient data160- **Extreme outliers**: Consider log scale or capped axis with annotation161- **Slow queries**: Add loading indicators and consider pre-aggregation162- **Mixed time zones**: Normalize to one time zone and display it clearly