Open Rednas83 opened 9 months ago
Change the plugin file name to *.client.ts
Just tried with a javascript plugin because for typescript we will need to wait for official support or for an external declaration file🤞
plugins/apex.client.js
import VueApexCharts from "vue3-apexcharts";
export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.vueApp.use(VueApexCharts)
})
components/vchart.vue
<template>
<ClientOnly>
<apexchart width="500" type="bar" :options="options" :series="series"></apexchart>
</ClientOnly>
</template>
<script setup lang="ts">
const options = ref({
chart: {
id: "vuechart-example",
},
xaxis: {
categories: [1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998],
},
})
const series = ref([
{
name: "series-1",
data: [30, 40, 45, 50, 49, 60, 70, 91],
},
])
</script>
Unfortunately this is also not working😢 Terminal Console
Any more ideas?
import VueApexCharts from 'vue3-apexcharts'
export default defineNuxtPlugin(nuxtApp => {
nuxtApp.vueApp.use(VueApexCharts) // missed
return {
provide: {
charts: VueApexCharts,
}
}
})
Got it working😀 The ungroup error was caused by a conflicting custom ungroup function. Also don't forget to wrap apexchart
with ClientOnly
to avoid a hydration mismatch
plugins/apex.client.js
import VueApexCharts from "vue3-apexcharts";
export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.vueApp.use(VueApexCharts)
})
components/vchart.vue
<template>
<h2>Charting with apex</h2>
<ClientOnly>
<apexchart width="500" type="bar" :options="options" :series="series"></apexchart>
</ClientOnly>
</template>
<script setup lang="ts">
const options = ref({
chart: {
id: "vuechart-example",
},
xaxis: {
categories: [1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998],
},
})
const series = ref([
{
name: "series-1",
data: [30, 40, 45, 50, 49, 60, 70, 91],
},
])
</script>
Perhaps this example can also be added to the docs for nuxt users?
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.
After exactly following the instruction I am getting
Tried wrapping
apexchart
component inClientOnly
component but that didn't fix the issueAnyone has a fix for nuxt3?