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

Error when component destroy in same time chart are build

Open ed-lot opened this issue 5 years ago • 25 comments

I have these javascript errors :

1 =>Error: <path> attribute d: Expected number, "M NaN NaN A 132.5 …". 1 =>Error: <path> attribute d: Expected number, "M NaN NaN A 112.5 …". 1 =>Error: <path> attribute d: Expected number, "M NaN NaN A 92.5 9…". ... 2 =>Error: <g> attribute transform: Expected number, "translate(NaN, 20)".(2)

1 =>        if (a == 'leading') {
            // ... call the leading method instead
            if (this.leading) {
               this.leading(v);
            }
         } else {
            // set given attribute on node
 bug here  ===> typeof n === 'string' ? this.node.setAttributeNS(n, a, v.toString()) : this.node.setAttribute(a, v.toString());
         } // rebuild if required

2 =>         key: "setAttrs",
            value: function setAttrs(el, attrs) {
            for (var key in attrs) {
               if (attrs.hasOwnProperty(key)) {
 bug here  ===>  el.setAttribute(key, attrs[key]);
               }
            }
         }

When the chart creating and i leave route (parent component are destroy). My code :

<apexchart v-if="!ui.block" type="radialBar" :options="radial.options" :series="radial.series" :key="1"/>

When axios get data and radial.options and radial.series are populate ui.block = false and chart begin construct. If i leave page at these time. Bug appear.

Can you help please ?

ed-lot avatar Jun 04 '19 08:06 ed-lot

Hi, Any update about this ?

iNeoO avatar Jul 02 '20 13:07 iNeoO

Hello, because of it i leaved this plugin, i don't know if patched

ed-lot avatar Jul 06 '20 06:07 ed-lot

I'm having the same issue.

To replicate is easy. Just create 2 components and use keep-alive, when you switch from one to another with keep alive:

Error: attribute transform: Expected number, "translate(NaN, 0)".

will appear.

It seems there is a problem on the destroy.

Daniel4Digital avatar Aug 12 '20 18:08 Daniel4Digital

Any updates on this? I'm having the same problem. I'm using nuxt keep-alive with two pages; on both pages I have apexchart donut. Everything works ok, but error is thrown every time I change the page.

cvakodobro avatar Nov 09 '20 09:11 cvakodobro

I dig it up more today and I saw that it happens only when I've opposite: true (doesnt make much sense but it is what it is) maybe it can help.

I've trimm down to having only this code:

yaxis= [ { seriesName: trans('_v4.models.app_tracking.general.stats.graph.qty_clicks'), }, { seriesName: trans('_v4.models.app_tracking.general.stats.graph.qty_clicks'), show: false, }, { seriesName: trans('_v4.models.app_tracking.general.stats.graph.qty_clicks'), show: false, }, { seriesName: trans('_v4.models.app_tracking.general.stats.graph.qty_clicks'), show: false, }, { seriesName: trans('_v4.models.app_tracking.general.stats.graph.conversion_rate'), opposite: true, } ];

Just when removing the opposite: true, the error stop appearing.

Daniel4Digital avatar Dec 09 '20 17:12 Daniel4Digital

Any updates on this? I'm having the same problem.

turkhero avatar Jan 18 '21 04:01 turkhero

Any updates? I started encountering this after apexcharts was bumped thanks to that security dep update

FM1337 avatar Feb 15 '21 20:02 FM1337

Still no updates? I also have this problem even not using Nuxt.

mytc avatar Apr 04 '21 02:04 mytc

Still no updates? I also have this problem even not using Nuxt.

I think this repo is dead, I suggest switching over to chart.js, there's a useful chartjs vue package that'll make your life easier than using this package.

FM1337 avatar Apr 04 '21 21:04 FM1337

@FM1337 Yes, I am consider chart.js too. Have you tried it? No having the same problem like this one? I have done the data structure for apexchart, if switching will need to construct the data again, which is a pain progress barbecue it is rather a very complicated data.

mytc avatar Apr 05 '21 06:04 mytc

