ChartRef
Defined in: react/index.tsx:76
Imperative handle exposed by every SwiftChart React component via
forwardRef. Use it to reach the underlying chart instance, force a
resize, or export a PNG snapshot — without leaking renderer details
into your component tree.
Example
Section titled “Example”import { useRef } from 'react';import { Line, type ChartRef } from '@arshad-shah/swift-chart/react';
const ref = useRef<ChartRef>(null);<Line ref={ref} data={...} mapping={{ x: 'month', y: 'revenue' }} /><button onClick={() => download(ref.current?.toDataURL())}>Save PNG</button>BaseChart for the full surface available via chart.
Properties
Section titled “Properties”chart:
BaseChart|null
Defined in: react/index.tsx:83
The underlying SwiftChart instance, or null while the host element
is unmounted (between render and the first effect, or after destroy).
Use it for imperative operations not exposed as props (e.g.
chart.update({ animDuration: 0 })).
resize
Section titled “resize”resize: () =>
void
Defined in: react/index.tsx:88
Force a resize + re-layout. Useful after a parent’s CSS changes shape
outside a ResizeObserver-tracked dimension.
Returns
Section titled “Returns”void
toDataURL
Section titled “toDataURL”toDataURL: (
type?,quality?,options?) =>string|null
Defined in: react/index.tsx:96
Export the current canvas as a data URL. Defaults to PNG; pass
'image/jpeg' or 'image/webp' (with quality 0–1) for those
formats. Pass { scale: 'css' } to export at on-screen CSS-pixel
resolution instead of the DPR-multiplied backing store (useful for
“Save as PNG” buttons). Returns null if the chart isn’t mounted.
Parameters
Section titled “Parameters”string
quality?
Section titled “quality?”number
options?
Section titled “options?”scale?
Section titled “scale?”"native" | "css"
Returns
Section titled “Returns”string | null