Data Visualization Mastery
Why Data Visualization Mastery Matters
Data visualization is the art and science of encoding information visually so humans can perceive patterns, outliers, and trends faster than reading raw numbers. A poorly chosen chart misleads. A poorly designed chart confuses. A well-designed chart tells the truth instantly. This skill codifies the principles of Edward Tufte, Stephen Few, Jacques Bertin, and Tamara Munzner into a systematic framework for building data-dense UIs that are beautiful, honest, and accessible.
The gap between a developer-built dashboard and a professionally designed data experience is systematic craft: choosing the right chart type, encoding data correctly, managing visual hierarchy across dozens of data points, and ensuring every pixel of ink serves the data.
Reference Architecture
| File |
Contents |
Use When |
references/chart-type-encyclopedia.md |
50+ chart types organized by purpose (comparison, trend, distribution, relationship, part-to-whole, flow, geo, hierarchy). Each chart: when to use, when NOT to use, data shape, max data points, design specs (colors, spacing, typography, gridlines), accessibility notes, thumbnail description. |
Selecting the right chart for a dataset. Reviewing chart design specs. Auditing chart choices in an existing UI. |
references/dashboard-layout-patterns.md |
30+ dashboard layout patterns: KPI rows, chart grids, filter bars, drill-down hierarchies, real-time monitoring, executive summary, operational, analytical, mobile card-stack. Each: CSS grid layout, spacing, component hierarchy, responsive collapse strategy. |
Designing dashboard layouts. Reviewing dashboard information architecture. Building responsive analytics UIs. |
references/data-table-mastery.md |
Complete data table design system: anatomy, column types (15+), sorting, filtering, pagination, selection, expansion, fixed headers, inline editing, cell formatting, empty/loading states, responsive strategies, density modes, full accessibility spec, production React/TypeScript code. |
Designing or building data tables. Auditing table usability. Adding features to existing tables. |
references/dataviz-accessibility.md |
Dataviz accessibility: alt text patterns for every chart type, data table alternatives, 8 colorblind-safe palettes with hex codes, pattern fills, high contrast mode, screen reader announcements, keyboard navigation, sonification, WCAG success criteria mapping. |
Making charts accessible. Auditing dataviz accessibility. Building inclusive dashboards. |
references/dataviz-code-patterns.md |
Production code for top 20 chart types using Recharts (React). Chart wrapper component with loading/error/empty states. Design tokens for dataviz. Responsive containers. Theme integration. Tooltip and legend customization. Print styles. |
Implementing charts in React. Building chart component libraries. Setting up dataviz design tokens. |
Cross-References
visual-design-mastery -- Color science (oklch, palette generation) applies directly to dataviz color palettes. Typography mastery (tabular figures, alignment) is critical for number-heavy UIs.
ui-pattern-intelligence -- Dashboard and table patterns at the component level. This skill provides the deeper dataviz-specific design intelligence.
accessibility-inclusive-design -- WCAG foundation. This skill extends it with dataviz-specific accessibility patterns.
component-patterns-code -- Component architecture. This skill provides dataviz-specific component patterns and code.
design-systems-architecture -- Token architecture. This skill defines dataviz-specific tokens (chart colors, gridlines, axes).
performance-states-patterns -- Loading, error, and empty states apply to every chart and table component.
cognitive-psychology-ux -- Perceptual principles (pre-attentive processing, Gestalt grouping) underpin all visual encoding decisions.
1. Foundational Principles
1.1 Edward Tufte's Core Principles
Data-Ink Ratio: Maximize the share of ink devoted to data. Every pixel that does not encode data should be questioned and likely removed. Remove chartjunk: decorative gridlines, 3D effects, gradient fills, drop shadows on bars, unnecessary legends, redundant labels.
Data-Ink Ratio = (Data Ink) / (Total Ink Used in the Graphic)
Target: > 0.8
Lie Factor: The size of an effect shown in the graphic divided by the size of the effect in the data. A lie factor of 1.0 is truthful. Above 1.05 or below 0.95 is distortion.
Lie Factor = (Size of effect in graphic) / (Size of effect in data)
Acceptable range: 0.95 - 1.05
Chartjunk Checklist -- Remove These:
- 3D effects on 2D data (bars, pies)
- Gradient fills that imply data variation where none exists
- Decorative background images
- Heavy gridlines that compete with data
- Redundant legends (when labels are directly on data)
- Unnecessary borders and boxes
- Excessive decimal places
- Animated entrances that delay comprehension
Small Multiples: When comparing across categories or time periods, use small multiples (the same chart repeated with different data) rather than cramming everything into one chart. Same scale, same axes, same visual encoding -- only the data changes.
1.2 Visual Encoding Hierarchy (Jacques Bertin + Cleveland & McGill)
Humans decode visual channels with different accuracy. Always use the most accurate channel for the most important data dimension:
MOST ACCURATE (use first)
1. Position on a common scale (bar chart, dot plot, scatter plot)
2. Position on non-aligned scales (small multiples)
3. Length (bar chart)
4. Direction / Angle (slope, but NOT pie chart angles)
5. Area (bubble chart, treemap)
6. Volume (3D -- almost never use)
7. Color saturation / Luminance (heatmap, choropleth)
8. Color hue (categorical encoding only)
LEAST ACCURATE (use last)
Practical implication: A bar chart (position + length) will ALWAYS be more accurately read than a pie chart (angle + area). Use pie charts only when part-to-whole relationship matters more than precise comparison, and only with 2-5 slices.
1.3 Stephen Few's Dashboard Design Principles
- Fit on a single screen -- no scrolling for the primary view
- Group related information using Gestalt proximity and enclosure
- Place the most important information top-left (F-pattern scanning)
- Use consistent visual encoding across all charts on the dashboard
- Provide context -- comparison values, targets, historical ranges
- Highlight what matters -- use pre-attentive attributes (color, size) to draw attention to exceptions, not to decorate
- Minimize non-data pixels -- every border, background, and separator should earn its place
- Support progressive disclosure -- summary first, details on demand
1.4 Tamara Munzner's Nested Model
Four levels of visualization design, each validated differently:
| Level |
Question |
Validation |
| Domain situation |
Who are the users? What are their tasks? |
Observe users in context |
| Data/task abstraction |
What data types? What analytical tasks? |
Test task completion |
| Visual encoding/interaction |
What marks and channels? What interactions? |
Perceptual experiments |
| Algorithm |
How to compute and render efficiently? |
Performance benchmarks |
2. Chart Selection Decision Framework
2.1 By Analytical Purpose
| Purpose |
Best Charts |
Avoid |
| Compare values |
Bar (horizontal for many categories), Column, Dot plot, Lollipop |
Pie (bad for comparison), Radar (distorts) |
| Show trend over time |
Line, Area, Sparkline, Slope chart |
Bar (unless discrete periods), Pie |
| Show part-to-whole |
Stacked bar (100%), Treemap, Donut (2-5 parts), Waffle |
Pie (>5 slices), Stacked area (hard to read middle layers) |
| Show distribution |
Histogram, Box plot, Violin, Density, Strip plot |
Bar chart (not the same as histogram) |
| Show relationship |
Scatter, Bubble, Correlation matrix |
Line chart (implies time sequence) |
| Show flow/process |
Sankey, Funnel, Alluvial |
Pie, Bar |
| Show geographic data |
Choropleth, Bubble map, Heat map |
Bar chart (loses spatial context) |
| Show hierarchy |
Treemap, Sunburst, Circle packing, Dendrogram |
Pie (flat, no hierarchy) |
| Show composition over time |
Stacked area, Stream graph |
Multiple pie charts over time |
2.2 By Data Shape
| Data Shape |
Recommended |
| 1 number (KPI) |
KPI card with delta, sparkline, context |
| 1 categorical + 1 quantitative |
Bar/Column chart |
| 1 time + 1 quantitative |
Line chart |
| 1 time + multiple quantitative |
Multi-series line, Small multiples |
| 2 quantitative |
Scatter plot |
| 3 quantitative |
Bubble chart (3rd = size) |
| 1 categorical + parts |
Stacked bar, Treemap |
| Hierarchical categories + 1 quantitative |
Treemap, Sunburst |
| Source to Target + flow magnitude |
Sankey diagram |
| Geographic + 1 quantitative |
Choropleth |
| Matrix (rows x cols x value) |
Heatmap |
2.3 By Audience
| Audience |
Approach |
| Executive |
KPI cards, sparklines, single-number summaries, traffic lights. Max 5-7 data points visible. Summary first, drill-down available. |
| Analyst |
Interactive charts, filters, cross-filtering, tooltips with detail. Support exploration. Higher data density acceptable. |
| General public |
Simple charts (bar, line, donut). Annotations explaining "what this means." No jargon. Large text. |
| Domain expert |
Specialized chart types acceptable (candlestick for finance, survival curves for medicine). Dense data OK. |
3. Color for Data Visualization
3.1 Palette Types
Sequential (low to high): Single hue varying in lightness. Use for ordered data (temperature, population, revenue).
Example (Blue sequential):
#f7fbff -> #deebf7 -> #c6dbef -> #9ecae1 -> #6baed6 -> #4292c6 -> #2171b5 -> #084594
Diverging (negative <- neutral -> positive): Two hues diverging from a neutral midpoint. Use for data with a meaningful center (profit/loss, above/below average, sentiment).
Example (Red-Blue diverging):
#b2182b -> #d6604d -> #f4a582 -> #fddbc7 -> #f7f7f7 -> #d1e5f0 -> #92c5de -> #4393c3 -> #2166ac
Categorical (distinct groups): Maximally distinct hues at similar lightness. Use for nominal categories (product lines, regions, user segments). Maximum 8-10 colors before confusion.
Colorblind-safe categorical (8 colors):
#4e79a7 #f28e2b #e15759 #76b7b2 #59a14f #edc948 #b07aa1 #ff9da7
(Tableau 10 subset -- optimized for distinguishability including colorblind viewers)
3.2 Colorblind-Safe Design Rules
- Never use red/green as the only differentiator -- 8% of males have red-green deficiency
- Use lightness variation in addition to hue -- colorblind viewers can still distinguish light from dark
- Add redundant encoding -- patterns, labels, icons, or position in addition to color
- Test with simulation -- Sim Daltonism (macOS), Color Oracle, or Figma colorblind plugins
- Use pre-tested palettes -- see
references/dataviz-accessibility.md for 8 verified palettes
3.3 Color Assignment Rules
- Semantic colors should be respected: red = danger/loss/down, green = success/gain/up, blue = information/neutral, yellow/amber = warning
- Gray for context, saturated color for focal data -- e.g., gray bars for all categories, blue bar for the selected one
- Consistent mapping -- if "Product A" is blue on chart 1, it must be blue on chart 2
- White/light background for charts -- data should be the most visually prominent element
- No more than 8 categorical colors -- group remaining into "Other"
4. Typography for Data-Dense UI
4.1 Tabular (Monospace) Figures
Numbers in tables and charts MUST use tabular figures (all digits occupy the same width) so columns align perfectly. Most professional fonts include a font-feature-settings: "tnum" OpenType feature.
/* Enable tabular figures for all data displays */
.dataviz-number,
.table-cell-number,
.kpi-value {
font-feature-settings: "tnum" 1;
font-variant-numeric: tabular-nums;
}
Fonts with excellent tabular figures: Inter, IBM Plex Sans, Roboto, SF Pro, DM Sans, JetBrains Mono.
4.2 Number Formatting Rules
| Context |
Format |
Example |
| Currency |
Symbol + comma grouping + 2 decimal |
$1,234,567.89 |
| Large currency |
Abbreviate with suffix |
$1.2M, $3.4B |
| Percentage |
1 decimal max, % symbol |
45.2% |
| Large numbers |
Comma grouping or abbreviate |
1,234,567 or 1.2M |
| Dates in tables |
Consistent format, sortable |
2026-03-12 or Mar 12, 2026 |
| Deltas/changes |
Sign + color + arrow |
+12.3% with green up-arrow |
| Negative numbers |
Parentheses or minus + red |
($1,234) or -$1,234 |
4.3 Alignment Rules
- Numbers: Right-align (decimal points line up)
- Text: Left-align
- Headers: Match cell alignment (right-align number headers, left-align text headers)
- Dates: Left-align or right-align consistently
- Status/tags: Center-align
- Actions: Right-align or center-align
4.4 Type Scale for Dashboards
KPI hero number: 32-48px, font-weight 700
KPI label: 12-14px, font-weight 500, text-transform uppercase, letter-spacing 0.05em, muted color
Chart title: 16-18px, font-weight 600
Axis labels: 11-12px, font-weight 400, muted color
Axis tick labels: 10-11px, font-weight 400, muted color
Tooltip title: 13-14px, font-weight 600
Tooltip value: 13-14px, font-weight 400
Data label on chart: 11-12px, font-weight 500
Table header: 12-13px, font-weight 600, text-transform uppercase, letter-spacing 0.03em
Table cell: 13-14px, font-weight 400
5. Grid and Spacing for Dashboards
5.1 Dashboard Grid System
Container max-width: 1440px (centered)
Outer padding: 24px (desktop), 16px (tablet), 12px (mobile)
Column grid: 12 columns, 24px gutter
Card padding: 20-24px
Card border-radius: 8-12px
Card gap: 16-24px
Chart minimum height: 240px (desktop), 180px (mobile)
KPI card height: ~120px
5.2 Chart Internal Spacing
Chart title to chart area: 12-16px
Chart area to legend: 16-20px
Axis label to axis line: 8px
Axis tick label to axis line: 4px
Gridline opacity: 0.1-0.15 (barely visible)
Bar gap (within group): 2-4px
Bar gap (between groups): 8-16px (> within-group gap)
Minimum bar width: 12px
Line stroke width: 2px (primary), 1.5px (secondary)
Data point dot radius: 4px (hover: 6px)
Tooltip offset from cursor: 8-12px
6. Animation and Interaction in Dataviz
6.1 When to Animate
DO animate:
- Data transitions (values changing from old to new)
- Chart type transitions (bar morphing to line)
- Progressive data loading (bars growing from zero)
- Hover states (tooltip appearance, highlight active series)
- Drill-down transitions (zooming into a segment)
DO NOT animate:
- Initial page load with complex entrance sequences (delays comprehension)
- Gratuitous bouncing, spinning, or pulsing
- Decorative animations that do not encode data
- Anything that takes > 500ms before data is readable
6.2 Transition Timing
/* Dataviz transition tokens */
--dataviz-transition-fast: 150ms ease-out; /* hover highlights */
--dataviz-transition-medium: 300ms ease-in-out; /* data updates */
--dataviz-transition-slow: 500ms ease-in-out; /* chart type changes */
--dataviz-tooltip-delay: 200ms; /* tooltip show delay */
--dataviz-tooltip-duration: 150ms ease-out; /* tooltip fade in */
6.3 Interaction Patterns
| Interaction |
Purpose |
Implementation |
| Hover tooltip |
Show exact value for a data point |
Appears after 200ms delay, follows cursor or anchors to point |
| Click to filter |
Select a category to filter other charts |
Click a bar/legend item, other charts cross-filter |
| Brush selection |
Select a time range |
Click-drag on time axis, zooms or filters to selection |
| Zoom |
Explore dense data |
Scroll to zoom, pinch on mobile, reset button always visible |
| Pan |
Navigate large datasets |
Click-drag on chart area (when zoomed), or scroll on time axis |
| Toggle series |
Show/hide data series |
Click legend items, hidden items gray out |
| Drill-down |
Navigate hierarchy |
Click a bar segment or treemap cell to see children |
| Cross-filter |
Link multiple charts |
Selection in one chart filters all related charts |
7. KPI Card Design
7.1 Anatomy of a KPI Card
+-------------------------------+
| Revenue * Live | <- Label (12px, muted) + Status indicator
| |
| $2.4M | <- Hero value (36px, bold, tabular figures)
| ^ 12.3% vs last month | <- Delta (14px, green + up arrow)
| |
| ~~~~~~~~~~~~~~~~~~~~~~~~ | <- Sparkline (past 30 days)
| |
| Target: $2.1M On track | <- Context line (12px, muted)
+-------------------------------+
7.2 KPI Card Rules
- One number per card -- the hero metric should be instantly readable
- Always show context -- delta (change), target, previous period, or benchmark
- Use semantic color for delta -- green (positive/good), red (negative/bad), gray (neutral)
- Sparkline adds trend without taking much space -- use 30-90 day window
- Label should be the dimension, not "KPI" or "Metric"
- Consistent card height across a row of KPIs
- 3-5 KPIs per row on desktop, stack to 1-2 per row on mobile
7.3 Delta Formatting
Positive good: ^ 12.3% (green, #16a34a)
Positive bad: ^ 12.3% (red, #dc2626) -- e.g., churn rate going up
Negative good: v 8.1% (green, #16a34a) -- e.g., error rate going down
Negative bad: v 8.1% (red, #dc2626)
No change: - 0.0% (gray, #6b7280)
8. Data Density and Information Architecture
8.1 Density Spectrum
| Level |
Data Points Visible |
Use For |
| Glanceable |
3-7 |
Executive KPIs, status monitors |
| Scannable |
8-30 |
Standard dashboards, summary reports |
| Explorable |
30-200 |
Analyst tools, detailed reports |
| Dense |
200-1000+ |
Trading terminals, monitoring walls, scientific viz |
8.2 Progressive Disclosure for Data
Level 0: KPI number (visible on dashboard)
Level 1: KPI + sparkline + delta (visible on dashboard card)
Level 2: Full chart with tooltip details (click KPI card)
Level 3: Data table behind the chart (click "View data" link)
Level 4: Raw data export (click "Export CSV")
8.3 Information Scent
Every data point should provide "scent" of what detail lies beneath:
- KPI cards should look clickable if they drill down
- Chart segments should highlight on hover if they have detail
- Truncated table cells should show full content on hover
- "See more" or "View all" links when data is summarized
9. Dataviz Anti-Patterns
9.1 The Deadly Sins of Data Visualization
| Anti-Pattern |
Problem |
Fix |
| Truncated Y-axis |
Bar chart not starting at 0 exaggerates differences |
Always start bar charts at 0. Line charts may start at non-zero if clearly labeled |
| Dual Y-axis |
Two different scales on left/right mislead about correlation |
Use two separate charts, or normalize to same scale |
| Pie chart > 5 slices |
Unreadable, angles are hard to compare |
Use horizontal bar chart sorted by value |
| 3D charts |
Distorts visual encoding, pure decoration |
Use 2D always |
| Rainbow color scale |
Not perceptually uniform, misleading |
Use sequential or diverging scale |
| Too many series |
Spaghetti chart, impossible to follow |
Highlight 1-2, gray out rest, or use small multiples |
| Missing context |
Numbers without comparison are meaningless |
Add targets, benchmarks, previous period, % change |
| Overloaded dashboard |
Everything crammed together, nothing stands out |
Reduce to 5-7 charts max, use progressive disclosure |
| Inconsistent time scales |
One chart monthly, next chart daily, side by side |
Standardize time scale across related charts |
| Decorative gradients |
Imply data variation where none exists |
Use flat fills |
9.2 Common Developer Mistakes
- Using the default chart library theme -- always customize colors, fonts, spacing to match your design system
- Ignoring responsive behavior -- charts should resize, not just scale down
- No loading states -- show skeleton/shimmer while data loads
- No empty states -- show a message when there is no data, not a blank chart
- No error states -- show a clear error message when API fails, not a broken chart
- Tooltips clipped by container -- ensure tooltips flip when near edges
- Legend taking up chart space -- move legend below chart on mobile, or use direct labels
- Axis labels overlapping -- rotate, abbreviate, or reduce ticks
- Not respecting prefers-reduced-motion -- disable chart animations when user requests
10. Responsive Dataviz Strategy
10.1 Breakpoint Behavior
| Component |
Desktop (>1024px) |
Tablet (768-1024px) |
Mobile (<768px) |
| KPI row |
4-5 cards horizontal |
3 cards, wrap to 2 rows |
2 cards per row, stack |
| Chart |
Full size, tooltips |
Slightly smaller, tooltips |
Full width, simplified |
| Legend |
Right side or top |
Below chart |
Below chart, scrollable |
| Data table |
Full columns visible |
Hide low-priority columns |
Card view or horizontal scroll |
| Filters |
Sidebar or top bar |
Top bar, collapsible |
Bottom sheet or modal |
| Dashboard |
12-col grid |
8-col grid |
Single column stack |
10.2 Mobile Chart Adaptations
- Reduce data points -- aggregate daily to weekly, or show top 10 instead of all
- Increase touch targets -- data points need 44x44px touch area
- Simplify axis labels -- abbreviate months (Jan, Feb), use K/M for numbers
- Move legend below -- side legends compress chart too much
- Use horizontal bar instead of vertical column (easier to read labels)
- Support swipe for time-based charts (pan through time)
- Full-screen mode for complex charts (tap to expand)
11. Dataviz Design Tokens
11.1 Token Definitions
/* Chart Colors -- Categorical */
--dataviz-categorical-1: #4e79a7;
--dataviz-categorical-2: #f28e2b;
--dataviz-categorical-3: #e15759;
--dataviz-categorical-4: #76b7b2;
--dataviz-categorical-5: #59a14f;
--dataviz-categorical-6: #edc948;
--dataviz-categorical-7: #b07aa1;
--dataviz-categorical-8: #ff9da7;
/* Chart Colors -- Sequential (blue) */
--dataviz-sequential-1: #f7fbff;
--dataviz-sequential-2: #deebf7;
--dataviz-sequential-3: #c6dbef;
--dataviz-sequential-4: #9ecae1;
--dataviz-sequential-5: #6baed6;
--dataviz-sequential-6: #4292c6;
--dataviz-sequential-7: #2171b5;
--dataviz-sequential-8: #084594;
/* Chart Colors -- Diverging (red-blue) */
--dataviz-diverging-negative-4: #b2182b;
--dataviz-diverging-negative-3: #d6604d;
--dataviz-diverging-negative-2: #f4a582;
--dataviz-diverging-negative-1: #fddbc7;
--dataviz-diverging-neutral: #f7f7f7;
--dataviz-diverging-positive-1: #d1e5f0;
--dataviz-diverging-positive-2: #92c5de;
--dataviz-diverging-positive-3: #4393c3;
--dataviz-diverging-positive-4: #2166ac;
/* Chart Colors -- Semantic */
--dataviz-positive: #16a34a;
--dataviz-negative: #dc2626;
--dataviz-warning: #d97706;
--dataviz-neutral: #6b7280;
/* Chart Structure */
--dataviz-grid-color: #e5e7eb;
--dataviz-grid-opacity: 0.15;
--dataviz-axis-color: #9ca3af;
--dataviz-axis-width: 1px;
--dataviz-tick-length: 4px;
--dataviz-line-width: 2px;
--dataviz-line-width-secondary: 1.5px;
--dataviz-point-radius: 4px;
--dataviz-point-radius-hover: 6px;
--dataviz-bar-radius: 4px 4px 0 0;
--dataviz-bar-gap: 4px;
--dataviz-bar-group-gap: 12px;
/* Tooltip */
--dataviz-tooltip-bg: #1f2937;
--dataviz-tooltip-text: #f9fafb;
--dataviz-tooltip-border-radius: 6px;
--dataviz-tooltip-padding: 8px 12px;
--dataviz-tooltip-shadow: 0 4px 12px rgba(0,0,0,0.15);
--dataviz-tooltip-max-width: 240px;
/* Typography */
--dataviz-font-family: 'Inter', system-ui, sans-serif;
--dataviz-font-mono: 'JetBrains Mono', 'SF Mono', monospace;
--dataviz-kpi-size: 36px;
--dataviz-kpi-weight: 700;
--dataviz-label-size: 12px;
--dataviz-label-weight: 500;
--dataviz-axis-label-size: 11px;
--dataviz-title-size: 16px;
--dataviz-title-weight: 600;
/* Spacing */
--dataviz-chart-min-height: 240px;
--dataviz-chart-padding: 20px;
--dataviz-card-padding: 20px;
--dataviz-card-gap: 16px;
--dataviz-card-radius: 8px;
11.2 Dark Mode Overrides
[data-theme="dark"] {
--dataviz-grid-color: #374151;
--dataviz-axis-color: #6b7280;
--dataviz-tooltip-bg: #f9fafb;
--dataviz-tooltip-text: #1f2937;
--dataviz-positive: #22c55e;
--dataviz-negative: #ef4444;
--dataviz-warning: #f59e0b;
/* Lighten categorical colors for dark backgrounds */
--dataviz-categorical-1: #6ba3d6;
--dataviz-categorical-2: #f5a855;
--dataviz-categorical-3: #e87b7d;
--dataviz-categorical-4: #93cec9;
--dataviz-categorical-5: #7dbd72;
--dataviz-categorical-6: #f0d56e;
--dataviz-categorical-7: #c499b8;
--dataviz-categorical-8: #ffb4bc;
}
12. Print Optimization for Dataviz
12.1 Print CSS
@media print {
/* Remove interactive elements */
.chart-tooltip,
.chart-legend-toggle,
.chart-zoom-controls,
.dashboard-filter-bar { display: none; }
/* Force white background */
.chart-container,
.dashboard-card { background: white !important; }
/* Ensure visible borders for cards */
.dashboard-card { border: 1px solid #d1d5db !important; }
/* Increase contrast for print */
.chart-gridline { opacity: 0.3 !important; }
.chart-axis-label { color: #111827 !important; }
/* Avoid page breaks inside charts */
.dashboard-card { break-inside: avoid; }
.chart-container { break-inside: avoid; }
/* Ensure chart colors print distinctly */
.chart-series { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
13. Quality Checklist: Dataviz Review
Use this checklist when reviewing any chart, graph, or dashboard:
Data Integrity
Visual Design
Accessibility
Responsiveness
States
Usage Examples
When User Says: "I need a chart for this data"
- Ask about the analytical purpose (compare, trend, distribution, relationship)
- Ask about the data shape (dimensions, measures, cardinality)
- Consult chart-type-encyclopedia.md for the recommended chart type
- Provide design specs from the encyclopedia entry
- Provide code pattern from dataviz-code-patterns.md
When User Says: "Design a dashboard for..."
- Identify the dashboard type (executive, operational, analytical)
- Consult dashboard-layout-patterns.md for the matching layout
- Select appropriate chart types for each data panel
- Apply KPI card design from section 7
- Ensure responsive behavior from section 10
When User Says: "Make this chart accessible"
- Consult dataviz-accessibility.md for the specific chart type
- Write alt text following the pattern
- Provide a data table alternative
- Check color palette against colorblind simulation
- Add keyboard navigation if interactive
When User Says: "Build a data table"
- Consult data-table-mastery.md for full spec
- Determine column types, sorting, filtering needs
- Select responsive strategy
- Apply accessibility requirements (role=grid, aria-sort)
- Provide production code pattern
1---2name: data-visualization-mastery3description: 50+ chart types with selection criteria, dashboard composition, data tables, KPI cards, sparklines, heatmaps, and accessible data presentation, with React code (Recharts, D3, Nivo) and data-viz tokens. Use when designing charts, dashboards, or any data-dense screen.4---56# Data Visualization Mastery78## Why Data Visualization Mastery Matters910Data visualization is the art and science of encoding information visually so humans can perceive patterns, outliers, and trends faster than reading raw numbers. A poorly chosen chart misleads. A poorly designed chart confuses. A well-designed chart tells the truth instantly. This skill codifies the principles of Edward Tufte, Stephen Few, Jacques Bertin, and Tamara Munzner into a systematic framework for building data-dense UIs that are beautiful, honest, and accessible.1112The gap between a developer-built dashboard and a professionally designed data experience is systematic craft: choosing the right chart type, encoding data correctly, managing visual hierarchy across dozens of data points, and ensuring every pixel of ink serves the data.1314## Reference Architecture1516| File | Contents | Use When |17|------|----------|----------|18| `references/chart-type-encyclopedia.md` | 50+ chart types organized by purpose (comparison, trend, distribution, relationship, part-to-whole, flow, geo, hierarchy). Each chart: when to use, when NOT to use, data shape, max data points, design specs (colors, spacing, typography, gridlines), accessibility notes, thumbnail description. | Selecting the right chart for a dataset. Reviewing chart design specs. Auditing chart choices in an existing UI. |19| `references/dashboard-layout-patterns.md` | 30+ dashboard layout patterns: KPI rows, chart grids, filter bars, drill-down hierarchies, real-time monitoring, executive summary, operational, analytical, mobile card-stack. Each: CSS grid layout, spacing, component hierarchy, responsive collapse strategy. | Designing dashboard layouts. Reviewing dashboard information architecture. Building responsive analytics UIs. |20| `references/data-table-mastery.md` | Complete data table design system: anatomy, column types (15+), sorting, filtering, pagination, selection, expansion, fixed headers, inline editing, cell formatting, empty/loading states, responsive strategies, density modes, full accessibility spec, production React/TypeScript code. | Designing or building data tables. Auditing table usability. Adding features to existing tables. |21| `references/dataviz-accessibility.md` | Dataviz accessibility: alt text patterns for every chart type, data table alternatives, 8 colorblind-safe palettes with hex codes, pattern fills, high contrast mode, screen reader announcements, keyboard navigation, sonification, WCAG success criteria mapping. | Making charts accessible. Auditing dataviz accessibility. Building inclusive dashboards. |22| `references/dataviz-code-patterns.md` | Production code for top 20 chart types using Recharts (React). Chart wrapper component with loading/error/empty states. Design tokens for dataviz. Responsive containers. Theme integration. Tooltip and legend customization. Print styles. | Implementing charts in React. Building chart component libraries. Setting up dataviz design tokens. |2324## Cross-References2526- **`visual-design-mastery`** -- Color science (oklch, palette generation) applies directly to dataviz color palettes. Typography mastery (tabular figures, alignment) is critical for number-heavy UIs.27- **`ui-pattern-intelligence`** -- Dashboard and table patterns at the component level. This skill provides the deeper dataviz-specific design intelligence.28- **`accessibility-inclusive-design`** -- WCAG foundation. This skill extends it with dataviz-specific accessibility patterns.29- **`component-patterns-code`** -- Component architecture. This skill provides dataviz-specific component patterns and code.30- **`design-systems-architecture`** -- Token architecture. This skill defines dataviz-specific tokens (chart colors, gridlines, axes).31- **`performance-states-patterns`** -- Loading, error, and empty states apply to every chart and table component.32- **`cognitive-psychology-ux`** -- Perceptual principles (pre-attentive processing, Gestalt grouping) underpin all visual encoding decisions.3334---3536## 1. Foundational Principles3738### 1.1 Edward Tufte's Core Principles3940**Data-Ink Ratio:** Maximize the share of ink devoted to data. Every pixel that does not encode data should be questioned and likely removed. Remove chartjunk: decorative gridlines, 3D effects, gradient fills, drop shadows on bars, unnecessary legends, redundant labels.4142```43Data-Ink Ratio = (Data Ink) / (Total Ink Used in the Graphic)44Target: > 0.845```4647**Lie Factor:** The size of an effect shown in the graphic divided by the size of the effect in the data. A lie factor of 1.0 is truthful. Above 1.05 or below 0.95 is distortion.4849```50Lie Factor = (Size of effect in graphic) / (Size of effect in data)51Acceptable range: 0.95 - 1.0552```5354**Chartjunk Checklist -- Remove These:**55- 3D effects on 2D data (bars, pies)56- Gradient fills that imply data variation where none exists57- Decorative background images58- Heavy gridlines that compete with data59- Redundant legends (when labels are directly on data)60- Unnecessary borders and boxes61- Excessive decimal places62- Animated entrances that delay comprehension6364**Small Multiples:** When comparing across categories or time periods, use small multiples (the same chart repeated with different data) rather than cramming everything into one chart. Same scale, same axes, same visual encoding -- only the data changes.6566### 1.2 Visual Encoding Hierarchy (Jacques Bertin + Cleveland & McGill)6768Humans decode visual channels with different accuracy. Always use the most accurate channel for the most important data dimension:6970```71MOST ACCURATE (use first)72 1. Position on a common scale (bar chart, dot plot, scatter plot)73 2. Position on non-aligned scales (small multiples)74 3. Length (bar chart)75 4. Direction / Angle (slope, but NOT pie chart angles)76 5. Area (bubble chart, treemap)77 6. Volume (3D -- almost never use)78 7. Color saturation / Luminance (heatmap, choropleth)79 8. Color hue (categorical encoding only)80LEAST ACCURATE (use last)81```8283**Practical implication:** A bar chart (position + length) will ALWAYS be more accurately read than a pie chart (angle + area). Use pie charts only when part-to-whole relationship matters more than precise comparison, and only with 2-5 slices.8485### 1.3 Stephen Few's Dashboard Design Principles86871. **Fit on a single screen** -- no scrolling for the primary view882. **Group related information** using Gestalt proximity and enclosure893. **Place the most important information top-left** (F-pattern scanning)904. **Use consistent visual encoding** across all charts on the dashboard915. **Provide context** -- comparison values, targets, historical ranges926. **Highlight what matters** -- use pre-attentive attributes (color, size) to draw attention to exceptions, not to decorate937. **Minimize non-data pixels** -- every border, background, and separator should earn its place948. **Support progressive disclosure** -- summary first, details on demand9596### 1.4 Tamara Munzner's Nested Model9798Four levels of visualization design, each validated differently:99100| Level | Question | Validation |101|-------|----------|------------|102| **Domain situation** | Who are the users? What are their tasks? | Observe users in context |103| **Data/task abstraction** | What data types? What analytical tasks? | Test task completion |104| **Visual encoding/interaction** | What marks and channels? What interactions? | Perceptual experiments |105| **Algorithm** | How to compute and render efficiently? | Performance benchmarks |106107---108109## 2. Chart Selection Decision Framework110111### 2.1 By Analytical Purpose112113| Purpose | Best Charts | Avoid |114|---------|-------------|-------|115| **Compare values** | Bar (horizontal for many categories), Column, Dot plot, Lollipop | Pie (bad for comparison), Radar (distorts) |116| **Show trend over time** | Line, Area, Sparkline, Slope chart | Bar (unless discrete periods), Pie |117| **Show part-to-whole** | Stacked bar (100%), Treemap, Donut (2-5 parts), Waffle | Pie (>5 slices), Stacked area (hard to read middle layers) |118| **Show distribution** | Histogram, Box plot, Violin, Density, Strip plot | Bar chart (not the same as histogram) |119| **Show relationship** | Scatter, Bubble, Correlation matrix | Line chart (implies time sequence) |120| **Show flow/process** | Sankey, Funnel, Alluvial | Pie, Bar |121| **Show geographic data** | Choropleth, Bubble map, Heat map | Bar chart (loses spatial context) |122| **Show hierarchy** | Treemap, Sunburst, Circle packing, Dendrogram | Pie (flat, no hierarchy) |123| **Show composition over time** | Stacked area, Stream graph | Multiple pie charts over time |124125### 2.2 By Data Shape126127| Data Shape | Recommended |128|------------|-------------|129| 1 number (KPI) | KPI card with delta, sparkline, context |130| 1 categorical + 1 quantitative | Bar/Column chart |131| 1 time + 1 quantitative | Line chart |132| 1 time + multiple quantitative | Multi-series line, Small multiples |133| 2 quantitative | Scatter plot |134| 3 quantitative | Bubble chart (3rd = size) |135| 1 categorical + parts | Stacked bar, Treemap |136| Hierarchical categories + 1 quantitative | Treemap, Sunburst |137| Source to Target + flow magnitude | Sankey diagram |138| Geographic + 1 quantitative | Choropleth |139| Matrix (rows x cols x value) | Heatmap |140141### 2.3 By Audience142143| Audience | Approach |144|----------|----------|145| **Executive** | KPI cards, sparklines, single-number summaries, traffic lights. Max 5-7 data points visible. Summary first, drill-down available. |146| **Analyst** | Interactive charts, filters, cross-filtering, tooltips with detail. Support exploration. Higher data density acceptable. |147| **General public** | Simple charts (bar, line, donut). Annotations explaining "what this means." No jargon. Large text. |148| **Domain expert** | Specialized chart types acceptable (candlestick for finance, survival curves for medicine). Dense data OK. |149150---151152## 3. Color for Data Visualization153154### 3.1 Palette Types155156**Sequential** (low to high): Single hue varying in lightness. Use for ordered data (temperature, population, revenue).157```158Example (Blue sequential):159#f7fbff -> #deebf7 -> #c6dbef -> #9ecae1 -> #6baed6 -> #4292c6 -> #2171b5 -> #084594160```161162**Diverging** (negative <- neutral -> positive): Two hues diverging from a neutral midpoint. Use for data with a meaningful center (profit/loss, above/below average, sentiment).163```164Example (Red-Blue diverging):165#b2182b -> #d6604d -> #f4a582 -> #fddbc7 -> #f7f7f7 -> #d1e5f0 -> #92c5de -> #4393c3 -> #2166ac166```167168**Categorical** (distinct groups): Maximally distinct hues at similar lightness. Use for nominal categories (product lines, regions, user segments). Maximum 8-10 colors before confusion.169```170Colorblind-safe categorical (8 colors):171#4e79a7 #f28e2b #e15759 #76b7b2 #59a14f #edc948 #b07aa1 #ff9da7172(Tableau 10 subset -- optimized for distinguishability including colorblind viewers)173```174175### 3.2 Colorblind-Safe Design Rules1761771. **Never use red/green as the only differentiator** -- 8% of males have red-green deficiency1782. **Use lightness variation** in addition to hue -- colorblind viewers can still distinguish light from dark1793. **Add redundant encoding** -- patterns, labels, icons, or position in addition to color1804. **Test with simulation** -- Sim Daltonism (macOS), Color Oracle, or Figma colorblind plugins1815. **Use pre-tested palettes** -- see `references/dataviz-accessibility.md` for 8 verified palettes182183### 3.3 Color Assignment Rules184185- **Semantic colors** should be respected: red = danger/loss/down, green = success/gain/up, blue = information/neutral, yellow/amber = warning186- **Gray for context**, saturated color for focal data -- e.g., gray bars for all categories, blue bar for the selected one187- **Consistent mapping** -- if "Product A" is blue on chart 1, it must be blue on chart 2188- **White/light background** for charts -- data should be the most visually prominent element189- **No more than 8 categorical colors** -- group remaining into "Other"190191---192193## 4. Typography for Data-Dense UI194195### 4.1 Tabular (Monospace) Figures196197Numbers in tables and charts MUST use tabular figures (all digits occupy the same width) so columns align perfectly. Most professional fonts include a `font-feature-settings: "tnum"` OpenType feature.198199```css200/* Enable tabular figures for all data displays */201.dataviz-number,202.table-cell-number,203.kpi-value {204 font-feature-settings: "tnum" 1;205 font-variant-numeric: tabular-nums;206}207```208209**Fonts with excellent tabular figures:** Inter, IBM Plex Sans, Roboto, SF Pro, DM Sans, JetBrains Mono.210211### 4.2 Number Formatting Rules212213| Context | Format | Example |214|---------|--------|---------|215| Currency | Symbol + comma grouping + 2 decimal | $1,234,567.89 |216| Large currency | Abbreviate with suffix | $1.2M, $3.4B |217| Percentage | 1 decimal max, % symbol | 45.2% |218| Large numbers | Comma grouping or abbreviate | 1,234,567 or 1.2M |219| Dates in tables | Consistent format, sortable | 2026-03-12 or Mar 12, 2026 |220| Deltas/changes | Sign + color + arrow | +12.3% with green up-arrow |221| Negative numbers | Parentheses or minus + red | ($1,234) or -$1,234 |222223### 4.3 Alignment Rules224225- **Numbers:** Right-align (decimal points line up)226- **Text:** Left-align227- **Headers:** Match cell alignment (right-align number headers, left-align text headers)228- **Dates:** Left-align or right-align consistently229- **Status/tags:** Center-align230- **Actions:** Right-align or center-align231232### 4.4 Type Scale for Dashboards233234```235KPI hero number: 32-48px, font-weight 700236KPI label: 12-14px, font-weight 500, text-transform uppercase, letter-spacing 0.05em, muted color237Chart title: 16-18px, font-weight 600238Axis labels: 11-12px, font-weight 400, muted color239Axis tick labels: 10-11px, font-weight 400, muted color240Tooltip title: 13-14px, font-weight 600241Tooltip value: 13-14px, font-weight 400242Data label on chart: 11-12px, font-weight 500243Table header: 12-13px, font-weight 600, text-transform uppercase, letter-spacing 0.03em244Table cell: 13-14px, font-weight 400245```246247---248249## 5. Grid and Spacing for Dashboards250251### 5.1 Dashboard Grid System252253```254Container max-width: 1440px (centered)255Outer padding: 24px (desktop), 16px (tablet), 12px (mobile)256Column grid: 12 columns, 24px gutter257Card padding: 20-24px258Card border-radius: 8-12px259Card gap: 16-24px260Chart minimum height: 240px (desktop), 180px (mobile)261KPI card height: ~120px262```263264### 5.2 Chart Internal Spacing265266```267Chart title to chart area: 12-16px268Chart area to legend: 16-20px269Axis label to axis line: 8px270Axis tick label to axis line: 4px271Gridline opacity: 0.1-0.15 (barely visible)272Bar gap (within group): 2-4px273Bar gap (between groups): 8-16px (> within-group gap)274Minimum bar width: 12px275Line stroke width: 2px (primary), 1.5px (secondary)276Data point dot radius: 4px (hover: 6px)277Tooltip offset from cursor: 8-12px278```279280---281282## 6. Animation and Interaction in Dataviz283284### 6.1 When to Animate285286**DO animate:**287- Data transitions (values changing from old to new)288- Chart type transitions (bar morphing to line)289- Progressive data loading (bars growing from zero)290- Hover states (tooltip appearance, highlight active series)291- Drill-down transitions (zooming into a segment)292293**DO NOT animate:**294- Initial page load with complex entrance sequences (delays comprehension)295- Gratuitous bouncing, spinning, or pulsing296- Decorative animations that do not encode data297- Anything that takes > 500ms before data is readable298299### 6.2 Transition Timing300301```css302/* Dataviz transition tokens */303--dataviz-transition-fast: 150ms ease-out; /* hover highlights */304--dataviz-transition-medium: 300ms ease-in-out; /* data updates */305--dataviz-transition-slow: 500ms ease-in-out; /* chart type changes */306--dataviz-tooltip-delay: 200ms; /* tooltip show delay */307--dataviz-tooltip-duration: 150ms ease-out; /* tooltip fade in */308```309310### 6.3 Interaction Patterns311312| Interaction | Purpose | Implementation |313|-------------|---------|----------------|314| **Hover tooltip** | Show exact value for a data point | Appears after 200ms delay, follows cursor or anchors to point |315| **Click to filter** | Select a category to filter other charts | Click a bar/legend item, other charts cross-filter |316| **Brush selection** | Select a time range | Click-drag on time axis, zooms or filters to selection |317| **Zoom** | Explore dense data | Scroll to zoom, pinch on mobile, reset button always visible |318| **Pan** | Navigate large datasets | Click-drag on chart area (when zoomed), or scroll on time axis |319| **Toggle series** | Show/hide data series | Click legend items, hidden items gray out |320| **Drill-down** | Navigate hierarchy | Click a bar segment or treemap cell to see children |321| **Cross-filter** | Link multiple charts | Selection in one chart filters all related charts |322323---324325## 7. KPI Card Design326327### 7.1 Anatomy of a KPI Card328329```330+-------------------------------+331| Revenue * Live | <- Label (12px, muted) + Status indicator332| |333| $2.4M | <- Hero value (36px, bold, tabular figures)334| ^ 12.3% vs last month | <- Delta (14px, green + up arrow)335| |336| ~~~~~~~~~~~~~~~~~~~~~~~~ | <- Sparkline (past 30 days)337| |338| Target: $2.1M On track | <- Context line (12px, muted)339+-------------------------------+340```341342### 7.2 KPI Card Rules3433441. **One number per card** -- the hero metric should be instantly readable3452. **Always show context** -- delta (change), target, previous period, or benchmark3463. **Use semantic color for delta** -- green (positive/good), red (negative/bad), gray (neutral)3474. **Sparkline adds trend** without taking much space -- use 30-90 day window3485. **Label should be the dimension**, not "KPI" or "Metric"3496. **Consistent card height** across a row of KPIs3507. **3-5 KPIs per row** on desktop, stack to 1-2 per row on mobile351352### 7.3 Delta Formatting353354```355Positive good: ^ 12.3% (green, #16a34a)356Positive bad: ^ 12.3% (red, #dc2626) -- e.g., churn rate going up357Negative good: v 8.1% (green, #16a34a) -- e.g., error rate going down358Negative bad: v 8.1% (red, #dc2626)359No change: - 0.0% (gray, #6b7280)360```361362---363364## 8. Data Density and Information Architecture365366### 8.1 Density Spectrum367368| Level | Data Points Visible | Use For |369|-------|---------------------|---------|370| **Glanceable** | 3-7 | Executive KPIs, status monitors |371| **Scannable** | 8-30 | Standard dashboards, summary reports |372| **Explorable** | 30-200 | Analyst tools, detailed reports |373| **Dense** | 200-1000+ | Trading terminals, monitoring walls, scientific viz |374375### 8.2 Progressive Disclosure for Data376377```378Level 0: KPI number (visible on dashboard)379Level 1: KPI + sparkline + delta (visible on dashboard card)380Level 2: Full chart with tooltip details (click KPI card)381Level 3: Data table behind the chart (click "View data" link)382Level 4: Raw data export (click "Export CSV")383```384385### 8.3 Information Scent386387Every data point should provide "scent" of what detail lies beneath:388- KPI cards should look clickable if they drill down389- Chart segments should highlight on hover if they have detail390- Truncated table cells should show full content on hover391- "See more" or "View all" links when data is summarized392393---394395## 9. Dataviz Anti-Patterns396397### 9.1 The Deadly Sins of Data Visualization398399| Anti-Pattern | Problem | Fix |400|-------------|---------|-----|401| **Truncated Y-axis** | Bar chart not starting at 0 exaggerates differences | Always start bar charts at 0. Line charts may start at non-zero if clearly labeled |402| **Dual Y-axis** | Two different scales on left/right mislead about correlation | Use two separate charts, or normalize to same scale |403| **Pie chart > 5 slices** | Unreadable, angles are hard to compare | Use horizontal bar chart sorted by value |404| **3D charts** | Distorts visual encoding, pure decoration | Use 2D always |405| **Rainbow color scale** | Not perceptually uniform, misleading | Use sequential or diverging scale |406| **Too many series** | Spaghetti chart, impossible to follow | Highlight 1-2, gray out rest, or use small multiples |407| **Missing context** | Numbers without comparison are meaningless | Add targets, benchmarks, previous period, % change |408| **Overloaded dashboard** | Everything crammed together, nothing stands out | Reduce to 5-7 charts max, use progressive disclosure |409| **Inconsistent time scales** | One chart monthly, next chart daily, side by side | Standardize time scale across related charts |410| **Decorative gradients** | Imply data variation where none exists | Use flat fills |411412### 9.2 Common Developer Mistakes4134141. **Using the default chart library theme** -- always customize colors, fonts, spacing to match your design system4152. **Ignoring responsive behavior** -- charts should resize, not just scale down4163. **No loading states** -- show skeleton/shimmer while data loads4174. **No empty states** -- show a message when there is no data, not a blank chart4185. **No error states** -- show a clear error message when API fails, not a broken chart4196. **Tooltips clipped by container** -- ensure tooltips flip when near edges4207. **Legend taking up chart space** -- move legend below chart on mobile, or use direct labels4218. **Axis labels overlapping** -- rotate, abbreviate, or reduce ticks4229. **Not respecting prefers-reduced-motion** -- disable chart animations when user requests423424---425426## 10. Responsive Dataviz Strategy427428### 10.1 Breakpoint Behavior429430| Component | Desktop (>1024px) | Tablet (768-1024px) | Mobile (<768px) |431|-----------|-------------------|---------------------|-----------------|432| KPI row | 4-5 cards horizontal | 3 cards, wrap to 2 rows | 2 cards per row, stack |433| Chart | Full size, tooltips | Slightly smaller, tooltips | Full width, simplified |434| Legend | Right side or top | Below chart | Below chart, scrollable |435| Data table | Full columns visible | Hide low-priority columns | Card view or horizontal scroll |436| Filters | Sidebar or top bar | Top bar, collapsible | Bottom sheet or modal |437| Dashboard | 12-col grid | 8-col grid | Single column stack |438439### 10.2 Mobile Chart Adaptations440441- **Reduce data points** -- aggregate daily to weekly, or show top 10 instead of all442- **Increase touch targets** -- data points need 44x44px touch area443- **Simplify axis labels** -- abbreviate months (Jan, Feb), use K/M for numbers444- **Move legend below** -- side legends compress chart too much445- **Use horizontal bar** instead of vertical column (easier to read labels)446- **Support swipe** for time-based charts (pan through time)447- **Full-screen mode** for complex charts (tap to expand)448449---450451## 11. Dataviz Design Tokens452453### 11.1 Token Definitions454455```css456/* Chart Colors -- Categorical */457--dataviz-categorical-1: #4e79a7;458--dataviz-categorical-2: #f28e2b;459--dataviz-categorical-3: #e15759;460--dataviz-categorical-4: #76b7b2;461--dataviz-categorical-5: #59a14f;462--dataviz-categorical-6: #edc948;463--dataviz-categorical-7: #b07aa1;464--dataviz-categorical-8: #ff9da7;465466/* Chart Colors -- Sequential (blue) */467--dataviz-sequential-1: #f7fbff;468--dataviz-sequential-2: #deebf7;469--dataviz-sequential-3: #c6dbef;470--dataviz-sequential-4: #9ecae1;471--dataviz-sequential-5: #6baed6;472--dataviz-sequential-6: #4292c6;473--dataviz-sequential-7: #2171b5;474--dataviz-sequential-8: #084594;475476/* Chart Colors -- Diverging (red-blue) */477--dataviz-diverging-negative-4: #b2182b;478--dataviz-diverging-negative-3: #d6604d;479--dataviz-diverging-negative-2: #f4a582;480--dataviz-diverging-negative-1: #fddbc7;481--dataviz-diverging-neutral: #f7f7f7;482--dataviz-diverging-positive-1: #d1e5f0;483--dataviz-diverging-positive-2: #92c5de;484--dataviz-diverging-positive-3: #4393c3;485--dataviz-diverging-positive-4: #2166ac;486487/* Chart Colors -- Semantic */488--dataviz-positive: #16a34a;489--dataviz-negative: #dc2626;490--dataviz-warning: #d97706;491--dataviz-neutral: #6b7280;492493/* Chart Structure */494--dataviz-grid-color: #e5e7eb;495--dataviz-grid-opacity: 0.15;496--dataviz-axis-color: #9ca3af;497--dataviz-axis-width: 1px;498--dataviz-tick-length: 4px;499--dataviz-line-width: 2px;500--dataviz-line-width-secondary: 1.5px;501--dataviz-point-radius: 4px;502--dataviz-point-radius-hover: 6px;503--dataviz-bar-radius: 4px 4px 0 0;504--dataviz-bar-gap: 4px;505--dataviz-bar-group-gap: 12px;506507/* Tooltip */508--dataviz-tooltip-bg: #1f2937;509--dataviz-tooltip-text: #f9fafb;510--dataviz-tooltip-border-radius: 6px;511--dataviz-tooltip-padding: 8px 12px;512--dataviz-tooltip-shadow: 0 4px 12px rgba(0,0,0,0.15);513--dataviz-tooltip-max-width: 240px;514515/* Typography */516--dataviz-font-family: 'Inter', system-ui, sans-serif;517--dataviz-font-mono: 'JetBrains Mono', 'SF Mono', monospace;518--dataviz-kpi-size: 36px;519--dataviz-kpi-weight: 700;520--dataviz-label-size: 12px;521--dataviz-label-weight: 500;522--dataviz-axis-label-size: 11px;523--dataviz-title-size: 16px;524--dataviz-title-weight: 600;525526/* Spacing */527--dataviz-chart-min-height: 240px;528--dataviz-chart-padding: 20px;529--dataviz-card-padding: 20px;530--dataviz-card-gap: 16px;531--dataviz-card-radius: 8px;532```533534### 11.2 Dark Mode Overrides535536```css537[data-theme="dark"] {538 --dataviz-grid-color: #374151;539 --dataviz-axis-color: #6b7280;540 --dataviz-tooltip-bg: #f9fafb;541 --dataviz-tooltip-text: #1f2937;542 --dataviz-positive: #22c55e;543 --dataviz-negative: #ef4444;544 --dataviz-warning: #f59e0b;545546 /* Lighten categorical colors for dark backgrounds */547 --dataviz-categorical-1: #6ba3d6;548 --dataviz-categorical-2: #f5a855;549 --dataviz-categorical-3: #e87b7d;550 --dataviz-categorical-4: #93cec9;551 --dataviz-categorical-5: #7dbd72;552 --dataviz-categorical-6: #f0d56e;553 --dataviz-categorical-7: #c499b8;554 --dataviz-categorical-8: #ffb4bc;555}556```557558---559560## 12. Print Optimization for Dataviz561562### 12.1 Print CSS563564```css565@media print {566 /* Remove interactive elements */567 .chart-tooltip,568 .chart-legend-toggle,569 .chart-zoom-controls,570 .dashboard-filter-bar { display: none; }571572 /* Force white background */573 .chart-container,574 .dashboard-card { background: white !important; }575576 /* Ensure visible borders for cards */577 .dashboard-card { border: 1px solid #d1d5db !important; }578579 /* Increase contrast for print */580 .chart-gridline { opacity: 0.3 !important; }581 .chart-axis-label { color: #111827 !important; }582583 /* Avoid page breaks inside charts */584 .dashboard-card { break-inside: avoid; }585 .chart-container { break-inside: avoid; }586587 /* Ensure chart colors print distinctly */588 .chart-series { -webkit-print-color-adjust: exact; print-color-adjust: exact; }589}590```591592---593594## 13. Quality Checklist: Dataviz Review595596Use this checklist when reviewing any chart, graph, or dashboard:597598### Data Integrity599- [ ] Chart type matches the analytical purpose600- [ ] Y-axis starts at 0 for bar charts601- [ ] Scales are clearly labeled with units602- [ ] No misleading truncation or distortion (lie factor ~1.0)603- [ ] Time axis direction is left-to-right, past-to-present604- [ ] Data source and last-updated timestamp visible605606### Visual Design607- [ ] Data-ink ratio > 0.8 (minimal chartjunk)608- [ ] Consistent color mapping across all charts609- [ ] Categorical palette limited to 8 or fewer colors610- [ ] Sufficient contrast between data series611- [ ] Tabular figures enabled for all numbers612- [ ] Numbers right-aligned in tables613- [ ] Gridlines subtle (opacity 0.1-0.15)614- [ ] No 3D effects, no decorative gradients615616### Accessibility617- [ ] Alt text describes the chart's key insight (not just "a bar chart")618- [ ] Data table alternative available for screen readers619- [ ] Colorblind-safe palette used620- [ ] Redundant encoding (not just color: shape, pattern, or label too)621- [ ] Keyboard navigable (for interactive charts)622- [ ] High contrast mode supported623- [ ] prefers-reduced-motion respected624625### Responsiveness626- [ ] Charts resize gracefully (not just CSS scale)627- [ ] Mobile layout tested (card stack, simplified axes)628- [ ] Touch targets >= 44x44px for interactive elements629- [ ] Tooltips do not clip at container edges630- [ ] Legend repositions on narrow viewports631632### States633- [ ] Loading state (skeleton/shimmer)634- [ ] Empty state (message + illustration)635- [ ] Error state (message + retry action)636- [ ] Partial data state (missing data points handled gracefully)637638---639640## Usage Examples641642### When User Says: "I need a chart for this data"6431. Ask about the analytical purpose (compare, trend, distribution, relationship)6442. Ask about the data shape (dimensions, measures, cardinality)6453. Consult chart-type-encyclopedia.md for the recommended chart type6464. Provide design specs from the encyclopedia entry6475. Provide code pattern from dataviz-code-patterns.md648649### When User Says: "Design a dashboard for..."6501. Identify the dashboard type (executive, operational, analytical)6512. Consult dashboard-layout-patterns.md for the matching layout6523. Select appropriate chart types for each data panel6534. Apply KPI card design from section 76545. Ensure responsive behavior from section 10655656### When User Says: "Make this chart accessible"6571. Consult dataviz-accessibility.md for the specific chart type6582. Write alt text following the pattern6593. Provide a data table alternative6604. Check color palette against colorblind simulation6615. Add keyboard navigation if interactive662663### When User Says: "Build a data table"6641. Consult data-table-mastery.md for full spec6652. Determine column types, sorting, filtering needs6663. Select responsive strategy6674. Apply accessibility requirements (role=grid, aria-sort)6685. Provide production code pattern