@FM1337 Yes, I am consider chart.js too. Have you tried it? No having the same problem like this one? I have done the data structure for apexchart, if switching will need to construct the data again, which is a pain progress barbecue it is rather a very complicated data.

Yup I switched over to it (specifically vue-chartjs) and have had no issues like the ones I've encountered with vue-apexcharts. I only originally used apex because I couldn't remember the name of chart.js and apex was the first result when looking for javascript chart libraries.

FM1337 avatar Apr 05 '21 13:04 FM1337

Switching library for a simple warning on the console? It doesn't cause any real problem. I suffer the same problem but I know this is not a priority since it's a minor issue for the sake of our Dev minds lol

TarantinoMariachi avatar Apr 05 '21 13:04 TarantinoMariachi

Switching library for a simple warning on the console? It doesn't cause any real problem. I suffer the same problem but I know this is not a priority since it's a minor issue for the sake of our Dev minds lol

Nope. It does caused problem in my case. The chart (donut chart) collapsed when switching tabs.

mytc avatar Apr 05 '21 18:04 mytc

I have this same problem when trying to populate series data from an axios response. Will go back to chartjs until I can figure it out.

imakeinternet avatar Apr 07 '21 19:04 imakeinternet

hi guys, I have problem when using apexchart on different material tab, when i try to resize the browser on different tab (not the tab displaying the chart) , it will hit Error: attribute d: Expected number, "M NaN NaN A. Is there any workaround on this issues? Appreciate any possible solutions. Thanks

chicky095 avatar Jul 08 '21 01:07 chicky095

Not really fixing the original issue but at least getting rid of the errors. In my use case I only have charts on a few pages on my site and decided to turn off the keep-alive feature with a vuex state property whenever i use apexcharts.

<Nuxt :keep-alive="!hasChart" />

ehnsio avatar Jan 28 '22 22:01 ehnsio

I have the same issue

AniaKru95 avatar Feb 15 '22 15:02 AniaKru95

Any updates on this? Seems like a lot of people are having the same issue.

stylianospanagakos avatar Mar 16 '22 11:03 stylianospanagakos

I found a workaround. In the template I've added condition v-if (surrounding my apexchart) and then I wrote two additional hooks: activated - sets component as active and deactevated - set component as inactive. Thanks to this, my chart is still keep-alive and I do not see annoying errors in console. Pseudocode:

<template>
    <div v-if="componentIsActive">
        <apexchart  :options="chartOpts" :series="chartSeries"></apexchart>
    </div>
</template>

data() {
       return {
        componentIsActive: false,
    }
},
activated() {
    this.componentIsActive = true
  },
deactivated() {
    this.componentIsActive = false
  },

AniaKru95 avatar Mar 16 '22 12:03 AniaKru95

@AniaKru95 it does look like a legit workaround but it will re-render the graph upon activation which is what you're trying to avoid by having it wrapped in keep-alive in the first place.

stylianospanagakos avatar Mar 16 '22 16:03 stylianospanagakos

Sure, but I keep my chart's data in memory so it is not a big problem to draw chart again. Spamming errors/warnings in the console was worse. I hope that this issue will be fixed in proper way.

AniaKru95 avatar Mar 17 '22 08:03 AniaKru95

@AniaKru95 Thank you for the workaround, works like a charm as long as you hold your data in parent component or store! I added this.componentIsActive = true; to my mounted() hook aswell since activated() is not running on initial render.

ehnsio avatar Mar 28 '22 08:03 ehnsio

@AniaKru95 , Thank you for the workaround, works great

chandra-sekar-1007531 avatar Apr 20 '22 17:04 chandra-sekar-1007531

I'm having the same issue. when i switch from one to another tab will appear. this error

apexcharts.common.js:1283 Error: attribute transform: Expected number, "translate(NaN, 0)".

shubham-agni-hcah avatar Sep 26 '23 11:09 shubham-agni-hcah

Having same issues on small screens, hope this will get fixed soon

Friis1978 avatar Oct 07 '23 11:10 Friis1978