mirror of
https://github.com/chartjs/Chart.js.git
synced 2025-12-08 20:36:08 +00:00
Optimize category parse for usual use case (#6959)
This commit is contained in:
parent
a1c2dd6fb6
commit
dc638d36e3
@ -8,6 +8,9 @@ const defaultConfig = {
|
||||
class CategoryScale extends Scale {
|
||||
_parse(raw, index) {
|
||||
const labels = this._getLabels();
|
||||
if (labels[index] === raw) {
|
||||
return index;
|
||||
}
|
||||
const first = labels.indexOf(raw);
|
||||
const last = labels.lastIndexOf(raw);
|
||||
return first === -1 || first !== last ? index : first;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user