ChartGPUChart is a legacy wrapper component kept for backward compatibility.
New work should use ChartGPU.
This file documents:
- the
ChartGPUChartPropssurface - how it maps to
ChartGPU - migration guidance
Related:
ChartGPUcomponent- API overview
- LLM entrypoint:
llm-context.md
- Exported as
ChartGPUChart - Marked
@deprecatedinsrc/index.tsandsrc/ChartGPUChart.tsx - Will be removed in a future major version
ChartGPUChartProps (defined in src/ChartGPUChart.tsx):
| Prop | Type | Required | Notes |
|---|---|---|---|
options |
ChartGPUOptions |
✅ | Same configuration object you pass to ChartGPU. |
className |
string |
Passed through to ChartGPU. |
|
style |
React.CSSProperties |
Merged with a default { width: '100%', height: '400px', position: 'relative' }. |
|
onInit |
(instance: ChartGPUInstance) => void |
Called when ChartGPU fires onReady. |
|
onDispose |
() => void |
Called on unmount only if the chart initialized (onInit ran). |
Before:
import { ChartGPUChart } from 'chartgpu-react';
<ChartGPUChart options={options} />;After:
import { ChartGPU } from 'chartgpu-react';
<ChartGPU options={options} style={{ width: '100%', height: 400 }} />;Before:
<ChartGPUChart options={options} onInit={(chart) => console.log(chart)} />;After:
<ChartGPU options={options} onReady={(chart) => console.log(chart)} />;ChartGPU does not expose an onDispose callback. Use a ref or onReady to retain the instance and dispose any dependent resources in a cleanup:
import { useEffect, useState } from 'react';
import { ChartGPU } from 'chartgpu-react';
import type { ChartGPUInstance } from 'chartgpu-react';
export function Example() {
const [chart, setChart] = useState<ChartGPUInstance | null>(null);
useEffect(() => {
return () => {
// Cleanup any app-level resources tied to the chart here.
// (The ChartGPU component itself disposes the chart instance automatically.)
void chart;
};
}, [chart]);
return <ChartGPU options={options} onReady={setChart} style={{ height: 400 }} />;
}ChartGPU provides:
- a clearer imperative
refAPI (ChartGPUHandle) - additional event props (
onCrosshairMove,onZoomChange) - explicit
themeoverride support