As a newcomer to ApexCharts.js, I am currently working on setting up a Vue3 app using Composition API along with the setup syntax. My goal is to reference the template ref of 'apexchart' so that I can later call the dataURI() function on it. I am attempting to do this within the onMounted hook but encountering an exception that reads: "Uncaught (in promise) TypeError: Cannot read properties of null (reading 'dataURI')"
Here's what I have tried so far, excluding the chart options and series:
<script setup lang="ts">
...
import ApexCharts from 'apexcharts'
const chart = ref({} as ApexCharts);
onMounted(async () => {
await chart.value.dataURI().then(({ imgURI, blob }) => {
console.log("...")
});
});
</script>
<template>
<div>
<div id="chart">
<apexchart ref="chart" :options="options" :series="series" type="polarArea" :size="200" />
</div>
</div>
</template>