vue3-apexcharts: Charts are being duplicated
Env:
"apexcharts": "^3.22.2",
"vue": "^3.0.2",
"vue3-apexcharts": "^1.1.1"
My options:
{
chart: {
height: 590,
type: "area",
},
dataLabels: {
enabled: false,
},
stroke: {
curve: "smooth",
},
xaxis: {
labels: {
showDuplicates: false,
hideOverlappingLabels: true,
offsetY: 20,
style: {
colors: "#979797",
},
},
},
}
Template:
<apexchart type="area" :height="590" :options="options" :series="series" />
Result:

Note: when I change a screen resolution, the duplicated one disappears
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 6
- Comments: 34 (4 by maintainers)
Commits related to this issue
- area-chart: fix apexcharts/vue3-apexcharts#3 — committed to givemomentum/stewardship-frontend by victor-yunenko a year ago
- area-chart: fix apexcharts/vue3-apexcharts#3 v2 — committed to givemomentum/stewardship-frontend by victor-yunenko a year ago
And if you’re using the Composition API (ie
<script setup>syntax) useonBeforeMountinstead ofonMounted.Will fix the issue for now
You just need to change mounted() to created(), resolving the issue for me
Same issue here using the latest versions of Vue, VueApexCharts and ApexCharts I created a Codesandbox here: https://codesandbox.io/s/cool-jennings-qbbr5?file=/src/App.vue
its worked well. awesome
I added a “:key” to the graph and it solved.
<apexchart type="area" :options="options" :series="series" :key="chart-items-${series[0].data.length}"></apexchart>Nuxt V3:
plugins/apex.client.tscomponents/PublicChartLine.vuejust saw your PR and the fix - nice work @razorness - can we get a patch release? i’ll update that SO question
Me too!
mounted() was too eary for me scenario. I moved the snipped from above to updated().