You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
returnR(()=>{if(!x.current)return;E.current=!0;lete=null;return(async()=>{try{if(!x.current)return;constp=k(),w=g.current;e=w ? awaitP.create(x.current,p,w) : awaitP.create(x.current,p);E.current ? (C.current=e,d(e),f==null||f(e)) : e.dispose();}catch(p){E.current&&console.error("Failed to create ChartGPU instance:",p);}})(),()=>{E.current=!1;C.current&&!C.current.disposed&&(C.current.dispose(),C.current=null);d(null);// Missing: removing the child canvas element(s)};},[]);
Fix
The cleanup must remove any DOM children that ChartGPU.create() appended:
()=>{E.current=!1;C.current&&!C.current.disposed&&(C.current.dispose(),C.current=null);d(null);// FIX: Remove the canvas element(s) appended by ChartGPU.create()if(x.current){while(x.current.firstChild){x.current.removeChild(x.current.firstChild);}}};
Conclusion
This is a bug in chartgpu-react v0.1.3, not in the dashboard adapter. The adapter (/<redacted>/src/charts/adapters/chartgpu-adapter.jsx) is using <ChartGPU> correctly.
I see 2 charts per chart, seems to be in the lib according to claude.
fully AI below here. I've not looked into it.
Root Cause: Two Canvas Elements per Chart (ChartGPU)
The duplicate
<canvas>issue comes from howchartgpu-reactand@chartgpu/chartgpuinteract under React StrictMode.How the DOM gets created
Layer 1:
chartgpu-reactrenders a<div>containerFile:
node_modules/chartgpu-react/dist/index.jsLines: ~206–213
Layer 2:
ChartGPU.create()appends a<canvas>into that<div>File:
node_modules/@chartgpu/chartgpu/dist/index.jsLines: ~9009–9010
Layer 3: the React component calls
ChartGPU.create(x.current, ...)File:
node_modules/chartgpu-react/dist/index.jsLines: ~89–97
At this point, everything is fine: one
<div>containing one<canvas>.The actual bug: React StrictMode double-mount
In development with React StrictMode, effects run:
The
useEffectcleanup disposes the chart instance, but does not remove the canvas DOM node:File:
node_modules/chartgpu-react/dist/index.jsLines: ~101–103
And
ChartGPUInstance.dispose()does not remove the<canvas>it appended—it only releases GPU/RAF resources.StrictMode sequence
create(div)appends canvas Add a modern React wrapper around ChartGPU with full lifecycle management, typed events, and improved example performance #1dispose()runs, but canvas Add a modern React wrapper around ChartGPU with full lifecycle management, typed events, and improved example performance #1 stays in the DOMcreate(div)appends canvas Refactor LineChartExample for simpler line series configuration #2Result: two
<canvas>elements inside the same container<div>.Exact code causing the bug (as shipped)
File:
node_modules/chartgpu-react/dist/index.js(lines ~89–103)Fix
The cleanup must remove any DOM children that
ChartGPU.create()appended:Conclusion
This is a bug in
chartgpu-reactv0.1.3, not in the dashboard adapter. The adapter (/<redacted>/src/charts/adapters/chartgpu-adapter.jsx) is using<ChartGPU>correctly.