Lightweight SVG+HTML hybrid charts. Zero dependencies, typed. Line, bar & pie.
npm install @anvme/nanocharts
import { NanoLineChart, NanoBarChart, NanoPieChart } from '@anvme/nanocharts';
import '@anvme/nanocharts/style.css';
<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>
NanoLineChart(containerId, config)| Option | Type | Default | Description |
|---|---|---|---|
data | number[][] | — | Array of series. Each inner array is one line. |
labels | string[] | — | X-axis labels. Must match series length. |
xLabel | string | '' | X-axis title. |
yLabel | string | '' | Y-axis title. |
colors | string[] | brand palette | Color per series. |
width | number | container width | Chart width in px. |
height | number | 350 | Chart height in px. |
smooth | boolean | false | Catmull-Rom spline smoothing. |
areaFill | boolean | false | Semi-transparent fill under lines. |
areaOpacity | number | 0.1 | Area fill opacity (0–1). |
strokeWidth | number | 2.5 | Line stroke width. |
showTicks | boolean | true | Show X/Y tick labels. |
showGrid | boolean | true | Show grid lines. |
gridDashed | boolean | false | Dashed grid lines. |
hover | boolean | true | Enable hover tooltip + indicator. |
NanoBarChart(containerId, config)| Option | Type | Default | Description |
|---|---|---|---|
data | number[][] | — | Array of series. Each inner array is one series. |
labels | string[] | — | Category labels. |
xLabel | string | '' | X-axis title. |
yLabel | string | '' | Y-axis title. |
colors | string[] | brand palette | Color per series. |
width | number | container width | Chart width in px. |
height | number | 350 | Chart height in px. |
stacked | boolean | false | Stack series instead of grouping. |
horizontal | boolean | false | Horizontal bars (categories on Y). |
barGap | number | 0.2 | Gap between groups (0–1 fraction). |
showTicks | boolean | true | Show tick labels. |
showGrid | boolean | true | Show grid lines. |
gridDashed | boolean | false | Dashed grid lines. |
hover | boolean | true | Enable hover tooltip + indicator. |
NanoPieChart(containerId, config)| Option | Type | Default | Description |
|---|---|---|---|
data | number[] | — | One numeric value per slice. |
labels | string[] | — | Label per slice. |
colors | string[] | brand palette | Color per slice. |
width | number | container width | Chart width in px. |
height | number | = width | Chart height in px (square by default). |
donut | boolean | false | Donut mode (hollow center). |
donutWidth | number | 60 | Donut ring thickness in px. |
showLabels | boolean | true | Show labels outside slices. |
hover | boolean | true | Enable hover tooltip. |
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>
Override on the .chart SVG element or a parent wrapper:
| Property | Light default | Description |
|---|---|---|
--chart-bg | #fff | Chart background |
--chart-grid | #e0e0e0 | Grid line color |
--chart-text | #666 | Tick label color |
--chart-title | #333 | Axis title color |
--chart-zero-line | #999 | Zero-axis line color |
--chart-indicator-stroke | #fff | Hover indicator stroke |
--chart-indicator-bar-fill | rgba(255,255,255,0.3) | Bar hover fill |
--chart-indicator-bar-stroke | #333 | Bar hover stroke |
Add a text or image watermark with pure CSS — no library changes needed.
<div id="chart" class="chart-watermark-text" data-watermark="Your Brand"></div>
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.
All modern browsers: Chrome, Firefox, Safari, Edge. No IE11. Uses SVGElement, Int16Array, Float64Array, requestAnimationFrame, CSS custom properties.