react-apexcharts
react-apexcharts copied to clipboard
How to get the chart instance by id , when using hooks ?
I have a graph already rendered and visible . how can I get the chart instance when using hooks ? I have a button and on click I would like to console out the instance :
<Button
label="Export to PDF"
size="small"
secondary
onClick={() => {
console.log(options.chart.id);
const chart = ApexCharts.getChartByID(options.chart.id);
console.log(chart); // <-- getting undefined here
console.log(window.Apex._chartInstances); // <-- empty array here
}}
/>
...
<Chart
options={options}
series={options.series}
height="500px"
width="99%"
type="area"
/>
Thanks ,
having a related issue. I need to do a dynamic line chart that turns into an area graph when there is only 1 series.
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.