mirror of
https://github.com/chartjs/Chart.js.git
synced 2026-03-20 23:26:53 +01:00
Optimize category parse for usual use case (#6959)
This commit is contained in:
committed by
Evert Timberg
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;
|
||||
|
||||
Reference in New Issue
Block a user