You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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'); });
The text was updated successfully, but these errors were encountered:
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.
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'); });
The text was updated successfully, but these errors were encountered: