Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Annotations being left behind after clearing #4644

Closed
bglasgo opened this issue Aug 16, 2024 Discussed in #4642 · 0 comments
Closed

Annotations being left behind after clearing #4644

bglasgo opened this issue Aug 16, 2024 Discussed in #4642 · 0 comments
Labels
bug Something isn't working

Comments

@bglasgo
Copy link

bglasgo commented Aug 16, 2024

Discussed in #4642

I have proof that this doesn't work here. Please look at the console.log output and see that annotations get left in the array after doing a clear. They will appear to be gone until calling updateseries(), then the leftovers will re-appear.
https://codepen.io/bgcode/pen/qBzpPvr

Originally posted by bglasgo August 15, 2024

Description

I was building a chart of time series data with 4 point annotations, marking the min and max of my two data series, and then using clearAnnotations() before updating my chart data and re-adding 4 new annotations... but then I started ending up with old annotations getting left behind and having extra each update.
anno

After looking into the issue I would blame the clearAnnotations() function. The array is being mutated while map tries to iterate over it. If the goal is to remove these items from the, array, it is leaving some behind.
// annotations added externally should be cleared out too w.globals.memory.methodsToExec.map(function (m, i) { if (m.label === 'addText' || m.label === 'addAnnotation') { w.globals.memory.methodsToExec.splice(i, 1); } });

I have tested on my own by replacing it with a filter and it seems to have fixed the problem
// annotations added externally should be cleared out too w.globals.memory.methodsToExec = w.globals.memory.methodsToExec.filter(function (m) { return !(m.label === 'addText' || m.label === 'addAnnotation'); });

@junedchhipa junedchhipa added the bug Something isn't working label Aug 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants