@anvme/nanocharts 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +134 -0
- package/dist/index.cjs +635 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +107 -0
- package/dist/index.d.ts +107 -0
- package/dist/index.js +606 -0
- package/dist/index.js.map +1 -0
- package/dist/index.min.cjs +2 -0
- package/dist/index.min.cjs.map +1 -0
- package/dist/index.min.js +2 -0
- package/dist/index.min.js.map +1 -0
- package/dist/nanocharts.global.js +604 -0
- package/dist/nanocharts.global.js.map +1 -0
- package/dist/nanocharts.min.global.js +2 -0
- package/dist/nanocharts.min.global.js.map +1 -0
- package/dist/style.css +181 -0
- package/dist/style.min.css +1 -0
- package/package.json +65 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 anvme
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
# nanocharts
|
|
2
|
+
|
|
3
|
+
Lightweight SVG+HTML hybrid charts. Zero dependencies, typed. Line, bar & pie.
|
|
4
|
+
|
|
5
|
+
- **~4.4 KB** brotli (JS ~3.7 KB + CSS ~0.7 KB), ~12 KB minified
|
|
6
|
+
- **< 0.5 ms** render time — `innerHTML` single-write, zero reflows
|
|
7
|
+
- **Zero dependencies**
|
|
8
|
+
- **TypeScript** declarations included
|
|
9
|
+
- **Dark mode** via `prefers-color-scheme`, Bootstrap, Tailwind, or standalone
|
|
10
|
+
- **CSS custom properties** for full theming control
|
|
11
|
+
- **Int16Array/Float64Array** typed arrays for cache-friendly math
|
|
12
|
+
- **Lazy hover** — tooltip & indicator DOM created only on first interaction
|
|
13
|
+
|
|
14
|
+
**[Live Examples](https://anvme.github.io/nanocharts/examples.html)**
|
|
15
|
+
|
|
16
|
+
## Install
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
npm install @anvme/nanocharts
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
```js
|
|
23
|
+
import { NanoLineChart, NanoBarChart, NanoPieChart } from '@anvme/nanocharts';
|
|
24
|
+
import '@anvme/nanocharts/style.css';
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
### CDN
|
|
28
|
+
|
|
29
|
+
```html
|
|
30
|
+
<link href="https://cdn.jsdelivr.net/npm/@anvme/nanocharts@1.0.0/dist/style.min.css" rel="stylesheet">
|
|
31
|
+
<script src="https://cdn.jsdelivr.net/npm/@anvme/nanocharts@1.0.0/dist/nanocharts.min.global.js"></script>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Usage
|
|
35
|
+
|
|
36
|
+
```html
|
|
37
|
+
<div id="chart" style="max-width: 600px"></div>
|
|
38
|
+
|
|
39
|
+
<script>
|
|
40
|
+
NanoLineChart('chart', {
|
|
41
|
+
data: [[5, 12, 8, 20, 15, 25, 18]],
|
|
42
|
+
labels: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
|
|
43
|
+
xLabel: 'Day',
|
|
44
|
+
yLabel: 'Sales'
|
|
45
|
+
});
|
|
46
|
+
</script>
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
```js
|
|
50
|
+
NanoBarChart('chart', {
|
|
51
|
+
data: [[40, 65, 30, 80, 55]],
|
|
52
|
+
labels: ['Chrome', 'Firefox', 'Safari', 'Edge', 'Other'],
|
|
53
|
+
xLabel: 'Browser',
|
|
54
|
+
yLabel: 'Users'
|
|
55
|
+
});
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
```js
|
|
59
|
+
NanoPieChart('chart', {
|
|
60
|
+
data: [40, 25, 20, 15],
|
|
61
|
+
labels: ['Desktop', 'Mobile', 'Tablet', 'Other'],
|
|
62
|
+
donut: true,
|
|
63
|
+
donutWidth: 50
|
|
64
|
+
});
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
## API
|
|
68
|
+
|
|
69
|
+
### NanoLineChart(containerId, config)
|
|
70
|
+
|
|
71
|
+
| Option | Type | Default | Description |
|
|
72
|
+
|---|---|---|---|
|
|
73
|
+
| `data` | `number[][]` | -- | Array of series |
|
|
74
|
+
| `labels` | `string[]` | -- | X-axis labels |
|
|
75
|
+
| `xLabel` | `string` | `''` | X-axis title |
|
|
76
|
+
| `yLabel` | `string` | `''` | Y-axis title |
|
|
77
|
+
| `colors` | `string[]` | brand palette | Color per series |
|
|
78
|
+
| `width` | `number` | container width | Chart width in px |
|
|
79
|
+
| `height` | `number` | `350` | Chart height in px |
|
|
80
|
+
| `smooth` | `boolean` | `false` | Catmull-Rom spline smoothing |
|
|
81
|
+
| `areaFill` | `boolean` | `false` | Fill under lines |
|
|
82
|
+
| `areaOpacity` | `number` | `0.1` | Area fill opacity |
|
|
83
|
+
| `strokeWidth` | `number` | `2.5` | Line stroke width |
|
|
84
|
+
| `showTicks` | `boolean` | `true` | Show tick labels |
|
|
85
|
+
| `showGrid` | `boolean` | `true` | Show grid lines |
|
|
86
|
+
| `gridDashed` | `boolean` | `false` | Dashed grid lines |
|
|
87
|
+
| `hover` | `boolean` | `true` | Enable hover tooltip |
|
|
88
|
+
|
|
89
|
+
### NanoBarChart(containerId, config)
|
|
90
|
+
|
|
91
|
+
| Option | Type | Default | Description |
|
|
92
|
+
|---|---|---|---|
|
|
93
|
+
| `data` | `number[][]` | -- | Array of series |
|
|
94
|
+
| `labels` | `string[]` | -- | Category labels |
|
|
95
|
+
| `xLabel` | `string` | `''` | X-axis title |
|
|
96
|
+
| `yLabel` | `string` | `''` | Y-axis title |
|
|
97
|
+
| `colors` | `string[]` | brand palette | Color per series |
|
|
98
|
+
| `width` | `number` | container width | Chart width in px |
|
|
99
|
+
| `height` | `number` | `350` | Chart height in px |
|
|
100
|
+
| `stacked` | `boolean` | `false` | Stack series |
|
|
101
|
+
| `horizontal` | `boolean` | `false` | Horizontal bars |
|
|
102
|
+
| `barGap` | `number` | `0.2` | Gap between groups (0-1) |
|
|
103
|
+
| `showTicks` | `boolean` | `true` | Show tick labels |
|
|
104
|
+
| `showGrid` | `boolean` | `true` | Show grid lines |
|
|
105
|
+
| `gridDashed` | `boolean` | `false` | Dashed grid lines |
|
|
106
|
+
| `hover` | `boolean` | `true` | Enable hover tooltip |
|
|
107
|
+
|
|
108
|
+
### NanoPieChart(containerId, config)
|
|
109
|
+
|
|
110
|
+
| Option | Type | Default | Description |
|
|
111
|
+
|---|---|---|---|
|
|
112
|
+
| `data` | `number[]` | -- | Value per slice |
|
|
113
|
+
| `labels` | `string[]` | -- | Label per slice |
|
|
114
|
+
| `colors` | `string[]` | brand palette | Color per slice |
|
|
115
|
+
| `width` | `number` | container width | Chart width in px |
|
|
116
|
+
| `height` | `number` | = width | Chart height in px |
|
|
117
|
+
| `donut` | `boolean` | `false` | Donut mode |
|
|
118
|
+
| `donutWidth` | `number` | `60` | Ring thickness in px |
|
|
119
|
+
| `showLabels` | `boolean` | `true` | Show labels outside slices |
|
|
120
|
+
| `hover` | `boolean` | `true` | Enable hover tooltip |
|
|
121
|
+
|
|
122
|
+
## Dark Mode
|
|
123
|
+
|
|
124
|
+
Charts auto-adapt via `prefers-color-scheme`. Force dark mode with:
|
|
125
|
+
|
|
126
|
+
```html
|
|
127
|
+
<html data-bs-theme="dark"> <!-- Bootstrap 5.3 -->
|
|
128
|
+
<html class="dark"> <!-- Tailwind -->
|
|
129
|
+
<div class="chart-dark"> <!-- Standalone -->
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
## License
|
|
133
|
+
|
|
134
|
+
MIT
|