nagix/chartjs-plugin-streaming

maximum call stack size exceeded error

roma177 opened this issue · 3 comments

Hello.
I have a chart which works fine, but after I added plugin it gives me maximum call stack size exceeded error. The sole goal of the plugin is to pause the realtime chart moving and to update the chart accordingly. It works, except after chart moving is paused I begin to get numerous maximum call stack size exceeded errors.
Part of the chart code with that plugin is below:
this.myChart = new Chart(ctx, { type: "line", plugins: [{ afterDatasetsDraw: () => { if (this.myChart.getDatasetMeta(0).data[0].x <= 55.5) { this.myChart.options.scales.x.realtime.pause = true; this.myChart.update("none"); } }}],

How to solve that maximum call stack size error saving pause functionality?
I also tried this but it does not stop chart moving immediately
plugins: [{ afterDatasetsDraw: () => { if (this.myChart.options.scales.x.realtime.pause !== true && this.myChart.getDatasetMeta(0).data[0].x <= 55.5) { this.myChart.options.scales.x.realtime.pause = true; this.myChart.update("none"); } }}],

Hello, same problem here, calling chart.update("none") or chart.update("quiet") (as specified in the doc), will eventually create a "maximum call stack size exceeded error". I managed to partially fix the problem by setting pause to true and removing chat.update(...), but as @roma177 said, it doesn't stop the chart immediately.

I tried to use the exact same versions of chart.js, the streaming plugin and the time libraries that are used in the documentation (which never crash btw, even when using the pause / unpause button) and it still crashes. So maybe the problem comes from somewhere else?
@roma177 Do you use any framework in your app? Like VueJS, React, Svelte, or something similar? I do.

After further investigation, I found out that this bug only happens when using both chartjs-plugin-streaming and chartjs-plugin-annotation at the same time. As a temporary workaround, I removed the annotation plugin and added a "static" dataset that looks exactly like the line annotation I was using (except, it was a dashed line, so now the line is scrolling too, but that's ok I guess).