Examples

Lightweight SVG+HTML hybrid charts. Zero dependencies, typed. Line, bar & pie.

~4.4 KB brotli ~5.1 KB gzip JS ~3.7 KB + CSS ~0.7 KB brotli ~12 KB + ~2.6 KB min

CDN

CSS
JS

Line Chart

Basic Line
Smooth + Area Fill
Dashed Grid + Custom Colors
Minimal (No Grid/Ticks)
Thick Stroke + Custom Size
Area Comparison (3 Series)
Watermark — Text
Watermark — Image Logo

Bar Chart

Basic Bar
Grouped (Year-over-Year)
Stacked Bar
Horizontal Bar
Negative Values (P&L)
Custom Gap + Dashed Grid

Pie & Donut Chart

Basic Pie
Donut
Thin Donut + Custom Colors
Many Slices (Budget)
No Labels (Hover Only)
Wide Donut + Custom Size

Documentation

Installation
npm / yarn / pnpm
npm install @anvme/nanocharts
import { NanoLineChart, NanoBarChart, NanoPieChart } from '@anvme/nanocharts';
import '@anvme/nanocharts/style.css';
CDN (no build step)
<link href="https://cdn.jsdelivr.net/npm/@anvme/nanocharts@1.0.3/dist/style.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/@anvme/nanocharts@1.0.3/dist/nanocharts.min.global.js"></script>
API Reference
NanoLineChart(containerId, config)
OptionTypeDefaultDescription
datanumber[][]Array of series. Each inner array is one line.
labelsstring[]X-axis labels. Must match series length.
xLabelstring''X-axis title.
yLabelstring''Y-axis title.
colorsstring[]brand paletteColor per series.
widthnumbercontainer widthChart width in px.
heightnumber350Chart height in px.
smoothbooleanfalseCatmull-Rom spline smoothing.
areaFillbooleanfalseSemi-transparent fill under lines.
areaOpacitynumber0.1Area fill opacity (0–1).
strokeWidthnumber2.5Line stroke width.
showTicksbooleantrueShow X/Y tick labels.
showGridbooleantrueShow grid lines.
gridDashedbooleanfalseDashed grid lines.
hoverbooleantrueEnable hover tooltip + indicator.

NanoBarChart(containerId, config)
OptionTypeDefaultDescription
datanumber[][]Array of series. Each inner array is one series.
labelsstring[]Category labels.
xLabelstring''X-axis title.
yLabelstring''Y-axis title.
colorsstring[]brand paletteColor per series.
widthnumbercontainer widthChart width in px.
heightnumber350Chart height in px.
stackedbooleanfalseStack series instead of grouping.
horizontalbooleanfalseHorizontal bars (categories on Y).
barGapnumber0.2Gap between groups (0–1 fraction).
showTicksbooleantrueShow tick labels.
showGridbooleantrueShow grid lines.
gridDashedbooleanfalseDashed grid lines.
hoverbooleantrueEnable hover tooltip + indicator.

NanoPieChart(containerId, config)
OptionTypeDefaultDescription
datanumber[]One numeric value per slice.
labelsstring[]Label per slice.
colorsstring[]brand paletteColor per slice.
widthnumbercontainer widthChart width in px.
heightnumber= widthChart height in px (square by default).
donutbooleanfalseDonut mode (hollow center).
donutWidthnumber60Donut ring thickness in px.
showLabelsbooleantrueShow labels outside slices.
hoverbooleantrueEnable hover tooltip.
Theming & Dark Mode

Charts auto-adapt to dark mode via prefers-color-scheme. You can also force dark mode with any of these:

<!-- Bootstrap 5.3 -->
<html data-bs-theme="dark">

<!-- Tailwind -->
<html class="dark">

<!-- Standalone -->
<div class="chart-dark">
  <div id="chart"></div>
</div>
CSS Custom Properties

Override on the .chart SVG element or a parent wrapper:

PropertyLight defaultDescription
--chart-bg#fffChart background
--chart-grid#e0e0e0Grid line color
--chart-text#666Tick label color
--chart-title#333Axis title color
--chart-zero-line#999Zero-axis line color
--chart-indicator-stroke#fffHover indicator stroke
--chart-indicator-bar-fillrgba(255,255,255,0.3)Bar hover fill
--chart-indicator-bar-stroke#333Bar hover stroke
Watermark / Copyright

Add a text or image watermark with pure CSS — no library changes needed.

Text watermark
<div id="chart" class="chart-watermark-text" data-watermark="Your Brand"></div>
Image watermark

Wrap the chart container so --watermark survives the library's inline style reset:

<div class="chart-watermark-img" style="--watermark: url('logo.png'); position: relative">
  <div id="chart"></div>
</div>

See the CSS tab on the watermark examples above for the full ::after styles.

Browser Support

All modern browsers: Chrome, Firefox, Safari, Edge. No IE11. Uses SVGElement, Int16Array, Float64Array, requestAnimationFrame, CSS custom properties.