resolvcharts 0.1.0 → 0.3.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/README.md +92 -26
- package/dist/index.cjs +290 -66
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +153 -28
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +153 -28
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +290 -67
- package/dist/index.mjs.map +1 -1
- package/dist/resolvcharts.global.min.js +195 -25
- package/dist/resolvcharts.global.min.js.map +1 -1
- package/dist/series-PmAjztEh.cjs +1191 -0
- package/dist/series-PmAjztEh.cjs.map +1 -0
- package/dist/series-wyqYpkXm.mjs +1191 -0
- package/dist/series-wyqYpkXm.mjs.map +1 -0
- package/package.json +21 -13
- package/dist/series-BdprL87H.mjs +0 -479
- package/dist/series-BdprL87H.mjs.map +0 -1
- package/dist/series-J_5Z6dah.cjs +0 -479
- package/dist/series-J_5Z6dah.cjs.map +0 -1
package/README.md
CHANGED
|
@@ -13,7 +13,13 @@ At [Resolvo Cloud](https://resolvocloud.com), we experienced glitchy live charts
|
|
|
13
13
|
npm install resolvcharts
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
Or drop in the CDN build (exposes a global `ResolvCharts`):
|
|
17
|
+
|
|
18
|
+
```html
|
|
19
|
+
<script src="https://unpkg.com/resolvcharts/dist/resolvcharts.global.min.js"></script>
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Quick start
|
|
17
23
|
|
|
18
24
|
```ts
|
|
19
25
|
import { createChart } from "resolvcharts";
|
|
@@ -27,12 +33,55 @@ const chart = createChart(document.querySelector("#chart")!, {
|
|
|
27
33
|
});
|
|
28
34
|
```
|
|
29
35
|
|
|
30
|
-
Chart types
|
|
36
|
+
## Chart types
|
|
37
|
+
|
|
38
|
+
The `data` shape depends on `type` — pick the row you need:
|
|
39
|
+
|
|
40
|
+
| `type` | `data` shape | Use case |
|
|
41
|
+
|---|---|---|
|
|
42
|
+
| `line` | `{ x, series: [{ y }] }` | Trends over an x axis |
|
|
43
|
+
| `area` | `{ x, series: [{ y }] }` | Line + filled gradient |
|
|
44
|
+
| `baseline` | `{ x, series: [{ y }] }` | Delta vs a reference value |
|
|
45
|
+
| `sparkline` | `{ x, series: [{ y }] }` | Tiny inline chart, no axes |
|
|
46
|
+
| `scatter` | `{ x, series: [{ y }] }` | Point clouds |
|
|
47
|
+
| `bar` | `{ categories, series: [{ values }] }` | Categorical groups; `stacked` supported |
|
|
48
|
+
| `combo` | `{ categories, series: [{ values, kind }] }` | Columns + line/area overlay |
|
|
49
|
+
| `donut` | `{ slices: [{ label, value }] }` | Share of a total |
|
|
50
|
+
| `candle` / `ohlc` | `{ candles: [{ x, open, high, low, close, volume? }] }` | Financial OHLC (+ volume band) |
|
|
51
|
+
| `waterfall` | `{ categories, values, totals? }` | P&L bridges, signed deltas |
|
|
52
|
+
|
|
53
|
+
## Examples
|
|
31
54
|
|
|
32
55
|
```ts
|
|
33
|
-
//
|
|
56
|
+
// Bar
|
|
57
|
+
createChart(el, {
|
|
58
|
+
type: "bar",
|
|
59
|
+
data: { categories: ["Q1", "Q2", "Q3"], series: [{ label: "Sales", values: [4, 7, 5] }] },
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
// Stacked bar (negative values stack below zero)
|
|
63
|
+
createChart(el, {
|
|
64
|
+
type: "bar", stacked: true,
|
|
65
|
+
data: { categories: ["Q1", "Q2"], series: [{ label: "A", values: [3, 5] }, { label: "B", values: [2, -1] }] },
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
// Combo — per-series `kind`: "column" (default), "line", or "area".
|
|
69
|
+
// Columns group per category; line/area series overlay on category centers.
|
|
70
|
+
createChart(el, {
|
|
71
|
+
type: "combo",
|
|
72
|
+
data: {
|
|
73
|
+
categories: ["Jan", "Feb", "Mar"],
|
|
74
|
+
series: [
|
|
75
|
+
{ label: "Inflow", values: [42, 55, 48], kind: "column" },
|
|
76
|
+
{ label: "Outflow", values: [30, 41, 37], kind: "column" },
|
|
77
|
+
{ label: "Net", values: [12, 14, 11], kind: "area" },
|
|
78
|
+
],
|
|
79
|
+
},
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
// Candlestick (+ optional volume band); "ohlc" renders bar-style
|
|
34
83
|
createChart(el, {
|
|
35
|
-
type: "candle",
|
|
84
|
+
type: "candle",
|
|
36
85
|
data: { candles: [{ x: 0, open: 100, high: 108, low: 98, close: 105, volume: 1200 }] },
|
|
37
86
|
});
|
|
38
87
|
|
|
@@ -53,20 +102,6 @@ createChart(el, {
|
|
|
53
102
|
data: { x: [0, 1, 2], series: [{ y: [-2, 4, -1] }] },
|
|
54
103
|
});
|
|
55
104
|
|
|
56
|
-
// Stacked bar (negative values stack below zero)
|
|
57
|
-
createChart(el, {
|
|
58
|
-
type: "bar", stacked: true,
|
|
59
|
-
data: { categories: ["Q1", "Q2"], series: [{ label: "A", values: [3, 5] }, { label: "B", values: [2, -1] }] },
|
|
60
|
-
});
|
|
61
|
-
```
|
|
62
|
-
|
|
63
|
-
```ts
|
|
64
|
-
// Bar
|
|
65
|
-
createChart(el, {
|
|
66
|
-
type: "bar",
|
|
67
|
-
data: { categories: ["Q1", "Q2", "Q3"], series: [{ label: "Sales", values: [4, 7, 5] }] },
|
|
68
|
-
});
|
|
69
|
-
|
|
70
105
|
// Donut
|
|
71
106
|
createChart(el, {
|
|
72
107
|
type: "donut",
|
|
@@ -76,29 +111,60 @@ createChart(el, {
|
|
|
76
111
|
|
|
77
112
|
## Options
|
|
78
113
|
|
|
114
|
+
Universal:
|
|
115
|
+
|
|
79
116
|
| Option | Default | Description |
|
|
80
117
|
|---|---|---|
|
|
81
|
-
| `type` | — |
|
|
82
|
-
| `data` | — |
|
|
118
|
+
| `type` | — | Any row in the table above |
|
|
119
|
+
| `data` | — | Matching shape from the table above |
|
|
83
120
|
| `theme` | `"light"` | `"light"` `"dark"` or partial token object |
|
|
84
121
|
| `accent` | — | Primary series color |
|
|
85
122
|
| `curve` | `"linear"` | `linear` `step` `smooth` (monotone cubic, never overshoots) |
|
|
86
123
|
| `grid` | `true` | Faint horizontal gridlines |
|
|
87
124
|
| `tooltip` | auto | Hover tooltip (off for sparkline) |
|
|
125
|
+
| `legend` | — | Reserved |
|
|
88
126
|
| `animate` | `true` | `true` = 400 ms, a number = custom ms; respects `prefers-reduced-motion` |
|
|
89
|
-
| `flow` | `false` | Continuous-flow mode for xy charts — ripple easing + tween duration auto-follows append cadence |
|
|
90
|
-
| `window` | — | Visible points in the sliding window (xy charts) |
|
|
91
|
-
| `maxPoints` | — | Hard cap on retained datapoints during `append()`; shows last N when `window` is unset |
|
|
92
|
-
| `stacked` | `false` | Bar charts: stack series per category |
|
|
93
|
-
| `baseline` | first value | Baseline chart reference value |
|
|
94
127
|
| `height` | — | Chart height in px |
|
|
95
128
|
| `labels` | — | `{x?: (v)=>string, y?: (v)=>string}` tick formatters |
|
|
96
129
|
| `onHover` | — | `(info \| null) => void` |
|
|
97
130
|
|
|
131
|
+
xy charts (`line` `area` `scatter` `sparkline` `baseline`):
|
|
132
|
+
|
|
133
|
+
| Option | Default | Description |
|
|
134
|
+
|---|---|---|
|
|
135
|
+
| `flow` | `false` | Continuous-flow mode — ripple easing + tween duration auto-follows append cadence |
|
|
136
|
+
| `window` | — | Visible points in the sliding window |
|
|
137
|
+
| `maxPoints` | — | Hard cap on retained datapoints during `append()`; shows last N when `window` is unset |
|
|
138
|
+
| `renderer` | `"canvas"` | `"webgpu"` rasterizes series on the GPU; `"auto"` uses it when available |
|
|
139
|
+
| `gpu` | — | WebGPU adapter options (`powerPreference`, `compat`, `timing`) |
|
|
140
|
+
|
|
141
|
+
Type-specific:
|
|
142
|
+
|
|
143
|
+
| Option | Default | Description |
|
|
144
|
+
|---|---|---|
|
|
145
|
+
| `stacked` | `false` | `bar`/`combo`: stack column series per category |
|
|
146
|
+
| `baseline` | first value | `baseline` chart reference value |
|
|
147
|
+
| `canvas` | — | `getContext("2d", …)` settings for all layers, e.g. `{ willReadFrequently: true }` |
|
|
148
|
+
|
|
149
|
+
## Theming
|
|
150
|
+
|
|
151
|
+
```ts
|
|
152
|
+
createChart(el, {
|
|
153
|
+
type: "line",
|
|
154
|
+
theme: "dark",
|
|
155
|
+
// or override individual tokens:
|
|
156
|
+
// theme: { bg: "#0b0e14", grid: "#1f2430", series: ["#7aa2f7", "#9ece6a"] },
|
|
157
|
+
accent: "#7aa2f7",
|
|
158
|
+
data: { x, series },
|
|
159
|
+
});
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
Tokens: `bg` `text` `textMuted` `grid` `axisBaseline` `crosshair` `series[]` `contextGray` `up` `down` `tooltipBg` `tooltipText` `tooltipMuted` `tooltipBorder` `tooltipShadow` `fontFamily`.
|
|
163
|
+
|
|
98
164
|
## API
|
|
99
165
|
|
|
100
166
|
```ts
|
|
101
|
-
chart.setData(newData); // animated transition
|
|
167
|
+
chart.setData(newData); // animated transition; shape must match `type`
|
|
102
168
|
chart.append(x, y); // streaming: append one sample (xy charts)
|
|
103
169
|
// number → single series, number[] → per-series value
|
|
104
170
|
chart.resize(); // manual resize (ResizeObserver handles automatically)
|