Skip to content

bug with deletion of traces #201

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

Closed
HungryGeneral opened this issue Jan 20, 2016 · 2 comments
Closed

bug with deletion of traces #201

HungryGeneral opened this issue Jan 20, 2016 · 2 comments
Labels
bug something broken

Comments

@HungryGeneral
Copy link

The specific bug I am encountering is when deleteTraces is called on a plot of 11 or more traces, with an array of integers from [0.... n-1](in order to delete all the Traces on the plot) it leaves several items undeleted, (in my specific case, the traces in the 11-18 slots of the data array.)
I believe this abnormality of the deleteTraces function (not deleting every trace it was requested to delete) is caused by the sort function used in the deleteTraces method (on line 62493 of plotly.js) the sort function seems to use the default behavior of the .sort() function which sorts numbers into this order 0, 1, 10, 11, 12..., 2..., 3..., 4..., 5..., etc. Thus comparing the first number in each integer, then the second then the third. Leaving the numbers out of numerical order. This is a problem, because of the use of the .splice() function, which removes an indicated item in the traces array, and decrements every item placed numerically above it, so as not to leave a hole. This behavior of the .splice() function combined with the previously outlined default behavior of the .sort() function creates this issue where if you want to delete items 0-11, of an 11 item list (let's say) it will delete items 9-2, try to delete item 11 and 10 (failing because there are no items in those positions) and then delete items 0 and 1, leaving item 11 and 10 undeleted.
This issue would be fixed by changing line 62516 (of my version, maybe it’s a little off from changes now) from indicies.sort().reverse(); to indicies.sort(function(a,b){return a-b}).reverse();
I hope this is helpful, and I submitted this issue correctly! Thank you very much!

@etpinard etpinard added the bug something broken label Jan 20, 2016
@etpinard
Copy link
Contributor

Bug confirmed. Thank you very much for this very detailed bug report.

Here's a reproducible example: http://codepen.io/etpinard/pen/OMzpXp

@mdtusz
Copy link
Contributor

mdtusz commented Jan 20, 2016

Congrats @HungryGeneral on your first open source contribution on github as well! Off to a good start!

🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug something broken
Projects
None yet
Development

No branches or pull requests

3 participants