uplot-plus 0.1.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 +341 -0
- package/dist/annotations.d.ts +22 -0
- package/dist/annotations.d.ts.map +1 -0
- package/dist/axes/layout.d.ts +30 -0
- package/dist/axes/layout.d.ts.map +1 -0
- package/dist/axes/ticks.d.ts +47 -0
- package/dist/axes/ticks.d.ts.map +1 -0
- package/dist/colors.d.ts +32 -0
- package/dist/colors.d.ts.map +1 -0
- package/dist/components/Axis.d.ts +14 -0
- package/dist/components/Axis.d.ts.map +1 -0
- package/dist/components/Band.d.ts +10 -0
- package/dist/components/Band.d.ts.map +1 -0
- package/dist/components/Chart.d.ts +8 -0
- package/dist/components/Chart.d.ts.map +1 -0
- package/dist/components/Legend.d.ts +12 -0
- package/dist/components/Legend.d.ts.map +1 -0
- package/dist/components/ResponsiveChart.d.ts +18 -0
- package/dist/components/ResponsiveChart.d.ts.map +1 -0
- package/dist/components/Scale.d.ts +11 -0
- package/dist/components/Scale.d.ts.map +1 -0
- package/dist/components/Series.d.ts +11 -0
- package/dist/components/Series.d.ts.map +1 -0
- package/dist/components/Sparkline.d.ts +28 -0
- package/dist/components/Sparkline.d.ts.map +1 -0
- package/dist/components/Timeline.d.ts +8 -0
- package/dist/components/Timeline.d.ts.map +1 -0
- package/dist/components/Tooltip.d.ts +9 -0
- package/dist/components/Tooltip.d.ts.map +1 -0
- package/dist/components/ZoomRanger.d.ts +26 -0
- package/dist/components/ZoomRanger.d.ts.map +1 -0
- package/dist/components/annotations/AnnotationLabel.d.ts +26 -0
- package/dist/components/annotations/AnnotationLabel.d.ts.map +1 -0
- package/dist/components/annotations/HLine.d.ts +22 -0
- package/dist/components/annotations/HLine.d.ts.map +1 -0
- package/dist/components/annotations/Region.d.ts +22 -0
- package/dist/components/annotations/Region.d.ts.map +1 -0
- package/dist/components/annotations/VLine.d.ts +22 -0
- package/dist/components/annotations/VLine.d.ts.map +1 -0
- package/dist/components/annotations/index.d.ts +9 -0
- package/dist/components/annotations/index.d.ts.map +1 -0
- package/dist/core/BlockMinMax.d.ts +42 -0
- package/dist/core/BlockMinMax.d.ts.map +1 -0
- package/dist/core/CursorManager.d.ts +43 -0
- package/dist/core/CursorManager.d.ts.map +1 -0
- package/dist/core/DataStore.d.ts +51 -0
- package/dist/core/DataStore.d.ts.map +1 -0
- package/dist/core/RenderScheduler.d.ts +28 -0
- package/dist/core/RenderScheduler.d.ts.map +1 -0
- package/dist/core/Scale.d.ts +23 -0
- package/dist/core/Scale.d.ts.map +1 -0
- package/dist/core/ScaleManager.d.ts +45 -0
- package/dist/core/ScaleManager.d.ts.map +1 -0
- package/dist/formatters.d.ts +39 -0
- package/dist/formatters.d.ts.map +1 -0
- package/dist/hooks/useChart.d.ts +5 -0
- package/dist/hooks/useChart.d.ts.map +1 -0
- package/dist/hooks/useChartStore.d.ts +69 -0
- package/dist/hooks/useChartStore.d.ts.map +1 -0
- package/dist/hooks/useDrawHook.d.ts +14 -0
- package/dist/hooks/useDrawHook.d.ts.map +1 -0
- package/dist/hooks/useInteraction.d.ts +14 -0
- package/dist/hooks/useInteraction.d.ts.map +1 -0
- package/dist/hooks/useStreamingData.d.ts +35 -0
- package/dist/hooks/useStreamingData.d.ts.map +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +47 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +3203 -0
- package/dist/math/align.d.ts +10 -0
- package/dist/math/align.d.ts.map +1 -0
- package/dist/math/increments.d.ts +9 -0
- package/dist/math/increments.d.ts.map +1 -0
- package/dist/math/stack.d.ts +16 -0
- package/dist/math/stack.d.ts.map +1 -0
- package/dist/math/utils.d.ts +74 -0
- package/dist/math/utils.d.ts.map +1 -0
- package/dist/paths/bars.d.ts +9 -0
- package/dist/paths/bars.d.ts.map +1 -0
- package/dist/paths/candlestick.d.ts +35 -0
- package/dist/paths/candlestick.d.ts.map +1 -0
- package/dist/paths/catmullRom.d.ts +9 -0
- package/dist/paths/catmullRom.d.ts.map +1 -0
- package/dist/paths/linear.d.ts +10 -0
- package/dist/paths/linear.d.ts.map +1 -0
- package/dist/paths/monotoneCubic.d.ts +10 -0
- package/dist/paths/monotoneCubic.d.ts.map +1 -0
- package/dist/paths/points.d.ts +10 -0
- package/dist/paths/points.d.ts.map +1 -0
- package/dist/paths/spline.d.ts +9 -0
- package/dist/paths/spline.d.ts.map +1 -0
- package/dist/paths/stepped.d.ts +9 -0
- package/dist/paths/stepped.d.ts.map +1 -0
- package/dist/paths/types.d.ts +32 -0
- package/dist/paths/types.d.ts.map +1 -0
- package/dist/paths/utils.d.ts +19 -0
- package/dist/paths/utils.d.ts.map +1 -0
- package/dist/rendering/CanvasRenderer.d.ts +75 -0
- package/dist/rendering/CanvasRenderer.d.ts.map +1 -0
- package/dist/rendering/drawAxes.d.ts +8 -0
- package/dist/rendering/drawAxes.d.ts.map +1 -0
- package/dist/rendering/drawBands.d.ts +8 -0
- package/dist/rendering/drawBands.d.ts.map +1 -0
- package/dist/rendering/drawCursor.d.ts +22 -0
- package/dist/rendering/drawCursor.d.ts.map +1 -0
- package/dist/rendering/drawPoints.d.ts +13 -0
- package/dist/rendering/drawPoints.d.ts.map +1 -0
- package/dist/rendering/drawSelect.d.ts +14 -0
- package/dist/rendering/drawSelect.d.ts.map +1 -0
- package/dist/rendering/drawSeries.d.ts +7 -0
- package/dist/rendering/drawSeries.d.ts.map +1 -0
- package/dist/sync/SyncGroup.d.ts +33 -0
- package/dist/sync/SyncGroup.d.ts.map +1 -0
- package/dist/sync/useSyncGroup.d.ts +8 -0
- package/dist/sync/useSyncGroup.d.ts.map +1 -0
- package/dist/time/fmtDate.d.ts +15 -0
- package/dist/time/fmtDate.d.ts.map +1 -0
- package/dist/time/timeIncrs.d.ts +17 -0
- package/dist/time/timeIncrs.d.ts.map +1 -0
- package/dist/time/timeSplits.d.ts +6 -0
- package/dist/time/timeSplits.d.ts.map +1 -0
- package/dist/time/timeVals.d.ts +16 -0
- package/dist/time/timeVals.d.ts.map +1 -0
- package/dist/types/axes.d.ts +84 -0
- package/dist/types/axes.d.ts.map +1 -0
- package/dist/types/bands.d.ts +12 -0
- package/dist/types/bands.d.ts.map +1 -0
- package/dist/types/chart.d.ts +53 -0
- package/dist/types/chart.d.ts.map +1 -0
- package/dist/types/common.d.ts +62 -0
- package/dist/types/common.d.ts.map +1 -0
- package/dist/types/cursor.d.ts +22 -0
- package/dist/types/cursor.d.ts.map +1 -0
- package/dist/types/data.d.ts +32 -0
- package/dist/types/data.d.ts.map +1 -0
- package/dist/types/events.d.ts +57 -0
- package/dist/types/events.d.ts.map +1 -0
- package/dist/types/hooks.d.ts +28 -0
- package/dist/types/hooks.d.ts.map +1 -0
- package/dist/types/index.d.ts +10 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/legend.d.ts +8 -0
- package/dist/types/legend.d.ts.map +1 -0
- package/dist/types/scales.d.ts +60 -0
- package/dist/types/scales.d.ts.map +1 -0
- package/dist/types/series.d.ts +76 -0
- package/dist/types/series.d.ts.map +1 -0
- package/dist/types/timeline.d.ts +30 -0
- package/dist/types/timeline.d.ts.map +1 -0
- package/dist/types/tooltip.d.ts +33 -0
- package/dist/types/tooltip.d.ts.map +1 -0
- package/dist/utils/shallowEqual.d.ts +10 -0
- package/dist/utils/shallowEqual.d.ts.map +1 -0
- package/package.json +59 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Yeonsoo Park
|
|
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,341 @@
|
|
|
1
|
+
# uPlot+
|
|
2
|
+
|
|
3
|
+
High-performance React charting library ripped off from uPlot. Might perform occasionally better than original uPlot in React context (or worse). Definitely easier to use in React context.
|
|
4
|
+
|
|
5
|
+
**[Live Demo (85+ examples)](https://yeonsoo-p.github.io/Uplot-Plus/)**
|
|
6
|
+
|
|
7
|
+
## Features
|
|
8
|
+
|
|
9
|
+
- **Canvas 2D rendering** — no SVG or DOM elements for data visualization
|
|
10
|
+
- **Native React components** — declarative `<Chart>`, `<Series>`, `<Scale>`, `<Axis>` API
|
|
11
|
+
- **Multi-x-axis support** — multiple data groups with independent x-ranges on one chart
|
|
12
|
+
- **TypeScript-first** — strict types, full type exports, no `any`
|
|
13
|
+
- **7 path builders** — linear, stepped, bars, monotone cubic, Catmull-Rom, points, candlestick
|
|
14
|
+
- **Interactive** — wheel/touch zoom, drag-to-zoom, cursor snapping, series focus
|
|
15
|
+
- **Cursor sync** — linked crosshairs and tooltips across multiple charts
|
|
16
|
+
- **Compact bundle** — ~111KB (~30KB gzip), React 18+ peer dependency
|
|
17
|
+
- **Dual output** — ES module + CommonJS
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
npm install uplot-plus
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Peer dependencies:
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
npm install react react-dom
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
## Quick Start
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
import { Chart, Scale, Series, Axis } from 'uplot-plus';
|
|
35
|
+
|
|
36
|
+
const data = [
|
|
37
|
+
{
|
|
38
|
+
x: [1, 2, 3, 4, 5],
|
|
39
|
+
series: [
|
|
40
|
+
[10, 25, 13, 30, 18],
|
|
41
|
+
[5, 15, 20, 12, 28],
|
|
42
|
+
],
|
|
43
|
+
},
|
|
44
|
+
];
|
|
45
|
+
|
|
46
|
+
function App() {
|
|
47
|
+
return (
|
|
48
|
+
<Chart width={800} height={400} data={data}>
|
|
49
|
+
<Scale id="x" />
|
|
50
|
+
<Scale id="y" />
|
|
51
|
+
<Axis scale="x" label="X-Axis" />
|
|
52
|
+
<Axis scale="y" label="Y-Axis" />
|
|
53
|
+
<Series group={0} index={0} yScale="y" stroke="#e74c3c" width={2} label="Series A" />
|
|
54
|
+
<Series group={0} index={1} yScale="y" stroke="#3498db" width={2} label="Series B" />
|
|
55
|
+
</Chart>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Components
|
|
61
|
+
|
|
62
|
+
| Component | Description |
|
|
63
|
+
|-----------|-------------|
|
|
64
|
+
| `<Chart>` | Root container — creates the canvas, manages the chart store |
|
|
65
|
+
| `<Scale>` | Registers a scale (linear, log, asinh, ordinal) |
|
|
66
|
+
| `<Series>` | Registers a data series with stroke, fill, path builder |
|
|
67
|
+
| `<Axis>` | Renders an axis with ticks, labels, grid lines |
|
|
68
|
+
| `<Band>` | Fills a region between two series |
|
|
69
|
+
| `<Legend>` | Interactive legend with live cursor values, click-to-toggle |
|
|
70
|
+
| `<Tooltip>` | Floating tooltip at cursor position, auto-flips at edges |
|
|
71
|
+
| `<ZoomRanger>` | Overview mini-chart with draggable selection for zoom control |
|
|
72
|
+
| `<Timeline>` | Horizontal lanes of colored event spans |
|
|
73
|
+
| `<Sparkline>` | Compact inline chart for tables and dashboards (no axes, no interaction) |
|
|
74
|
+
| `<ResponsiveChart>` | Auto-sizes to container via ResizeObserver |
|
|
75
|
+
| `<HLine>` | Declarative horizontal line annotation |
|
|
76
|
+
| `<VLine>` | Declarative vertical line annotation |
|
|
77
|
+
| `<Region>` | Declarative shaded region annotation |
|
|
78
|
+
| `<AnnotationLabel>` | Declarative text label at data coordinates |
|
|
79
|
+
|
|
80
|
+
> Full props reference, usage examples, and demo links: [docs/COMPONENTS.md](docs/COMPONENTS.md)
|
|
81
|
+
|
|
82
|
+
## Data Model
|
|
83
|
+
|
|
84
|
+
Data is organized as groups, each with its own x-values:
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
import type { ChartData, XGroup } from 'uplot-plus';
|
|
88
|
+
|
|
89
|
+
// Single x-axis (most common)
|
|
90
|
+
const data: ChartData = [
|
|
91
|
+
{
|
|
92
|
+
x: [1, 2, 3, 4, 5],
|
|
93
|
+
series: [
|
|
94
|
+
[10, 20, 30, 40, 50], // series 0
|
|
95
|
+
[5, 15, 25, 35, 45], // series 1
|
|
96
|
+
],
|
|
97
|
+
},
|
|
98
|
+
];
|
|
99
|
+
|
|
100
|
+
// Multi x-axis — two groups with independent x-ranges
|
|
101
|
+
const multiData: ChartData = [
|
|
102
|
+
{ x: [0, 1, 2, 3], series: [[10, 20, 15, 25]] },
|
|
103
|
+
{ x: [0, 0.5, 1.5, 2.5, 3], series: [[8, 18, 22, 12, 30]] },
|
|
104
|
+
];
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Each series is referenced by a `(group, index)` tuple — `group` is the index into the `ChartData` array, `index` is the index into that group's `series` array.
|
|
108
|
+
|
|
109
|
+
Null values in series arrays create gaps in the chart. Use `spanGaps` on `<Series>` to bridge them.
|
|
110
|
+
|
|
111
|
+
## Path Builders
|
|
112
|
+
|
|
113
|
+
| Builder | Import | Use case |
|
|
114
|
+
|---------|--------|----------|
|
|
115
|
+
| `linear()` | `linear` | Line/area charts (default). Pixel-level decimation for large datasets |
|
|
116
|
+
| `stepped()` | `stepped` | Step charts — step-after, step-before, or mid-step |
|
|
117
|
+
| `bars()` | `bars` | Bar/column charts with configurable width, gaps, grouped bars |
|
|
118
|
+
| `monotoneCubic()` | `monotoneCubic` | Smooth curves that preserve monotonicity (no overshoot) |
|
|
119
|
+
| `catmullRom()` | `catmullRom` | Centripetal Catmull-Rom splines |
|
|
120
|
+
| `points()` | `points` | Scatter plots — points only, no connecting lines |
|
|
121
|
+
| `drawCandlesticks()` | `drawCandlesticks` | OHLC financial candlestick charts |
|
|
122
|
+
|
|
123
|
+
```tsx
|
|
124
|
+
import { Series, bars } from 'uplot-plus';
|
|
125
|
+
|
|
126
|
+
<Series group={0} index={0} yScale="y" paths={bars()} stroke="#3498db" fill="#3498db80" />
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
## Event Callbacks
|
|
130
|
+
|
|
131
|
+
React-idiomatic event handling — all callbacks receive resolved chart data (nearest point, data values, coordinates).
|
|
132
|
+
|
|
133
|
+
```tsx
|
|
134
|
+
import { Chart, Scale, Series, Axis } from 'uplot-plus';
|
|
135
|
+
|
|
136
|
+
<Chart
|
|
137
|
+
data={data} width={800} height={400}
|
|
138
|
+
onClick={(info) => {
|
|
139
|
+
if (info.point) {
|
|
140
|
+
console.log(`Clicked series ${info.point.seriesIdx} at y=${info.point.yVal}`);
|
|
141
|
+
}
|
|
142
|
+
}}
|
|
143
|
+
onContextMenu={(info) => {
|
|
144
|
+
// Right-click with resolved nearest point
|
|
145
|
+
showContextMenu(info.srcEvent, info.point);
|
|
146
|
+
}}
|
|
147
|
+
onDblClick={(info) => {
|
|
148
|
+
// Return false to prevent default zoom reset
|
|
149
|
+
return false;
|
|
150
|
+
}}
|
|
151
|
+
onSelect={(sel) => {
|
|
152
|
+
// Intercept drag selection — fetch detail data instead of zooming
|
|
153
|
+
fetchData(sel.ranges['x'].min, sel.ranges['x'].max);
|
|
154
|
+
return false; // prevent zoom
|
|
155
|
+
}}
|
|
156
|
+
onScaleChange={(scaleId, min, max) => {
|
|
157
|
+
console.log(`Scale ${scaleId} changed: [${min}, ${max}]`);
|
|
158
|
+
}}
|
|
159
|
+
onCursorMove={(info) => { /* fires on every mouse move */ }}
|
|
160
|
+
onCursorLeave={() => { /* cursor left the plot */ }}
|
|
161
|
+
>
|
|
162
|
+
<Scale id="x" />
|
|
163
|
+
<Scale id="y" />
|
|
164
|
+
<Axis scale="x" />
|
|
165
|
+
<Axis scale="y" />
|
|
166
|
+
<Series group={0} index={0} yScale="y" stroke="#e74c3c" width={2} label="Series A" />
|
|
167
|
+
</Chart>
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
### Controlled Scales
|
|
171
|
+
|
|
172
|
+
Control zoom and pan declaratively through React state — no imperative refs needed:
|
|
173
|
+
|
|
174
|
+
```tsx
|
|
175
|
+
import { useState, useCallback } from 'react';
|
|
176
|
+
import { Chart, Scale, Series, Axis } from 'uplot-plus';
|
|
177
|
+
|
|
178
|
+
function ZoomableChart({ data }) {
|
|
179
|
+
const [xRange, setXRange] = useState<[number, number] | null>(null);
|
|
180
|
+
|
|
181
|
+
const onScaleChange = useCallback((id: string, min: number, max: number) => {
|
|
182
|
+
if (id === 'x') setXRange([min, max]);
|
|
183
|
+
}, []);
|
|
184
|
+
|
|
185
|
+
return (
|
|
186
|
+
<>
|
|
187
|
+
<button onClick={() => setXRange(null)}>Reset Zoom</button>
|
|
188
|
+
<Chart data={data} width={800} height={400} onScaleChange={onScaleChange}>
|
|
189
|
+
<Scale id="x"
|
|
190
|
+
auto={xRange == null} min={xRange?.[0]} max={xRange?.[1]} />
|
|
191
|
+
<Scale id="y" />
|
|
192
|
+
{/* ... axes, series */}
|
|
193
|
+
</Chart>
|
|
194
|
+
</>
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
## Hooks
|
|
200
|
+
|
|
201
|
+
### `useChart()`
|
|
202
|
+
|
|
203
|
+
Access the chart store from a child component of `<Chart>`. This is an advanced API for building custom chart sub-components that need direct store access — for most use cases, prefer event callbacks and controlled Scale props.
|
|
204
|
+
|
|
205
|
+
```tsx
|
|
206
|
+
import { useChart } from 'uplot-plus';
|
|
207
|
+
|
|
208
|
+
function CustomControl() {
|
|
209
|
+
const store = useChart();
|
|
210
|
+
return <button onClick={() => store.toggleSeries(0, 0)}>Toggle</button>;
|
|
211
|
+
}
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### `useDrawHook()` / `useCursorDrawHook()`
|
|
215
|
+
|
|
216
|
+
Register custom Canvas 2D draw callbacks from child components. For most cases, prefer the `onDraw` / `onCursorDraw` props on `<Chart>` — these hooks are useful when building reusable chart sub-components.
|
|
217
|
+
|
|
218
|
+
```tsx
|
|
219
|
+
import { useDrawHook } from 'uplot-plus';
|
|
220
|
+
import type { DrawCallback } from 'uplot-plus';
|
|
221
|
+
|
|
222
|
+
const onDraw: DrawCallback = (dc) => {
|
|
223
|
+
dc.ctx.fillStyle = 'rgba(255,0,0,0.2)';
|
|
224
|
+
dc.ctx.fillRect(dc.plotBox.left, dc.plotBox.top, dc.plotBox.width, dc.plotBox.height);
|
|
225
|
+
};
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
### `useStreamingData()`
|
|
229
|
+
|
|
230
|
+
Sliding-window data management for real-time charts:
|
|
231
|
+
|
|
232
|
+
```tsx
|
|
233
|
+
import { useStreamingData } from 'uplot-plus';
|
|
234
|
+
|
|
235
|
+
const { data, push, start, stop, fps } = useStreamingData(initialData, {
|
|
236
|
+
window: 1000, // keep last 1000 points
|
|
237
|
+
batchSize: 10, // push 10 points per tick
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
// In your tick callback:
|
|
241
|
+
push([newX], [newY1], [newY2]);
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
## Axis Value Formatters
|
|
245
|
+
|
|
246
|
+
Pre-built formatters for common axis label patterns:
|
|
247
|
+
|
|
248
|
+
```tsx
|
|
249
|
+
import { fmtCompact, fmtSuffix, fmtHourMin, fmtMonthName, fmtLabels } from 'uplot-plus';
|
|
250
|
+
|
|
251
|
+
<Axis scale="y" values={fmtCompact()} /> // 1.2K, 3.5M
|
|
252
|
+
<Axis scale="y" values={fmtSuffix('%')} /> // 42%
|
|
253
|
+
<Axis scale="y" values={fmtSuffix('°C', 1)} /> // 23.5°C
|
|
254
|
+
<Axis scale="x" values={fmtHourMin({ utc: true })} /> // 14:30
|
|
255
|
+
<Axis scale="x" values={fmtMonthName()} /> // Jan, Feb, ...
|
|
256
|
+
<Axis scale="x" values={fmtLabels(['Q1','Q2','Q3','Q4'])} />
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
## Color Utilities
|
|
260
|
+
|
|
261
|
+
```tsx
|
|
262
|
+
import { fadeGradient, withAlpha, palette } from 'uplot-plus';
|
|
263
|
+
|
|
264
|
+
// Gradient that fades from color to transparent (for area fills)
|
|
265
|
+
<Series fill={fadeGradient('#3498db')} />
|
|
266
|
+
<Series fill={fadeGradient('#e74c3c', 1.0, 0.2)} />
|
|
267
|
+
|
|
268
|
+
// Match fill to stroke with lower opacity
|
|
269
|
+
<Series stroke="#2980b9" fill={withAlpha('#2980b9', 0.1)} />
|
|
270
|
+
|
|
271
|
+
// Generate N distinct colors
|
|
272
|
+
const colors = palette(5); // 5 visually distinct HSL colors
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
## Data Utilities
|
|
276
|
+
|
|
277
|
+
### `stackGroup`
|
|
278
|
+
|
|
279
|
+
Computes stacked series values and generates band configs:
|
|
280
|
+
|
|
281
|
+
```tsx
|
|
282
|
+
import { stackGroup, Band } from 'uplot-plus';
|
|
283
|
+
|
|
284
|
+
const raw = { x: [1, 2, 3], series: [[10, 20, 30], [5, 10, 15]] };
|
|
285
|
+
const { group, bands } = stackGroup(raw);
|
|
286
|
+
|
|
287
|
+
<Chart data={[group]}>
|
|
288
|
+
{bands.map((b, i) => <Band key={i} {...b} />)}
|
|
289
|
+
</Chart>
|
|
290
|
+
```
|
|
291
|
+
|
|
292
|
+
### `alignData`
|
|
293
|
+
|
|
294
|
+
Aligns data across multiple x-axes for multi-group charts.
|
|
295
|
+
|
|
296
|
+
## Annotations
|
|
297
|
+
|
|
298
|
+
Declarative annotation components — place inside `<Chart>`:
|
|
299
|
+
|
|
300
|
+
```tsx
|
|
301
|
+
import { HLine, VLine, Region, AnnotationLabel } from 'uplot-plus';
|
|
302
|
+
|
|
303
|
+
<Chart data={data}>
|
|
304
|
+
{/* ... scales, axes, series */}
|
|
305
|
+
<HLine value={65} yScale="y" stroke="#e74c3c" dash={[6, 4]} label="Threshold" />
|
|
306
|
+
<VLine value={100} xScale="x" stroke="#8e44ad" dash={[4, 4]} />
|
|
307
|
+
<Region yMin={40} yMax={60} yScale="y" fill="rgba(46,204,113,0.12)" />
|
|
308
|
+
<AnnotationLabel x={50} y={65} text="Alert zone" fill="#e74c3c" />
|
|
309
|
+
</Chart>
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
Imperative helpers are available for advanced draw hooks that need programmatic control:
|
|
313
|
+
|
|
314
|
+
```tsx
|
|
315
|
+
import { drawHLine, drawVLine, drawLabel, drawRegion } from 'uplot-plus';
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
## Scale Utilities
|
|
319
|
+
|
|
320
|
+
For advanced draw hooks that need pixel conversions:
|
|
321
|
+
|
|
322
|
+
```tsx
|
|
323
|
+
import { valToPos, posToVal } from 'uplot-plus';
|
|
324
|
+
|
|
325
|
+
const px = valToPos(dataValue, scale, dimension, offset);
|
|
326
|
+
const val = posToVal(pixelPos, scale, dimension, offset);
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
## Development
|
|
330
|
+
|
|
331
|
+
```sh
|
|
332
|
+
npm run dev # Start demo dev server (85+ examples)
|
|
333
|
+
npm run build # Build library (ES + CJS to dist/)
|
|
334
|
+
npm run typecheck # TypeScript strict check
|
|
335
|
+
npm run lint # ESLint
|
|
336
|
+
npm run test # Vitest test suite
|
|
337
|
+
```
|
|
338
|
+
|
|
339
|
+
## License
|
|
340
|
+
|
|
341
|
+
MIT
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { DrawContext } from './types/hooks';
|
|
2
|
+
import type { ScaleState } from './types';
|
|
3
|
+
export interface AnnotationStyle {
|
|
4
|
+
stroke?: string;
|
|
5
|
+
width?: number;
|
|
6
|
+
dash?: number[];
|
|
7
|
+
fill?: string;
|
|
8
|
+
font?: string;
|
|
9
|
+
}
|
|
10
|
+
/** Draw a horizontal line at a y-value.
|
|
11
|
+
* Assumes ctx is already pxRatio-scaled (handled by the library). */
|
|
12
|
+
export declare function drawHLine(dc: DrawContext, yScale: ScaleState, value: number, style?: AnnotationStyle): void;
|
|
13
|
+
/** Draw a vertical line at an x-value.
|
|
14
|
+
* Assumes ctx is already pxRatio-scaled (handled by the library). */
|
|
15
|
+
export declare function drawVLine(dc: DrawContext, xScale: ScaleState, value: number, style?: AnnotationStyle): void;
|
|
16
|
+
/** Draw a text label at data coordinates.
|
|
17
|
+
* Assumes ctx is already pxRatio-scaled (handled by the library). */
|
|
18
|
+
export declare function drawLabel(dc: DrawContext, xScale: ScaleState, yScale: ScaleState, xVal: number, yVal: number, text: string, style?: AnnotationStyle): void;
|
|
19
|
+
/** Draw a shaded region between two y-values.
|
|
20
|
+
* Assumes ctx is already pxRatio-scaled (handled by the library). */
|
|
21
|
+
export declare function drawRegion(dc: DrawContext, yScale: ScaleState, yMin: number, yMax: number, style?: AnnotationStyle): void;
|
|
22
|
+
//# sourceMappingURL=annotations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"annotations.d.ts","sourceRoot":"","sources":["../src/annotations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAG1C,MAAM,WAAW,eAAe;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;sEACsE;AACtE,wBAAgB,SAAS,CACvB,EAAE,EAAE,WAAW,EACf,MAAM,EAAE,UAAU,EAClB,KAAK,EAAE,MAAM,EACb,KAAK,GAAE,eAAoB,GAC1B,IAAI,CAYN;AAED;sEACsE;AACtE,wBAAgB,SAAS,CACvB,EAAE,EAAE,WAAW,EACf,MAAM,EAAE,UAAU,EAClB,KAAK,EAAE,MAAM,EACb,KAAK,GAAE,eAAoB,GAC1B,IAAI,CAYN;AAED;sEACsE;AACtE,wBAAgB,SAAS,CACvB,EAAE,EAAE,WAAW,EACf,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,KAAK,GAAE,eAAoB,GAC1B,IAAI,CASN;AAED;sEACsE;AACtE,wBAAgB,UAAU,CACxB,EAAE,EAAE,WAAW,EACf,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,KAAK,GAAE,eAAoB,GAC1B,IAAI,CAcN"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { ScaleState, BBox } from '../types';
|
|
2
|
+
import type { AxisState } from '../types/axes';
|
|
3
|
+
/**
|
|
4
|
+
* Run one cycle of axis calculation.
|
|
5
|
+
* For each visible axis, compute tick positions, labels, and size.
|
|
6
|
+
* Returns true if all axis sizes have converged.
|
|
7
|
+
*
|
|
8
|
+
* Ported from uPlot uPlot.js axesCalc.
|
|
9
|
+
*/
|
|
10
|
+
export declare function axesCalc(axisStates: AxisState[], getScale: (id: string) => ScaleState | undefined, plotWidCss: number, plotHgtCss: number, cycleNum: number): boolean;
|
|
11
|
+
/**
|
|
12
|
+
* Compute the plot area bounding box by subtracting axis sizes from the chart dimensions.
|
|
13
|
+
*
|
|
14
|
+
* Ported from uPlot uPlot.js calcPlotRect (lines 818-870).
|
|
15
|
+
*/
|
|
16
|
+
export declare function calcPlotRect(chartWidth: number, chartHeight: number, axisStates: AxisState[]): BBox;
|
|
17
|
+
/**
|
|
18
|
+
* Compute axis positions (_pos and _lpos) using cumulative offsets from plot edges.
|
|
19
|
+
*
|
|
20
|
+
* Ported from uPlot uPlot.js calcAxesRects (lines 872-899).
|
|
21
|
+
*/
|
|
22
|
+
export declare function calcAxesRects(axisStates: AxisState[], plotBox: BBox): void;
|
|
23
|
+
/**
|
|
24
|
+
* Run the convergence loop: repeatedly calculate axes and plot rect
|
|
25
|
+
* until axis sizes stabilize (or max 3 cycles).
|
|
26
|
+
*
|
|
27
|
+
* Ported from uPlot uPlot.js convergeSize.
|
|
28
|
+
*/
|
|
29
|
+
export declare function convergeSize(chartWidth: number, chartHeight: number, axisStates: AxisState[], getScale: (id: string) => ScaleState | undefined): BBox;
|
|
30
|
+
//# sourceMappingURL=layout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"layout.d.ts","sourceRoot":"","sources":["../../src/axes/layout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAiB/C;;;;;;GAMG;AACH,wBAAgB,QAAQ,CACtB,UAAU,EAAE,SAAS,EAAE,EACvB,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,UAAU,GAAG,SAAS,EAChD,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,QAAQ,EAAE,MAAM,GACf,OAAO,CAoFT;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAC1B,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,SAAS,EAAE,GACtB,IAAI,CAsCN;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,UAAU,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,IAAI,GAAG,IAAI,CA8B1E;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,UAAU,EAAE,MAAM,EAClB,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,SAAS,EAAE,EACvB,QAAQ,EAAE,CAAC,EAAE,EAAE,MAAM,KAAK,UAAU,GAAG,SAAS,GAC/C,IAAI,CAqCN"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { AxisConfig, AxisState } from '../types/axes';
|
|
2
|
+
/**
|
|
3
|
+
* Generate tick split positions for a numeric (linear) axis.
|
|
4
|
+
* Ported from uPlot opts.js numAxisSplits.
|
|
5
|
+
*/
|
|
6
|
+
export declare function numAxisSplits(scaleMin: number, scaleMax: number, foundIncr: number, _foundSpace: number, forceMin: boolean): number[];
|
|
7
|
+
/**
|
|
8
|
+
* Format tick values as strings for a numeric axis.
|
|
9
|
+
* Ported from uPlot opts.js numAxisVals.
|
|
10
|
+
*/
|
|
11
|
+
export declare function numAxisVals(splits: number[]): string[];
|
|
12
|
+
/**
|
|
13
|
+
* Generate tick split positions for a log-scale axis.
|
|
14
|
+
* Ported from uPlot opts.js logAxisSplits.
|
|
15
|
+
*/
|
|
16
|
+
export declare function logAxisSplits(scaleMin: number, scaleMax: number, logBase: number): number[];
|
|
17
|
+
/**
|
|
18
|
+
* Generate tick split positions for an asinh (symmetric log) axis.
|
|
19
|
+
* Produces linear ticks near zero and logarithmic ticks at larger magnitudes.
|
|
20
|
+
*
|
|
21
|
+
* @param scaleMin - minimum value on the scale
|
|
22
|
+
* @param scaleMax - maximum value on the scale
|
|
23
|
+
* @param linthresh - linear threshold (values within [-linthresh, linthresh] are linear)
|
|
24
|
+
*/
|
|
25
|
+
export declare function asinhAxisSplits(scaleMin: number, scaleMax: number, linthresh?: number): number[];
|
|
26
|
+
/**
|
|
27
|
+
* Filter log axis split values to reduce label density.
|
|
28
|
+
* Keeps only values that are exact powers of the log base.
|
|
29
|
+
* This prevents crowded labels at intermediate ticks (2, 3, 4... between 1 and 10).
|
|
30
|
+
*/
|
|
31
|
+
export declare function logAxisValFilter(splits: number[], logBase: number): boolean[];
|
|
32
|
+
/**
|
|
33
|
+
* Determine optimal tick increment and spacing for an axis.
|
|
34
|
+
* Ported from uPlot uPlot.js getIncrSpace.
|
|
35
|
+
*/
|
|
36
|
+
export declare function getIncrSpace(axis: AxisConfig, min: number, max: number, fullDim: number): [number, number];
|
|
37
|
+
/**
|
|
38
|
+
* Compute the size of an axis in CSS pixels.
|
|
39
|
+
* For vertical axes, estimates width from the longest tick label.
|
|
40
|
+
* For horizontal axes, uses a fixed height based on font size.
|
|
41
|
+
*/
|
|
42
|
+
export declare function computeAxisSize(axis: AxisConfig, _values: string[] | null, _cycleNum: number): number;
|
|
43
|
+
/**
|
|
44
|
+
* Create an initial AxisState from an AxisConfig.
|
|
45
|
+
*/
|
|
46
|
+
export declare function createAxisState(config: AxisConfig): AxisState;
|
|
47
|
+
//# sourceMappingURL=ticks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ticks.d.ts","sourceRoot":"","sources":["../../src/axes/ticks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAiB3D;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,EACjB,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,OAAO,GAChB,MAAM,EAAE,CAaV;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAEtD;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAC3B,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GACd,MAAM,EAAE,CA0CV;AAED;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAC7B,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,SAAS,SAAI,GACZ,MAAM,EAAE,CA8CV;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,MAAM,EAAE,EAChB,OAAO,EAAE,MAAM,GACd,OAAO,EAAE,CAUX;AAYD;;;GAGG;AACH,wBAAgB,YAAY,CAC1B,IAAI,EAAE,UAAU,EAChB,GAAG,EAAE,MAAM,EACX,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,MAAM,GACd,CAAC,MAAM,EAAE,MAAM,CAAC,CAWlB;AAKD;;;;GAIG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,UAAU,EAChB,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EACxB,SAAS,EAAE,MAAM,GAChB,MAAM,CAsBR;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,UAAU,GAAG,SAAS,CAa7D"}
|
package/dist/colors.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { GradientConfig } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Create a vertical linear gradient that fades a color from one opacity to another.
|
|
4
|
+
* Useful for area charts: `fill={fadeGradient('#3498db')}`.
|
|
5
|
+
*
|
|
6
|
+
* Supports hex (#rgb, #rrggbb) and rgb()/rgba() color strings.
|
|
7
|
+
*
|
|
8
|
+
* @param color - CSS color string (hex or rgb/rgba)
|
|
9
|
+
* @param fromAlpha - opacity at the top (default 0.8)
|
|
10
|
+
* @param toAlpha - opacity at the bottom (default 0.0)
|
|
11
|
+
*/
|
|
12
|
+
export declare function fadeGradient(color: string, fromAlpha?: number, toAlpha?: number): GradientConfig;
|
|
13
|
+
/**
|
|
14
|
+
* Return a CSS color string with a new alpha value.
|
|
15
|
+
* Useful for matching fill to stroke: `fill={withAlpha(stroke, 0.1)}`.
|
|
16
|
+
*
|
|
17
|
+
* Supports hex (#rgb, #rrggbb) and rgb()/rgba() color strings.
|
|
18
|
+
*
|
|
19
|
+
* @param color - CSS color string (hex or rgb/rgba)
|
|
20
|
+
* @param alpha - opacity 0–1
|
|
21
|
+
*/
|
|
22
|
+
export declare function withAlpha(color: string, alpha: number): string;
|
|
23
|
+
/**
|
|
24
|
+
* Generate a palette of N visually distinct colors using HSL rotation.
|
|
25
|
+
* Uses the golden angle (~137.5°) for maximum separation between adjacent colors.
|
|
26
|
+
*
|
|
27
|
+
* @param n - number of colors to generate
|
|
28
|
+
* @param saturation - HSL saturation percentage (default 65)
|
|
29
|
+
* @param lightness - HSL lightness percentage (default 50)
|
|
30
|
+
*/
|
|
31
|
+
export declare function palette(n: number, saturation?: number, lightness?: number): string[];
|
|
32
|
+
//# sourceMappingURL=colors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"colors.d.ts","sourceRoot":"","sources":["../src/colors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAqC9C;;;;;;;;;GASG;AACH,wBAAgB,YAAY,CAC1B,KAAK,EAAE,MAAM,EACb,SAAS,SAAM,EACf,OAAO,SAAM,GACZ,cAAc,CAchB;AAED;;;;;;;;GAQG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAK9D;AAED;;;;;;;GAOG;AACH,wBAAgB,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,SAAK,EAAE,SAAS,SAAK,GAAG,MAAM,EAAE,CAQ5E"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { AxisConfig } from '../types';
|
|
2
|
+
import { Side } from '../types';
|
|
3
|
+
export type AxisProps = Omit<AxisConfig, 'side'> & {
|
|
4
|
+
side?: Side;
|
|
5
|
+
};
|
|
6
|
+
/**
|
|
7
|
+
* Renderless component that registers an axis config with the chart store.
|
|
8
|
+
* Must be a child of <Chart>.
|
|
9
|
+
*
|
|
10
|
+
* Mount effect registers/unregisters based on identity keys (scale, side).
|
|
11
|
+
* Sync effect updates config when any prop changes (shallow-equality bail-out).
|
|
12
|
+
*/
|
|
13
|
+
export declare function Axis(props: AxisProps): null;
|
|
14
|
+
//# sourceMappingURL=Axis.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Axis.d.ts","sourceRoot":"","sources":["../../src/components/Axis.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAIhC,MAAM,MAAM,SAAS,GAAG,IAAI,CAAC,UAAU,EAAE,MAAM,CAAC,GAAG;IAAE,IAAI,CAAC,EAAE,IAAI,CAAA;CAAE,CAAC;AAMnE;;;;;;GAMG;AACH,wBAAgB,IAAI,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CAuC3C"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { BandConfig } from '../types/bands';
|
|
2
|
+
/**
|
|
3
|
+
* Renderless component that registers a band config with the chart store.
|
|
4
|
+
* A band fills the area between two series.
|
|
5
|
+
*
|
|
6
|
+
* Uses a mount/update split: registers once on mount, replaces config immutably on prop changes.
|
|
7
|
+
* Destructures series tuple to primitives for stable dependency comparison.
|
|
8
|
+
*/
|
|
9
|
+
export declare function Band({ series, group, fill, dir }: BandConfig): null;
|
|
10
|
+
//# sourceMappingURL=Band.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Band.d.ts","sourceRoot":"","sources":["../../src/components/Band.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAGjD;;;;;;GAMG;AACH,wBAAgB,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,UAAU,GAAG,IAAI,CA6BnE"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { ChartProps } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Root chart component.
|
|
4
|
+
* Creates a canvas element, manages the chart store, and provides context to children.
|
|
5
|
+
* Canvas drawing is completely decoupled from React's reconciliation cycle.
|
|
6
|
+
*/
|
|
7
|
+
export declare function Chart({ width, height, data, children, className, pxRatio: pxRatioOverride, onDraw, onCursorDraw, syncKey, cursor, onClick, onContextMenu, onDblClick, onCursorMove, onCursorLeave, onScaleChange, onSelect, }: ChartProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
//# sourceMappingURL=Chart.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Chart.d.ts","sourceRoot":"","sources":["../../src/components/Chart.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAO3C;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,EACpB,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,eAAe,EAClE,MAAM,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,EACrC,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,YAAY,EAAE,aAAa,EAC/D,aAAa,EAAE,QAAQ,GACxB,EAAE,UAAU,2CAsJZ"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { LegendConfig } from '../types/legend';
|
|
3
|
+
interface LegendProps extends LegendConfig {
|
|
4
|
+
className?: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Legend component that shows series labels with color swatches.
|
|
8
|
+
* Updates live as the cursor moves. Click to toggle series visibility.
|
|
9
|
+
*/
|
|
10
|
+
export declare function Legend({ show, position, className }: LegendProps): React.ReactElement | null;
|
|
11
|
+
export {};
|
|
12
|
+
//# sourceMappingURL=Legend.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Legend.d.ts","sourceRoot":"","sources":["../../src/components/Legend.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA0D,MAAM,OAAO,CAAC;AAE/E,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAGpD,UAAU,WAAY,SAAQ,YAAY;IACxC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAwDD;;;GAGG;AACH,wBAAgB,MAAM,CAAC,EAAE,IAAW,EAAE,QAAmB,EAAE,SAAS,EAAE,EAAE,WAAW,GAAG,KAAK,CAAC,YAAY,GAAG,IAAI,CAiE9G"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ChartProps } from '../types/chart';
|
|
2
|
+
export interface ResponsiveChartProps extends Omit<ChartProps, 'width' | 'height'> {
|
|
3
|
+
/** Minimum width in CSS pixels (default: 100) */
|
|
4
|
+
minWidth?: number;
|
|
5
|
+
/** Minimum height in CSS pixels (default: 100) */
|
|
6
|
+
minHeight?: number;
|
|
7
|
+
/** If set, height = width / aspectRatio */
|
|
8
|
+
aspectRatio?: number;
|
|
9
|
+
/** Initial height when container height is auto (default: 300) */
|
|
10
|
+
initialHeight?: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Chart wrapper that auto-sizes to its container via ResizeObserver.
|
|
14
|
+
* The container div takes 100% width; height is either derived from
|
|
15
|
+
* container, aspectRatio, or initialHeight.
|
|
16
|
+
*/
|
|
17
|
+
export declare function ResponsiveChart({ minWidth, minHeight, aspectRatio, initialHeight, ...chartProps }: ResponsiveChartProps): React.JSX.Element;
|
|
18
|
+
//# sourceMappingURL=ResponsiveChart.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ResponsiveChart.d.ts","sourceRoot":"","sources":["../../src/components/ResponsiveChart.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAEjD,MAAM,WAAW,oBAAqB,SAAQ,IAAI,CAAC,UAAU,EAAE,OAAO,GAAG,QAAQ,CAAC;IAChF,iDAAiD;IACjD,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kDAAkD;IAClD,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,2CAA2C;IAC3C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,kEAAkE;IAClE,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,EAC9B,QAAc,EACd,SAAe,EACf,WAAW,EACX,aAAmB,EACnB,GAAG,UAAU,EACd,EAAE,oBAAoB,GAAG,KAAK,CAAC,GAAG,CAAC,OAAO,CAmD1C"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ScaleConfig } from '../types';
|
|
2
|
+
export type ScaleProps = ScaleConfig;
|
|
3
|
+
/**
|
|
4
|
+
* Renderless component that registers a scale config with the chart store.
|
|
5
|
+
* Must be a child of <Chart>.
|
|
6
|
+
*
|
|
7
|
+
* Mount effect registers/unregisters based on identity key (id).
|
|
8
|
+
* Sync effect updates config when any prop changes (shallow-equality bail-out).
|
|
9
|
+
*/
|
|
10
|
+
export declare function Scale(props: ScaleProps): null;
|
|
11
|
+
//# sourceMappingURL=Scale.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Scale.d.ts","sourceRoot":"","sources":["../../src/components/Scale.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAI5C,MAAM,MAAM,UAAU,GAAG,WAAW,CAAC;AAErC;;;;;;GAMG;AACH,wBAAgB,KAAK,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAgC7C"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { SeriesConfig } from '../types';
|
|
2
|
+
export type SeriesProps = SeriesConfig;
|
|
3
|
+
/**
|
|
4
|
+
* Renderless component that registers a series config with the chart store.
|
|
5
|
+
* Must be a child of <Chart>.
|
|
6
|
+
*
|
|
7
|
+
* Mount effect registers/unregisters based on identity keys (group, index).
|
|
8
|
+
* Sync effect updates config when any prop changes (shallow-equality bail-out).
|
|
9
|
+
*/
|
|
10
|
+
export declare function Series(props: SeriesProps): null;
|
|
11
|
+
//# sourceMappingURL=Series.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Series.d.ts","sourceRoot":"","sources":["../../src/components/Series.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAI7C,MAAM,MAAM,WAAW,GAAG,YAAY,CAAC;AAEvC;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,WAAW,GAAG,IAAI,CAoC/C"}
|