Sparkline Mini Charts
Ultra-lightweight, reactive, framework-agnostic micro data visualizations. Drop semantic SVG sparkline tags into any table, dashboard, card, or metric widget with 100% Shadow DOM encapsulation.
Installation & Quick Start
pnpm add sparkline-mini-charts
Live Real-Time Streaming Studio (All 17 Charts)
Witness smooth SVG path morphing, synchronized point tracking, staggered bar physics, and authentic ThemeRiver organic flows in real time.
<mini-line-chart>
<mini-area-chart>
<mini-bar-chart>
<mini-pie-chart>
<mini-half-pie-chart>
<mini-radial-bar-chart>
<mini-progress-chart>
<mini-gauge-chart>
<mini-candlestick-chart>
<mini-ohlc-chart>
<mini-stacked-area-chart>
<mini-stream-chart>
<mini-combo-chart>
<mini-bullet-chart>
<mini-win-loss-chart>
<mini-range-bar-chart>
<mini-scatter-chart>
Components Catalog & Code Explorer
Explore all 17 primitives with uniform cards, multi-framework code snippets, and deep-dive documentation.
Continuous Trends & Flow
Signed & Categorical
Radial & Proportions
Gauges, Meters & Benchmarks
Financial & 2D Coordinates
Live Rendered Stage
Component Attributes
Interactive Sandbox & Playground
Experiment with chart attributes, test custom datasets, and export ready-to-use markup.
Theming & Design Tokens Guide
Discover how to brand, customize, and integrate Sparkline Mini Charts with your Design System using CSS Custom Properties and Shadow Parts.
๐ฆ Complete Design Tokens Master Snippet (Ready to Copy) Drop-in CSS
Copy and paste this master snippet into your global stylesheet
(e.g. index.css, styles.css, or your
Design System root). Simply replace the fallback values with
your own CSS variables:
/* ==========================================================================
Sparkline Mini Charts โ Master Design Tokens & Theming Configuration
Drop this into :root or any container class (e.g. .theme-dark, .my-dashboard)
========================================================================== */
:root {
/* ------------------------------------------------------------------------
1. Brand & Single-Series Base (Line, Bar, Area, Progress, Scatter)
------------------------------------------------------------------------ */
--mini-chart-color: var(--brand-primary, #0ea5e9); /* Main curve, bar fill, and accent */
--mini-chart-point-fill: var(--brand-accent, #38bdf8); /* Line endpoint & scatter dots */
--mini-chart-point-stroke: #ffffff; /* Border on active/highlight dots */
--mini-chart-aspect-ratio: auto; /* Override default 10/3 aspect ratio */
/* ------------------------------------------------------------------------
2. Multi-Series & Categorical Palette (Pie, Half-Pie, Stream, Stacked)
Used sequentially for multi-layer data (1st slice, 2nd slice, etc.)
Supports 1 to 8+ elements (wraps around automatically if > 8 items)
------------------------------------------------------------------------ */
--mini-chart-color-1: var(--palette-1, #0ea5e9); /* 1st slice / top stream layer */
--mini-chart-color-2: var(--palette-2, #6366f1); /* 2nd slice / layer */
--mini-chart-color-3: var(--palette-3, #8b5cf6); /* 3rd slice / layer */
--mini-chart-color-4: var(--palette-4, #ec4899); /* 4th slice / layer */
--mini-chart-color-5: var(--palette-5, #f43f5e); /* 5th slice / layer */
--mini-chart-color-6: var(--palette-6, #f97316); /* 6th slice / layer */
--mini-chart-color-7: var(--palette-7, #eab308); /* 7th slice / layer */
--mini-chart-color-8: var(--palette-8, #10b981); /* 8th slice / bottom layer */
/* ------------------------------------------------------------------------
3. Financial & Binary Status Tones (Candlestick, OHLC, Win/Loss)
------------------------------------------------------------------------ */
--mini-chart-bullish-color: var(--brand-success, #10b981); /* Bullish candles, win bars (+1) */
--mini-chart-bearish-color: var(--brand-danger, #ef4444); /* Bearish candles, loss bars (-1) */
--mini-chart-tie-color: var(--brand-muted, #94a3b8); /* Tie / neutral bars (0) */
--mini-chart-wick-width: 0.75px; /* Precision stroke width for wicks */
--mini-chart-tick-width: 0.75px; /* Tick mark width for OHLC bars */
/* ------------------------------------------------------------------------
4. Gauges, Progress & Benchmark KPIs (Gauge, Progress, Bullet)
------------------------------------------------------------------------ */
--mini-chart-track-color: rgba(128, 128, 128, 0.15); /* Background guide arc / track */
--mini-chart-measure-color: var(--brand-primary, #0ea5e9); /* Bullet actual performance bar */
--mini-chart-target-color: var(--brand-danger, #ef4444); /* Bullet KPI benchmark target line */
--mini-chart-target-width: 2.5px; /* Bullet target marker width */
--mini-chart-range-1: rgba(128, 128, 128, 0.10); /* Bullet poor / low range band */
--mini-chart-range-2: rgba(128, 128, 128, 0.18); /* Bullet satisfactory range band */
--mini-chart-range-3: rgba(128, 128, 128, 0.26); /* Bullet good / optimal range band */
/* ------------------------------------------------------------------------
5. Interactivity, Dimming & Transitions (All Charts)
------------------------------------------------------------------------ */
--mini-chart-inactive-opacity: 0.45; /* Non-hovered items dimming factor */
--mini-chart-hover-brightness: 1.18; /* Active item highlight boost */
--mini-chart-transition-duration: 0.4s; /* Path morphing & value change speed */
--mini-chart-hover-duration: 0.2s; /* Pointer feedback transition speed */
--mini-chart-stroke-width: 2px; /* Primary SVG stroke width */
--mini-chart-bar-radius: 2px; /* Rounded corners for bars */
}
The 4 Levels of Customization
1. Zero-Config (`currentColor`)
All single-series charts inherit their primary color from CSS
color. When your theme switches or changes text
color, the sparklines update automatically.
.metric-card.success {
color: var(--brand-success); /* Chart inherits automatically! */
}
2. CSS Custom Properties (`--mini-chart-*`)
Map your Design System tokens directly to our standardized CSS properties at the root or container level.
:root {
--mini-chart-color: var(--color-primary-500);
--mini-chart-bullish-color: var(--color-emerald-500);
--mini-chart-bearish-color: var(--color-rose-500);
}
3. Shadow Parts (`::part(...)`)
Target discrete SVG elements inside the Shadow DOM like
::part(line), ::part(point-last), or
::part(wick) for advanced design control.
mini-line-chart::part(point-last) {
fill: var(--color-accent);
stroke: #ffffff;
stroke-width: 2px;
}
4. Motion & Performance Tuning
Control or disable transitions across entire dashboards for high-frequency streaming or accessibility compliance.
/* Instant high-frequency real-time update mode */
.high-frequency-table {
--mini-chart-transition-duration: 0s;
--mini-chart-hover-duration: 0.05s;
}
Complete Design Tokens Reference
| CSS Custom Property | Default Fallback | Applies To | Description |
|---|---|---|---|
--mini-chart-color |
#2563eb |
Line, Bar, Area, Combo, Progress, Scatter | Primary brand tone for paths, bars, and single-value fills. |
--mini-chart-color-1..8 |
Built-in 8-Color Palette | Stream, Stacked Area, Pie, Radial Bar | Sequential palette for multi-layer/radial segments. |
--mini-chart-point-fill |
currentColor |
Line, Scatter | Fill color for data endpoints and scatter points. |
--mini-chart-bullish-color |
#10b981 |
Candlestick, OHLC, Win/Loss | Color for positive/bullish trading periods and wins. |
--mini-chart-bearish-color |
#ef4444 |
Candlestick, OHLC, Win/Loss | Color for negative/bearish trading periods and losses. |
--mini-chart-track-color |
rgba(128, 128, 128, 0.15) |
Progress, Gauge, Radial Bar | Background track arc color for circular meters. |
--mini-chart-stroke-width |
2px (or component default) |
Line, Area, Gauge, Combo | Stroke width for lines and needle indicators. |
--mini-chart-inactive-opacity |
0.45 |
All interactive charts | Opacity applied to non-hovered items during hover focus. |
--mini-chart-transition-duration |
0.4s |
All charts | Duration of path morphing and value transitions. |
Gradients Studio & Multi-Stop Colors
v1.4.0 New FeatureExplore hardware-accelerated continuous SVG gradients and multi-stop chromatic transitions across Gauge, Progress, Radial Rings, Bullet, and Area sparklines.
๐จ Continuous Multi-Stop Color Lab
Select a chromatic preset or live-tweak stops to see real-time gradient rendering across all compatible charts:
๐ Gradient Attributes Reference
| Component | Attribute Syntax | Examples | Visual Outcome |
|---|---|---|---|
<mini-gauge-chart> |
gradient="true | ['#c1','#c2',...]" |
gradient="true" |
Replaces segmented zones with a continuous smooth multi-stop arc gradient. |
<mini-progress-chart> |
gradient="true | ['#c1','#c2',...]" |
gradient="['#3b82f6','#10b981']" |
Linear gradient mapped directly across the active progress stroke path. |
<mini-radial-bar-chart> |
gradient="true | [['#c1','#c2'],...]" |
gradient="true" |
Generates individual radiant color shifts for each concentric activity ring. |
<mini-bullet-chart> |
gradient="true | ['#c1','#c2',...]" |
gradient="['#8b5cf6','#ec4899']" |
Draws a horizontal chromatic fill across the measure bar [part="measure"]. |
<mini-area-chart> |
gradient="true | ['#c1','#c2',...]" |
gradient="['#06b6d4','#8b5cf6']" |
Fills the area beneath the curve with multi-stop color stops and gradual vertical opacity falloff. |
Framework Integrations
Standard Web Components work in any environment. Use native Custom Elements directly or via first-class typed wrappers.
Import the registration script once and use standard Custom Elements in your HTML.
<!-- Include registration bundle -->
<script type="module" src="https://cdn.jsdelivr.net/npm/sparkline-mini-charts/register"></script>
<!-- Use sparklines anywhere -->
<mini-line-chart
data="[18, 23, 20, 31, 27, 38, 44]"
curve="smooth"
trend-color="auto"
label="Weekly revenue trend"
></mini-line-chart>