Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ lib.parseDate = datesModule.parseDate;
var searchModule = require('./search');
lib.findBin = searchModule.findBin;
lib.sorterAsc = searchModule.sorterAsc;
lib.sorterDes = searchModule.sorterDes;
lib.distinctVals = searchModule.distinctVals;
lib.roundUp = searchModule.roundUp;

Expand Down
1 change: 1 addition & 0 deletions src/lib/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ function greaterThan(a, b) { return a > b; }
function greaterOrEqual(a, b) { return a >= b; }

exports.sorterAsc = function(a, b) { return a - b; };
exports.sorterDes = function(a, b) { return b - a; };

/**
* find distinct values in an array, lumping together ones that appear to
Expand Down
2 changes: 1 addition & 1 deletion src/plot_api/plot_api.js
Original file line number Diff line number Diff line change
Expand Up @@ -1423,7 +1423,7 @@ Plotly.deleteTraces = function deleteTraces(gd, indices) {
indices = positivifyIndices(indices, gd.data.length - 1);

// we want descending here so that splicing later doesn't affect indexing
indices.sort().reverse();
indices.sort(Lib.sorterDes);
for (i = 0; i < indices.length; i += 1) {
deletedTrace = gd.data.splice(indices[i], 1)[0];
traces.push(deletedTrace);
Expand Down
26 changes: 26 additions & 0 deletions test/jasmine/tests/plot_api_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,32 @@ describe('Test plot api', function() {

});

it('should work with more than 10 indices', function() {
gd.data = [];

for(var i = 0; i < 20; i++) {
gd.data.push({
name: 'trace #' + i
});
}

var expectedData = [
{name: 'trace #12'},
{name: 'trace #13'},
{name: 'trace #14'},
{name: 'trace #15'},
{name: 'trace #16'},
{name: 'trace #17'},
{name: 'trace #18'},
{name: 'trace #19'}
];

Plotly.deleteTraces(gd, [0,1,2,3,4,5,6,7,8,9,10,11]);
expect(gd.data).toEqual(expectedData);
expect(PlotlyInternal.redraw).toHaveBeenCalled();

});

});

describe('Plotly.addTraces', function() {
Expand Down