Skip to content

Commit b005143

Browse files
authored
scale.category: options.min/max can be index (#8594)
1 parent 7ec99c3 commit b005143

File tree

5 files changed

+6
-13
lines changed

5 files changed

+6
-13
lines changed

src/scales/scale.category.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Scale from '../core/core.scale';
2+
import {valueOrDefault} from '../helpers';
23

34
function findOrAddLabel(labels, raw, index) {
45
const first = labels.indexOf(raw);
@@ -22,7 +23,7 @@ export default class CategoryScale extends Scale {
2223
parse(raw, index) {
2324
const labels = this.getLabels();
2425
return isFinite(index) && labels[index] === raw
25-
? index : findOrAddLabel(labels, raw, index);
26+
? index : findOrAddLabel(labels, raw, valueOrDefault(index, raw));
2627
}
2728

2829
determineDataLimits() {

test/fixtures/controller.bar/floatBar/float-bar-horizontal.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818
"indexAxis": "y",
1919
"scales": {
2020
"x": {
21-
"display": false,
22-
"min": -8,
23-
"max": 12
21+
"display": false
2422
},
2523
"y": {
2624
"display": false

test/fixtures/controller.bar/floatBar/float-bar-stacked-horizontal.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@
2323
},
2424
"y": {
2525
"display": false,
26-
"stacked": true,
27-
"min": -8,
28-
"max": 12
26+
"stacked": true
2927
}
3028
}
3129
}

test/fixtures/controller.bar/floatBar/float-bar-stacked.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818
"scales": {
1919
"x": {
2020
"display": false,
21-
"stacked": true,
22-
"min": -8,
23-
"max": 12
21+
"stacked": true
2422
},
2523
"y": {
2624
"display": false,

test/fixtures/controller.bar/floatBar/float-bar.json

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@
1717
"options": {
1818
"scales": {
1919
"x": {
20-
"display": false,
21-
"min": -8,
22-
"max": 12
20+
"display": false
2321
},
2422
"y": {
2523
"display": false

0 commit comments

Comments
 (0)