chartjs / Chart.js

Simple HTML5 Charts using the <canvas> tag
https://www.chartjs.org/
MIT License
64.5k stars 11.89k forks source link

Fix undefined controller error in tooltip plugin #11651

Open DrowningElysium opened 8 months ago

DrowningElysium commented 8 months ago

Issue that has been made clear in https://github.com/chartjs/Chart.js/pull/11596#issuecomment-1899486148

Issue also applies to a project of mine where the data is loaded twice, (Once from local storage and once from a result from a request), which might cause the issue.

LeeLenaleee commented 8 months ago

@etimberg we dissalowed optional chaining because it was not stable yet and not all platforms supported it. It seems it is stable now and every major browser supports it, except for IE 11 but we do not support that ourselfs.

I think we can use it now, what is your oppnion on it? https://caniuse.com/?search=optional%20chaining

etimberg commented 8 months ago

@LeeLenaleee I'm ok to use it now that it's stable

aStarlikeMine commented 6 months ago

I have this exact issue currently and will wait for this fix to be merged.

Our scenario happens when swopping between the graph on the dashboard and the page load from the graph click event multiple times, and only when this is done quickly.

daviddeutsch commented 5 months ago

Just confirming that I also have this issue in my current codebase - in my case, it seems to be related to multiple graphs being loaded at the same time under a stress test. It's four graphs in total with four sets of data (~600 points) being drawn each.

I've already staggered the loading because it wouldn't go smoothly otherwise (I first init the graphjs instance and then load in the data a short timeout later) and the missing controller happens seemingly at random - skipping over the error, all tooltips work just fine a moment later, navigating away and back to the page, I cannot reproduce the error consistently.

Another weird thing is that when I add a breakpoint to where the error occurs, I can print out the content of controller just fine (it's not null), but then the error happens anyhow (it reports that controller IS null).

I first thought that the fix in this PR resolved the issue, but the error ended up cropping up again, so now I'm completely unsure what causes it.