Are you an AI agent?

useChartInstance

useChartInstance: () => ChartInstance

Returns the underlying ChartInstance for the surrounding <ChartContainer>. Use this to call imperative methods (e.g. addSeries, setSeriesData, fitContent) from inside child components. Must be called from a component rendered inside a <ChartContainer> — calling it outside throws.

Example

import { useChartInstance } from '@wick-charts/react';
 
function FitButton() {
const chart = useChartInstance();
 
return <button onClick={() => chart.fitContent()}>Fit</button>;
}