liveline 0.0.3 → 0.0.5
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 +81 -2
- package/dist/index.cjs +1893 -297
- package/dist/index.d.cts +45 -3
- package/dist/index.d.ts +45 -3
- package/dist/index.js +1892 -297
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Liveline
|
|
2
2
|
|
|
3
|
-
Real-time animated
|
|
3
|
+
Real-time animated charts for React. Line and candlestick modes, canvas-rendered, 60fps, zero CSS imports.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
@@ -66,6 +66,33 @@ The component fills its parent container. Set a height on the parent. Pass `data
|
|
|
66
66
|
| `valueMomentumColor` | `boolean` | `false` | Color the value text green/red by momentum |
|
|
67
67
|
| `degen` | `boolean \| DegenOptions` | `false` | Burst particles + chart shake on momentum swings |
|
|
68
68
|
|
|
69
|
+
**Candlestick**
|
|
70
|
+
|
|
71
|
+
| Prop | Type | Default | Description |
|
|
72
|
+
|------|------|---------|-------------|
|
|
73
|
+
| `mode` | `'line' \| 'candle'` | `'line'` | Chart type |
|
|
74
|
+
| `candles` | `CandlePoint[]` | — | OHLC candle data `{ time, open, high, low, close }` |
|
|
75
|
+
| `candleWidth` | `number` | — | Seconds per candle |
|
|
76
|
+
| `liveCandle` | `CandlePoint` | — | Current in-progress candle with real-time OHLC |
|
|
77
|
+
| `lineMode` | `boolean` | `false` | Morph candles into a line display |
|
|
78
|
+
| `lineData` | `LivelinePoint[]` | — | Tick-level data for line mode density |
|
|
79
|
+
| `lineValue` | `number` | — | Current tick value for line mode |
|
|
80
|
+
| `onModeChange` | `(mode) => void` | — | Callback for built-in line/candle toggle |
|
|
81
|
+
|
|
82
|
+
When `mode="candle"`, pass `candles` (committed OHLC bars) and `liveCandle` (the current bar, updated every tick). `candleWidth` sets the time bucket in seconds. The `lineMode` prop smoothly morphs between candle and line views — candle bodies collapse to close price, then the line extends outward. Provide `lineData` and `lineValue` (tick-level resolution) for a smooth density transition during the morph.
|
|
83
|
+
|
|
84
|
+
The `onModeChange` prop renders a built-in line/candle toggle next to the time window buttons.
|
|
85
|
+
|
|
86
|
+
**State**
|
|
87
|
+
|
|
88
|
+
| Prop | Type | Default | Description |
|
|
89
|
+
|------|------|---------|-------------|
|
|
90
|
+
| `loading` | `boolean` | `false` | Breathing line animation — use while waiting for data |
|
|
91
|
+
| `paused` | `boolean` | `false` | Smoothly freeze chart scrolling; resume catches up to real time |
|
|
92
|
+
| `emptyText` | `string` | `'No data to display'` | Text shown in the empty state |
|
|
93
|
+
|
|
94
|
+
When `loading` flips to `false` with data present, the loading line morphs into the actual chart shape. In line mode, the fill, grid, and badge animate in. In candle mode, flat lines expand into full OHLC bodies while the morph line fades out. When `data` is empty and `loading` is `false`, a minimal "No data" empty state is shown.
|
|
95
|
+
|
|
69
96
|
**Time**
|
|
70
97
|
|
|
71
98
|
| Prop | Type | Default | Description |
|
|
@@ -110,6 +137,45 @@ The component fills its parent container. Set a height on the parent. Pass `data
|
|
|
110
137
|
<Liveline data={data} value={value} color="#3b82f6" theme="dark" />
|
|
111
138
|
```
|
|
112
139
|
|
|
140
|
+
### Candlestick (minimal)
|
|
141
|
+
|
|
142
|
+
```tsx
|
|
143
|
+
<Liveline
|
|
144
|
+
mode="candle"
|
|
145
|
+
data={ticks}
|
|
146
|
+
value={latestTick}
|
|
147
|
+
candles={candles}
|
|
148
|
+
candleWidth={60}
|
|
149
|
+
liveCandle={liveCandle}
|
|
150
|
+
color="#f7931a"
|
|
151
|
+
formatValue={(v) => `$${v.toLocaleString('en-US', { minimumFractionDigits: 2 })}`}
|
|
152
|
+
/>
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Candlestick (line mode toggle + time windows)
|
|
156
|
+
|
|
157
|
+
```tsx
|
|
158
|
+
<Liveline
|
|
159
|
+
mode="candle"
|
|
160
|
+
data={ticks}
|
|
161
|
+
value={latestTick}
|
|
162
|
+
candles={candles}
|
|
163
|
+
candleWidth={60}
|
|
164
|
+
liveCandle={liveCandle}
|
|
165
|
+
lineMode={showLine}
|
|
166
|
+
lineData={ticks}
|
|
167
|
+
lineValue={latestTick}
|
|
168
|
+
onModeChange={(mode) => setShowLine(mode === 'line')}
|
|
169
|
+
color="#f7931a"
|
|
170
|
+
formatValue={(v) => `$${v.toLocaleString('en-US', { minimumFractionDigits: 2 })}`}
|
|
171
|
+
windows={[
|
|
172
|
+
{ label: '5m', secs: 300 },
|
|
173
|
+
{ label: '15m', secs: 900 },
|
|
174
|
+
{ label: '1h', secs: 3600 },
|
|
175
|
+
]}
|
|
176
|
+
/>
|
|
177
|
+
```
|
|
178
|
+
|
|
113
179
|
### Crypto-style (momentum + degen + exaggerate)
|
|
114
180
|
|
|
115
181
|
```tsx
|
|
@@ -143,6 +209,17 @@ The component fills its parent container. Set a height on the parent. Pass `data
|
|
|
143
209
|
/>
|
|
144
210
|
```
|
|
145
211
|
|
|
212
|
+
### Loading + pause
|
|
213
|
+
|
|
214
|
+
```tsx
|
|
215
|
+
<Liveline
|
|
216
|
+
data={data}
|
|
217
|
+
value={value}
|
|
218
|
+
loading={isConnecting}
|
|
219
|
+
paused={!isTabVisible}
|
|
220
|
+
/>
|
|
221
|
+
```
|
|
222
|
+
|
|
146
223
|
### Orderbook (orderbook data + particles)
|
|
147
224
|
|
|
148
225
|
```tsx
|
|
@@ -160,8 +237,10 @@ The component fills its parent container. Set a height on the parent. Pass `data
|
|
|
160
237
|
|
|
161
238
|
- **Canvas rendering** — single `<canvas>` element, no DOM nodes per data point
|
|
162
239
|
- **requestAnimationFrame** loop pauses when the tab is hidden
|
|
163
|
-
- **
|
|
240
|
+
- **Fritsch-Carlson monotone splines** for smooth curves — no overshoots beyond local min/max
|
|
164
241
|
- **Frame-rate-independent lerp** on value, Y-axis range, badge color, and scrub opacity
|
|
242
|
+
- **Candlestick rendering** — OHLC bodies + wicks with bull/bear coloring, smooth live candle updates
|
|
243
|
+
- **Line/candle morph** — candle bodies collapse to close price, morph line extends center-out, coordinated alpha crossfade
|
|
165
244
|
- **ResizeObserver** tracks container size — no per-frame layout reads
|
|
166
245
|
- **Theme derivation** — full palette from one accent color + light/dark mode
|
|
167
246
|
- **Binary search interpolation** for hover value lookup
|