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
2 changes: 1 addition & 1 deletion src/plots/cartesian/ordered_categories.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ function flattenUniqueSort(axisLetter, sortFunction, data) {
insertionIndex = bisector(categoryArray, category);

// skip loop on already encountered values
if(insertionIndex < categoryArray.length - 1 && categoryArray[insertionIndex] === category) continue;
if(insertionIndex < categoryArray.length && categoryArray[insertionIndex] === category) continue;

// insert value
categoryArray.splice(insertionIndex, 0, category);
Expand Down
12 changes: 12 additions & 0 deletions test/jasmine/tests/calcdata_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,18 @@ describe('calculated data and points', function() {
expect(gd.calcdata[0][3]).toEqual(jasmine.objectContaining({x: 0, y: 13}));
expect(gd.calcdata[0][4]).toEqual(jasmine.objectContaining({x: 2, y: 14}));
});

it('should combine duplicate categories', function() {
Plotly.plot(gd, [{x: [ '1', '1'], y: [10, 20]}], { xaxis: {
type: 'category',
categoryorder: 'category ascending'
}});

expect(gd.calcdata[0][0]).toEqual(jasmine.objectContaining({x: 0, y: 10}));
expect(gd.calcdata[0][1]).toEqual(jasmine.objectContaining({x: 0, y: 20}));

expect(gd._fullLayout.xaxis._categories).toEqual(['1']);
});
});

describe('explicit category ordering', function() {
Expand Down