Closed tamojay-dey closed 2 years ago
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions
You can pass innerRef to props, which gives you a ref to the div surrounding the chart.js canvas. You can also access the ref through some handler functions. For example, I use animation onComplete() to get my ref and base64 image:
options.animation = {
onComplete: (chartElement) => {
const base64Img = chartElement.chartInstance.toBase64Image();
}
}
I have tried to capture the reference of a react chart but it returns undefined.
<CCardBody> <CChart ref={chartRef} id="react-chart" type="line" datasets={finaldata} options={options} labels={Xaxis} /> </CCardBody>
and defining chartRef as:
const chartRef = useRef()
I thought it could be because of the fact that it lacks react-chartjs-2 dependency as told here. but it is still returning undefined. I am using Core UI 3.2. Any suggestion how to get the reference? I need the chart reference to save it to a base64image.