liveline 0.0.4 → 0.0.6

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # Liveline
2
2
 
3
- Real-time animated line chart for React. Canvas-rendered, 60fps, zero CSS imports.
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,23 @@ 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
+
69
86
  **State**
70
87
 
71
88
  | Prop | Type | Default | Description |
@@ -74,7 +91,7 @@ The component fills its parent container. Set a height on the parent. Pass `data
74
91
  | `paused` | `boolean` | `false` | Smoothly freeze chart scrolling; resume catches up to real time |
75
92
  | `emptyText` | `string` | `'No data to display'` | Text shown in the empty state |
76
93
 
77
- When `loading` flips to `false` with data present, the flat loading line morphs into the actual chart shape (line, fill, grid, and badge all animate in). When `data` is empty and `loading` is `false`, a minimal "No data" empty state is shown.
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.
78
95
 
79
96
  **Time**
80
97
 
@@ -120,6 +137,45 @@ When `loading` flips to `false` with data present, the flat loading line morphs
120
137
  <Liveline data={data} value={value} color="#3b82f6" theme="dark" />
121
138
  ```
122
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
+
123
179
  ### Crypto-style (momentum + degen + exaggerate)
124
180
 
125
181
  ```tsx
@@ -183,6 +239,8 @@ When `loading` flips to `false` with data present, the flat loading line morphs
183
239
  - **requestAnimationFrame** loop pauses when the tab is hidden
184
240
  - **Fritsch-Carlson monotone splines** for smooth curves — no overshoots beyond local min/max
185
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
186
244
  - **ResizeObserver** tracks container size — no per-frame layout reads
187
245
  - **Theme derivation** — full palette from one accent color + light/dark mode
188
246
  - **Binary search interpolation** for hover value lookup