react-apexcharts icon indicating copy to clipboard operation
react-apexcharts copied to clipboard

How to get the chart instance by id , when using hooks ?

Open zlobjul opened this issue 1 year ago • 1 comments

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 ,

zlobjul avatar Jul 26 '23 09:07 zlobjul

having a related issue. I need to do a dynamic line chart that turns into an area graph when there is only 1 series.

MatheusRoichman avatar Apr 17 '24 03:04 MatheusRoichman

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.

github-actions[bot] avatar Aug 03 '24 14:08 github-actions[bot]