Skip to content

Commit f4214cb

Browse files
committed
plotly#189 adding a path for when categorymode is not in ['array', 'category ascending', 'category descending']
1 parent 5f33a7b commit f4214cb

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

src/plots/cartesian/ordered_categories.js

+11-6
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,15 @@ module.exports = function orderedCategories(axisLetter, categorymode, categoryli
2424

2525
// ... or take the union of all encountered tick keys and sort them as specified
2626
// (could be simplified with lodash-fp or ramda)
27-
[].concat.apply([], data.map(function(d) {return d[axisLetter];}))
28-
.filter(function(element, index, array) {return index === array.indexOf(element);})
29-
.sort(({
30-
'category ascending': d3.ascending,
31-
'category descending': d3.descending
32-
})[categorymode]);
27+
28+
['category ascending', 'category descending'].indexOf(categorymode) > -1 ?
29+
30+
[].concat.apply([], data.map(function(d) {return d[axisLetter];}))
31+
.filter(function(element, index, array) {return index === array.indexOf(element);})
32+
.sort(({
33+
'category ascending': d3.ascending,
34+
'category descending': d3.descending
35+
})[categorymode]) :
36+
37+
[].slice();
3338
};

test/jasmine/tests/calcdata_test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ describe('calculated data and points', function() {
172172
});
173173
});
174174

175-
fdescribe('explicit category ordering', function() {
175+
describe('explicit category ordering', function() {
176176

177177
it('should output categories in explicitly supplied order, independent of trace order', function() {
178178

@@ -252,7 +252,7 @@ describe('calculated data and points', function() {
252252
expect(gd.calcdata[0][4]).toEqual(jasmine.objectContaining({x: 3, y: 14}));
253253
});
254254

255-
fit('should output categories in explicitly supplied order first, if not all categories are covered', function() {
255+
it('should output categories in explicitly supplied order first, if not all categories are covered', function() {
256256

257257
Plotly.plot(gd, [{x: ['c','a','e','b','d'], y: [15,11,12,13,14]}], { xaxis: {
258258
type: 'category',

0 commit comments

Comments
 (0)