Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d2be6c9

Browse files
committed
Remove the fallback to indexOf search in getCategoryIndex, update the mock object in unit test instead
1 parent c32163e commit d2be6c9

File tree

2 files changed

+2
-3
lines changed

2 files changed

+2
-3
lines changed

src/plots/cartesian/set_convert.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,8 @@ module.exports = function setConvert(ax, fullLayout) {
152152
if(ax._categoriesMap) {
153153
index = ax._categoriesMap[v];
154154
if(index !== undefined) return index;
155-
} else {
156-
index = ax._categories.indexOf(v);
157-
if(index !== -1) return index;
158155
}
156+
159157
if(typeof v === 'number') { return v; }
160158
}
161159

test/jasmine/tests/axes_test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1685,6 +1685,7 @@ describe('Test axes', function() {
16851685
var ax = {
16861686
type: 'category',
16871687
_categories: ['a', 'b', 'c', 'd'],
1688+
_categoriesMap: {'a': 0, 'b': 1, 'c': 2, 'd': 3},
16881689
tickmode: 'array',
16891690
tickvals: ['a', 1, 1.5, 'c', 2.7, 3, 'e', 4, 5, -2],
16901691
ticktext: ['A!', 'B?', 'B->C'],

0 commit comments

Comments
 (0)