Skill 详情
creating-dashboards
Direct dashboard interface design and implementation guidance.
使用前先检查
自动化审核只检查相关性,不代表安全审查或推荐。使用前请阅读来源中的说明。
SKILL.md
这段内容是审核时保存的快照。外部来源才是完整且最新的版本。
---
name: creating-dashboards
description: Creates comprehensive dashboard and analytics interfaces that combine data visualization, KPI cards, real-time updates, and interactive layouts. Use this skill when building business intelligence dashboards, monitoring systems, executive reports, or any interface that requires multiple coordinated data displays with filters, metrics, and visualizations working together.
---
# Creating Dashboards
## Purpose
This skill enables the creation of sophisticated dashboard interfaces that aggregate and present data through coordinated widgets including KPI cards, charts, tables, and filters. Dashboards serve as centralized command centers for data-driven decision making, combining multiple component types from other skills (data-viz, tables, design-tokens) into unified analytics experiences with real-time updates, responsive layouts, and interactive filtering.
## When to Use
Activate this skill when:
- Building business intelligence or analytics dashboards
- Creating executive reporting interfaces
- Implementing real-time monitoring systems
- Designing KPI displays with metrics and trends
- Developing customizable widget-based layouts
- Coordinating filters across multiple data displays
- Building responsive data-heavy interfaces
- Implementing drag-and-drop dashboard editors
- Creating template-based analytics systems
- Designing multi-tenant SaaS dashboards
## Core Dashboard Elements
### KPI Card Anatomy
```
┌────────────────────────────┐
│ Revenue (This Month) │ ← Label with time period
│ │
│ $1,245,832 │ ← Big number (primary metric)
│ ↑ 15.3% vs last month │ ← Trend indicator with comparison
│ ▂▃▅▆▇█ (sparkline) │ ← Mini visualization
└────────────────────────────┘
```
### Widget Container Structure
- Title bar with widget name and actions
- Loading state (skeleton or spinner)
- Error boundary with retry option
- Resize handles for adjustable layouts
- Settings menu (export, configure, refresh)
### Dashboard Layout Types
**Fixed Layout**: Designer-defined placement, consistent across users
**Customizable Grid**: User drag-and-drop, resizable widgets, saved layouts
**Template-Based**: Pre-built patterns, industry-specific starting points
### Global Dashboard Controls
- Date range picker (affects all widgets)
- Filter panel (coordinated across widgets)
- Refresh controls (manual/auto-refresh)
- Export actions (PDF, image, data)
- Theme switcher (light/dark/custom)
## Implementation Approach
### 1. Choose Dashboard Architecture
**For Quick Analytics Dashboard → Use Tremor**
Pre-built KPI cards, charts, and tables with minimal code:
```bash
npm install @tremor/react
```
**For Customizable Dashboard → Use react-grid-layout**
Drag-and-drop, resizable widgets, user-defined layouts:
```bash
npm install react-grid-layout
```
### 2. Set Up Global State Management
Implement filter context for cross-widget coordination:
```tsx
// Dashboard context for shared filters
const DashboardContext = createContext({
filters: { dateRange: null, categories: [] },
setFilters: () => {},
refreshInterval: 30000
});
// Wrap dashboard with provider
<DashboardContext.Provider value={dashboardState}>
<FilterPanel />
<WidgetGrid />
</DashboardContext.Provider>
```
### 3. Implement Data Fetching Strategy
**Parallel Loading**: Fetch all widget data simultaneously
**Lazy Loading**: Load visible widgets first, others on scroll
**Cached Updates**: Serve from cache while fetching fresh data
### 4. Configure Real-Time Updates
**Server-Sent Events (Recommended for Dashboards)**:
```tsx
const eventSource = new EventSource('/api/dashboard/stream');
eventSource.onmessage = (event) => {
const update = JSON.parse(event.data);
updateWidget(update.widgetId, update.data);
};
```
### 5. Apply Responsive Design
Define breakpoints for different screen sizes:
- Desktop (>1200px): Multi-column grid
- Tablet (768-1200px): 2-column layout
- Mobile 在 GitHub 阅读完整来源 (打开外部页面)