Wick Charts

useChartInstance

useChartInstance: () => ChartInstance

Returns the underlying ChartInstance for the surrounding <ChartContainer>. Use this to call imperative methods (e.g. addSeries, setSeriesData, resetZoom) 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 ResetButton() {
const chart = useChartInstance();
 
return <button onClick={() => chart.resetZoom()}>Reset</button>;
}