1- <p align =" center " style = " margin-bottom : 0 ; margin-top : 20 px ; " >
2- <img src =" docs/assets/chartgpu.png " alt =" ChartGPU " width =" 400 " >
1+ <p align =" center " >
2+ <img src =" docs/assets/chartgpu.png " alt =" ChartGPU " width =" 360 " >
33</p >
44
5- <p align =" center " style =" margin-top :-18px ;" >
6- React bindings for <a href =" https://github.com/ChartGPU/ChartGPU " >ChartGPU</a >: MIT-licensed WebGPU charts for dense real-time, multi-series and multi-panel dashboards.
5+ <p align =" center " >
6+ React bindings for <a href =" https://github.com/ChartGPU/ChartGPU " >ChartGPU</a > —
7+ WebGPU charts for large datasets, real-time streaming, multi-chart dashboards, and 3D series.
8+ MIT licensed.
79</p >
810
9- <div align =" center " >
11+ <p align =" center " >
12+ <a href =" https://www.npmjs.com/package/chartgpu-react " ><img src =" https://img.shields.io/npm/v/chartgpu-react " alt =" npm " ></a >
13+ <a href =" https://github.com/ChartGPU/chartgpu-react/blob/main/LICENSE " ><img src =" https://img.shields.io/badge/license-MIT-yellow " alt =" MIT " ></a >
14+ <a href =" https://chartgpu.io/docs/getting-started/ " ><img src =" https://img.shields.io/badge/docs-getting%20started-blue " alt =" docs " ></a >
15+ <a href =" https://chartgpu.io " ><img src =" https://img.shields.io/badge/demo-chartgpu.io-brightgreen " alt =" demo " ></a >
16+ <a href =" https://github.com/mikbry/awesome-webgpu " ><img src =" https://awesome.re/mentioned-badge.svg " alt =" Featured in Awesome WebGPU " height =" 20 " /></a >
17+ </p >
1018
11- [ <img src =" docs/assets/powered-by-webgpu.svg " alt =" Powered by WebGPU " height =" 28 " />] ( #browser-support-webgpu-required )
12- [ ![ npm version] ( https://img.shields.io/npm/v/chartgpu-react?style=for-the-badge&color=blue )] ( https://www.npmjs.com/package/chartgpu-react )
13- [ ![ NPM Downloads] ( https://img.shields.io/npm/dm/chartgpu-react?style=for-the-badge&color=%2368cc49 )] ( https://www.npmjs.com/package/chartgpu-react )
14- [ ![ License: MIT] ( https://img.shields.io/badge/License-MIT-yellow.svg?style=for-the-badge )] ( https://github.com/ChartGPU/chartgpu-react/blob/main/LICENSE )
15- [ ![ Live Demo] ( https://img.shields.io/badge/demo-live-brightgreen?style=for-the-badge )] ( https://chartgpu.io )
16- [ ![ Documentation] ( https://img.shields.io/badge/Documentation-Getting%20Started-blue?style=for-the-badge )] ( https://chartgpu.io/docs/getting-started/ )
17- [ ![ API Reference] ( https://img.shields.io/badge/API-Reference-blue?style=for-the-badge )] ( ./docs/API.md )
19+ <p align =" center " >
20+ <a href =" https://chartgpu.io " >Live demo</a > ·
21+ <a href =" https://chartgpu.io/docs/ " >Docs</a > ·
22+ <a href =" ./docs/API.md " >React API</a > ·
23+ <a href =" https://github.com/ChartGPU/ChartGPU " >Core library</a >
24+ </p >
1825
19- [ < img src = " https://hackerbadge.now.sh/api?id=46706528 " alt = " Featured on Hacker News " height = " 30 " /> ] ( https://news.ycombinator.com/item?id=46706528 )
26+ ---
2027
21- [ < img src = " https://awesome.re/mentioned-badge.svg " alt = " Featured in Awesome WebGPU " style = " height : 30 px ; " /> ] ( https://github.com/mikbry/awesome-webgpu )
28+ ## Overview
2229
23- </ div >
30+ ` chartgpu-react ` is a thin React + TypeScript wrapper around [ ` @chartgpu/chartgpu ` ] ( https://www.npmjs.com/package/@chartgpu/chartgpu ) . Core charting stays in ChartGPU; this package handles:
2431
25- ` chartgpu-react ` is a thin React + TypeScript wrapper around [ ` @chartgpu/chartgpu ` ] ( https://www.npmjs.com/package/@chartgpu/chartgpu ) : lifecycle, resize, events, refs, and multi-chart GPU sharing in React. Core charting stays in ChartGPU (MIT commercial embed, zero npm runtime dependencies in core, WebGPU required, no WebGL fallback).
32+ - Async create/dispose lifecycle and debounced resize
33+ - Declarative event props and imperative ` ChartGPUHandle ` ref
34+ - Shared-device multi-chart via ` useGPUContext ` / ` gpuContext `
35+ - Chart sync via ` useConnectCharts ` / ` connectCharts `
2636
27- Use it when Chart.js, ECharts, or uPlot hit streaming or multi-panel walls. Commercial GPU seats often ship WebGL fallback and broader catalog; ChartGPU is the open WebGPU-only embed .
37+ ChartGPU renders with ** WebGPU ** (not Canvas2D or WebGL). There is ** no WebGL/Canvas fallback** . Unsupported browsers must be gated by the host app .
2838
29- Demo and docs: [ chartgpu.io] ( https://chartgpu.io ) · [ docs ] ( https://chartgpu.io/docs/ ) · [ streaming dashboards] ( https://chartgpu.io/docs/streaming-dashboards/ ) · [ core repo ] ( https://github.com/ChartGPU/ChartGPU )
39+ Demo and product docs: [ chartgpu.io] ( https://chartgpu.io ) · [ streaming dashboards] ( https://chartgpu.io/docs/streaming-dashboards/ )
3040
3141---
3242
@@ -36,51 +46,44 @@ Demo and docs: [chartgpu.io](https://chartgpu.io) · [docs](https://chartgpu.io/
3646npm install chartgpu-react @chartgpu/chartgpu react react-dom
3747```
3848
39- Peer dependency: ** ` @chartgpu/chartgpu ` ^0.3.6** (aligned with this package’s 0.3.x line). React 18 or 19.
40-
41- ---
49+ Peer dependency: ** ` @chartgpu/chartgpu ` ^0.3.9** . React 18 or 19.
4250
43- ## Quick start
51+ ### Minimal example
4452
4553``` tsx
4654import { ChartGPU } from ' chartgpu-react' ;
4755import type { ChartGPUOptions } from ' chartgpu-react' ;
4856
4957function MyChart() {
5058 const options: ChartGPUOptions = {
51- series: [
52- {
53- type: ' line' ,
54- data: {
55- x: new Float64Array ([0 , 1 , 2 , 3 ]),
56- y: new Float64Array ([0 , 1 , 4 , 9 ]),
57- },
58- lineStyle: { width: 2 , color: ' #667eea' },
59+ series: [{
60+ type: ' line' ,
61+ data: {
62+ x: new Float64Array ([0 , 1 , 2 ]),
63+ y: new Float64Array ([1 , 3 , 2 ]),
5964 },
60- ],
61- xAxis: { type: ' value' },
62- yAxis: { type: ' value' },
65+ }],
6366 };
6467
65- return <ChartGPU options = { options } style = { { width: ' 100%' , height: ' 400px ' }} />;
68+ return <ChartGPU options = { options } style = { { width: ' 100%' , height: 400 }} />;
6669}
6770```
6871
69- Object / ` [x,y] ` tuples are fine for tiny demos; prefer typed-array columns at scale .
72+ Prefer column-shaped x/y at scale; object / ` [x,y] ` tuples are fine for small demos. Requires a WebGPU-capable browser (see [ Browser support ] ( #browser-support ) ) .
7073
7174---
7275
73- ## Why chartgpu-react
76+ ## Features
7477
75- | | |
76- | --- | --- |
77- | ** React lifecycle ** | Async create/dispose, debounced ` ResizeObserver ` sizing |
78- | ** Dense real-time jobs ** | Multi-series streaming, multi-panel dashboards, finance, heatmaps (via core) |
79- | ** Shared-device multi-panel ** | ` useGPUContext ` / ` gpuContext ` prop (recommended for ≥3 charts); ` useConnectCharts ` / ` connectCharts ` |
80- | ** Ring FIFO streaming ** | ` ref.appendData(..., { maxPoints }) ` ; heatmap/surface stream APIs on core |
81- | ** Events and refs ** | ` onClick ` , ` onCrosshairMove ` , ` onZoomChange ` , ` onDataAppend ` , ` onDeviceLost ` , …; ` ChartGPUHandle ` imperative API |
82- | ** MIT commercial embed ** | MIT wrapper; core density stays free under MIT with no feature gates on FIFO, zoom, multi-chart, or finance series |
83- | ** WebGPU-only ** | Same browser gate as core; no WebGL fallback |
78+ - ** React lifecycle ** — async create/dispose, StrictMode-safe, debounced ` ResizeObserver ` sizing
79+ - ** Streaming ** — ` ref.appendData(..., { maxPoints }) ` FIFO ring; heatmap/surface stream APIs on core ( ` updateHeatmap ` , ` updateSurface3D ` )
80+ - ** Multi-chart ** — ` useGPUContext ` + ` gpuContext ` prop (≥3 charts recommended); zoom sync via ` useConnectCharts ` / ` connectCharts `
81+ - ** Events and refs ** — ` onClick ` , ` onCrosshairMove ` , ` onZoomChange ` , ` onDataAppend ` , ` onDeviceLost ` , …; full ` ChartGPUHandle ` imperative API
82+ - ** External render mode ** — app-owned rAF with ` renderMode: 'external' ` , ` needsRender() ` , ` renderFrame() `
83+ - ** Series via core ** — line, area, bar, scatter, pie, candlestick, ohlc, heatmap, band, errorBar, impulse, step, stacked mountain, 3D ( ` pointCloud3d ` , ` surface3d ` )
84+ - ** MIT commercial embed ** — wrapper and core density (FIFO, zoom, multi-chart, finance series) stay open under MIT
85+
86+ Core architecture: [ ChartGPU ARCHITECTURE ] ( https://github.com/ChartGPU/ChartGPU/blob/main/docs/ARCHITECTURE.md ) . Performance: [ chartgpu.io/docs/performance ] ( https://chartgpu.io/docs/performance/ ) .
8487
8588---
8689
@@ -110,9 +113,12 @@ function StreamingChart() {
110113 const id = window .setInterval (() => {
111114 const x0 = t .current ;
112115 const x = new Float64Array ([x0 , x0 + 1 , x0 + 2 ]);
113- const y = new Float64Array ([Math .sin (x0 * 0.05 ), Math .sin ((x0 + 1 ) * 0.05 ), Math .sin ((x0 + 2 ) * 0.05 )]);
116+ const y = new Float64Array ([
117+ Math .sin (x0 * 0.05 ),
118+ Math .sin ((x0 + 1 ) * 0.05 ),
119+ Math .sin ((x0 + 2 ) * 0.05 ),
120+ ]);
114121 t .current += 3 ;
115- // Density path: column payload + fixed-capacity ring
116122 ref .current ?.appendData (0 , { x , y }, { maxPoints: 50_000 });
117123 }, 16 );
118124 return () => window .clearInterval (id );
@@ -123,15 +129,10 @@ function StreamingChart() {
123129 ref = { ref }
124130 options = { {
125131 autoScroll: true ,
126- series: [
127- {
128- type: ' line' ,
129- data: { x: new Float64Array (0 ), y: new Float64Array (0 ) },
130- lineStyle: { width: 2 , color: ' #4facfe' },
131- },
132- ],
133- xAxis: { type: ' value' },
134- yAxis: { type: ' value' },
132+ series: [{
133+ type: ' line' ,
134+ data: { x: new Float64Array (0 ), y: new Float64Array (0 ) },
135+ }],
135136 }}
136137 style = { { width: ' 100%' , height: 320 }}
137138 />
@@ -141,7 +142,9 @@ function StreamingChart() {
141142
142143---
143144
144- ## Multi-chart dashboards (shared GPU device)
145+ ## Multi-chart (shared device)
146+
147+ For three or more charts on one page, create a single adapter/device/pipeline cache and pass it into each chart. Charts do not destroy a shared device on dispose.
145148
146149``` tsx
147150import { ChartGPU , useGPUContext } from ' chartgpu-react' ;
@@ -166,11 +169,11 @@ function Dashboard() {
166169}
167170```
168171
169- Recommended for ≥3 charts. Full recipes : [ streaming dashboards] ( https://chartgpu.io/docs/streaming-dashboards/ ) · [ chart-sync recipe ] ( ./docs/recipes/chart-sync.md ) · [ core multi-chart cookbook] ( https://github.com/ChartGPU/ChartGPU/blob/main/docs/guides/multichart-dashboard-cookbook.md )
172+ Recipes : [ streaming dashboards] ( https://chartgpu.io/docs/streaming-dashboards/ ) · [ chart-sync] ( ./docs/recipes/chart-sync.md ) · [ core multi-chart cookbook] ( https://github.com/ChartGPU/ChartGPU/blob/main/docs/guides/multichart-dashboard-cookbook.md )
170173
171174---
172175
173- ## More feature snippets
176+ ## More snippets
174177
175178### Crosshair / interaction X
176179
@@ -284,29 +287,49 @@ function CandlestickStreaming() {
284287
285288---
286289
290+ ## Browser support
291+
292+ WebGPU only. No WebGL path.
293+
294+ | Browser | Support |
295+ | ---------| ---------|
296+ | Chrome / Edge | 113+ |
297+ | Safari | 18+ |
298+ | Firefox | Windows 114+; macOS 145+; Linux incomplete — see [ gpuweb status] ( https://github.com/gpuweb/gpuweb/wiki/Implementation-Status ) |
299+
300+ Detect ` navigator.gpu ` before creating charts. Do not leave an unsupported user on a blank canvas without UI.
301+
302+ ``` ts
303+ if (! navigator .gpu ) {
304+ // fail closed: show UI, do not leave an empty chart
305+ }
306+ ```
307+
308+ If you need Canvas/SVG or dual WebGL+WebGPU backends, use a library that ships those fallbacks.
309+
310+ ---
311+
287312## Documentation
288313
289314### chartgpu.io (core product)
290315
291- | | |
292- | ---| ---|
316+ | Resource | Description |
317+ | ---------- | ---------- ---|
293318| [ Docs hub] ( https://chartgpu.io/docs/ ) | Guides and series docs |
294319| [ Getting started] ( https://chartgpu.io/docs/getting-started/ ) | Install and first chart |
320+ | [ API reference] ( https://chartgpu.io/docs/api/ ) | ` create ` , options, streaming, interaction, 3D |
295321| [ Streaming dashboards] ( https://chartgpu.io/docs/streaming-dashboards/ ) | Shared device, multi-chart |
296322| [ Performance] ( https://chartgpu.io/docs/performance/ ) | Density, sampling, GPU sharing |
323+ | [ Theming] ( https://chartgpu.io/docs/theming/ ) | Dark / light / custom |
297324
298325### This repository (React)
299326
300- | | |
301- | ---| ---|
327+ | Resource | Description |
328+ | ---------- | ---------- ---|
302329| [ Getting started] ( ./docs/GETTING_STARTED.md ) | React install and first component |
303330| [ API] ( ./docs/API.md ) | Component, hooks, handle |
304331| [ Recipes] ( ./docs/recipes/ ) | Crosshair, sync, streaming, annotations, dataZoom |
305332
306- ---
307-
308- ## Examples
309-
310333``` bash
311334npm install
312335npm run dev
@@ -317,32 +340,13 @@ See [`examples/main.tsx`](./examples/main.tsx).
317340
318341---
319342
320- ## Browser support (WebGPU required)
321-
322- No WebGL fallback. Gate unsupported browsers in your app (capability detect; never a blank canvas).
323-
324- | Browser | Notes |
325- | ---------| --------|
326- | Chrome / Edge | 113+ |
327- | Safari | 18+ |
328- | Firefox | Windows 114+, macOS 145+, Linux still incomplete on [ gpuweb status] ( https://github.com/gpuweb/gpuweb/wiki/Implementation-Status ) |
329-
330- ``` ts
331- if (! navigator .gpu ) {
332- // fail closed: show UI, do not leave an empty chart
333- }
334- ```
335-
336- WebGPU-only is intentional. Need Canvas/SVG or dual WebGL+WebGPU? Use a stack that ships a fallback.
337-
338- ---
339-
340343## Development
341344
342345``` bash
343346npm install
344347npm run typecheck
345348npm run build
349+ npm run test
346350npm run dev
347351```
348352
@@ -401,7 +405,7 @@ Issues and pull requests welcome. For larger changes, open an issue first.
401405
402406## License
403407
404- [ MIT] ( LICENSE ) . Free for commercial embedding . ChartGPU core keeps density, FIFO, multi-chart, and finance series in the open core.
408+ [ MIT] ( LICENSE ) . Free for commercial use . ChartGPU core keeps density, FIFO, multi-chart, and finance series in the open core.
405409
406410## Related
407411
0 commit comments