Skip to content
Advertisement

Reactive chart with vue-chartjs throws “Maximum call stack size exceeded”

I tried to build a reactive chart with vue-chartjs (Vue v3, Vue ChartJS v4, ChartJS v3). But instead of updating the data in the diagram it just throws the following stack trace every time the interval functions for data computation gets executed:

JavaScript

I have no clue where to look for the error. I understand that it hints maybe a recursion but I have no idea where this recursion could happen.

If I use static dummy data instead of computing an array with data it displays that data just fine in the diagram.

It’s basically the same problem as in this question here: Why using ref() in Vue3 causes “RangeError: Maximum call stack size exceeded”?

I attached below the code of the two components that lead to this error message.

LineChart.vue

JavaScript

DistanceWidget.vue

JavaScript

Advertisement

Answer

I found a working example in the documentation: https://codesandbox.io/s/github/apertureless/vue-chartjs/tree/main/sandboxes/reactive-prop

It’s rather complex and not very intuitive. I would have never figured it out myself. But if you build up on it, you get it working. The spread operators (...) are key to get out of the Maximum call stack size exceeded hell.

Good luck!

User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement