Documentation / @finchart/react / useChartPlot
Function: useChartPlot()
useChartPlot():
Plot
Defined in: react/src/components/chart-context.ts:115
The current container's chart. The channel for imperative configuration done from inside, not outside.
Reading plotRef from a parent's effect breaks under a key remount — under StrictMode's double mount, the parent effect grabs the first instance, the one about to be discarded, and any tool install or applyOptions call goes nowhere. Inside the container is different: children only render once the api is in place, and if they remount they remount together with it, so they always see the current chart.
function Setup() {
const plot = useChartPlot();
useEffect(() => {
const tools = plot.mainPane.use(drawingTools({ plot }));
return () => tools.dispose();
}, [plot]);
return null;
}plotRef is still the right tool for event handlers (something like a button's fitDomains()) — by the time the user clicks, the chart has already settled.
Returns
Plot