-
Notifications
You must be signed in to change notification settings - Fork 35
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Charts are being duplicated #3
Comments
Sorry for the late response. |
I have fixed this issue by using |
Same issue here using the latest versions of Vue, VueApexCharts and ApexCharts |
Having the same issue. I have to integrate with Vue3 so I can't use ApexCharts native. Any resolution to it? |
@mijreed you can use it like
|
That worked. Thank you! |
I can confirm, it is a problem with Vue3 using Vite as well. Same issue where if a resize happens the duplicate disappears. |
Having this issue too. Opening the development tools or resizing the window causes the duplicate to disappear. |
+1 also having this issue with Vue 3 and Vite |
Will fix the issue for now |
Having the same issue. |
The same here! Hack with event works but doesn't look like a right solution |
same issue :/ |
Facing the exactly same issue |
Me too! mounted() was too eary for me scenario. I moved the snipped from above to updated(). |
Still not fixed |
You just need to change mounted() to created(), resolving the issue for me |
And if you're using the Composition API (ie |
its worked well. awesome |
This happens because you mount the component and use reactivity too quickly before the apex component can be initialized. In this case, the This is my work around as long as #50 is not accepted, which adds an additional check within the |
May I ask why this is closed? I had to implement the nextTick workaround I found via https://stackoverflow.com/a/70826352/2817604 - looks like it was picked from #3 (comment) |
Which version are you using? |
NuxtJS V3 project using a plugin: import VueApexCharts from 'vue3-apexcharts'
export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.vueApp.use(VueApexCharts)
}) |
just saw your PR and the fix - nice work @razorness - can we get a patch release? i'll update that SO question |
thank you. It works for me |
Until the patch is released, could you share how you implemented this in Nuxt3 @acidjazz ? |
Nuxt V3:
import VueApexCharts from 'vue3-apexcharts'
export default defineNuxtPlugin((nuxtApp) => {
nuxtApp.vueApp.use(VueApexCharts)
})
<script lang="ts" setup>
import { ApexOptions } from 'apexcharts'
const options:ApexOptions = {
colors: ['#6667ab', 'green'],
tooltip: { theme: 'none' },
chart: {
type: 'line',
toolbar: { show: false },
foreColor: '#6b7280',
},
grid: { show: false },
markers: {
size: 6,
colors: ['#6667ab'],
},
xaxis: {
title: { text: 'Year' },
tooltip: { enabled: false },
categories: [2018, 2019, 2020, 2021, 2022],
axisBorder: { show: false },
axisTicks: { show: false },
},
yaxis: {
title: { text: 'Days' },
},
stroke: {
show: true,
curve: 'smooth',
},
fill: {
type: 'gradient',
gradient: {
type: 'horizontal',
colorStops: [
{
offset: 1,
color: '#9c9ae3',
opacity: 1,
},
{
offset: 100,
color: '#00c893',
opacity: 1,
},
],
},
},
dataLabels: {
style: {
colors: ['#6667ab'],
},
},
}
const series = [
{
name: 'Days',
data: [352, 203, 126, 51, 8],
},
]
onMounted(() => {
nextTick(() => {
window.dispatchEvent(new Event('resize'))
})
})
</script>
<template>
<div>
<apexchart
class="hidden lg:block w-470px" :options="options" :series="series"
width="470"
/>
<apexchart
class="lg:hidden" :options="options" :series="series"
width="370"
/>
</div>
</template> |
Thanks, that works like a charm.
But I couldn't find why this didn't work (I tried several other steps of the lifecycle, like |
I added a ":key" to the graph and it solved.
|
Window.dispatchEvent(new Event('resize')) on both onMounted and updated caused a visible flick of the duplicate before it got removed. Solved it by reassigning the data.
|
Also faced this same, and updating the data on |
I love this solution better using |
When installing 1.4.1 its not showing me the recent commit Any idea? |
New version issued just 2 days ago. This issue should not happen anymore. Your hot fixes should be safe to remove. |
Env:
My options:
Template:
Result:
Note: when I change a screen resolution, the duplicated one disappears
The text was updated successfully, but these errors were encountered: