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

Bogus TypeError when updating box plot series with a different number of data points

Open MetRonnie opened this issue 2 years ago • 1 comments

<VueApexCharts :series="series" type="boxPlot" />

When series changes I get a TypeError if the length of series[0].data has changed

apexcharts.common.js:14 Uncaught (in promise) TypeError: Cannot read properties of null (reading 'resetSeries')
    at Proxy.value (apexcharts.common.js:14:41711)
    at Object.deep (vue3-apexcharts.common.js:465:23)
    at callWithErrorHandling (runtime-core.esm-bundler.js:173:22)
    at callWithAsyncErrorHandling (runtime-core.esm-bundler.js:182:21)
    at job (runtime-core.esm-bundler.js:1812:17)
    at flushPreFlushCbs (runtime-core.esm-bundler.js:336:13)
    at updateComponentPreRender (runtime-core.esm-bundler.js:5789:9)
    at ReactiveEffect.componentUpdateFn [as fn] (runtime-core.esm-bundler.js:5702:21)
    at ReactiveEffect.run (reactivity.esm-bundler.js:190:25)
    at instance.update (runtime-core.esm-bundler.js:5763:56)

(that was Chrome; in Firefox the error message is TypeError: this.series is null)

apexcharts.common.js:

    }, {
        key: "updateSeries",
        value: function() {
            var t = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : []
              , e = !(arguments.length > 1 && void 0 !== arguments[1]) || arguments[1]
              , i = !(arguments.length > 2 && void 0 !== arguments[2]) || arguments[2];
            return this.series.resetSeries(!1), // <----------------

However if I catch the error like this:

<script>
export default {
  errorCaptured (err, instance, info) {
    if (err.message.includes('resetSeries')) {
      return false
    }
  },
  ...

Everything works just fine.

For some reason I can't reproduce this in Vue SFC Playground

Version

apexcharts: 3.41.0
vue3-apexcharts: 1.4.1

MetRonnie avatar Jun 27 '23 09:06 MetRonnie

Hitting a similar problem when both series and type change one after the other I think the chart engine choke itself if it's still dealing with the previous change and a new update comes in

IlCallo avatar Aug 05 '23 14:08 IlCallo

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.

github-actions[bot] avatar Aug 02 '24 14:08 github-actions[bot]

Still present on

apexcharts: 3.54.0
vue3-apexcharts: 1.7.0

but it's worse now as using errorCaptured doesn't prevent the chart from breaking

MetRonnie avatar Oct 09 '24 11:10 MetRonnie

I've done some debugging and found that https://github.com/apexcharts/vue3-apexcharts/pull/50 (v1.4.4) introduced this bug.

Edit: further debugging, found out it only affects the chart if the height is set to scale with the number of entries in the series.

Playground repro

  1. First time you remove an entry from the series, the whole chart disappears.
  2. Second time, you get the TypeError

MetRonnie avatar Oct 09 '24 11:10 MetRonnie

@junedchhipa Think this fixes it: https://github.com/apexcharts/vue3-apexcharts/pull/123

MetRonnie avatar Oct 09 '24 12:10 MetRonnie