]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
scale.category: options.min/max can be index (#8594)
authorJukka Kurkela <jukka.kurkela@gmail.com>
Tue, 9 Mar 2021 13:08:36 +0000 (15:08 +0200)
committerGitHub <noreply@github.com>
Tue, 9 Mar 2021 13:08:36 +0000 (08:08 -0500)
src/scales/scale.category.js
test/fixtures/controller.bar/floatBar/float-bar-horizontal.json
test/fixtures/controller.bar/floatBar/float-bar-stacked-horizontal.json
test/fixtures/controller.bar/floatBar/float-bar-stacked.json
test/fixtures/controller.bar/floatBar/float-bar.json

index 868b24b5c810e1ff8fb02464c1b8e24d27689133..c6efd61b8f4adfe5d82f2383964dbbd55a6264ea 100644 (file)
@@ -1,4 +1,5 @@
 import Scale from '../core/core.scale';
+import {valueOrDefault} from '../helpers';
 
 function findOrAddLabel(labels, raw, index) {
   const first = labels.indexOf(raw);
@@ -22,7 +23,7 @@ export default class CategoryScale extends Scale {
   parse(raw, index) {
     const labels = this.getLabels();
     return isFinite(index) && labels[index] === raw
-      ? index : findOrAddLabel(labels, raw, index);
+      ? index : findOrAddLabel(labels, raw, valueOrDefault(index, raw));
   }
 
   determineDataLimits() {
index 8142c8db608b722cb09c46b111ebe432ea944347..8f5aafe70f0dc3b69479b74b306cb2218cbf64e2 100644 (file)
@@ -18,9 +18,7 @@
             "indexAxis": "y",
             "scales": {
                 "x": {
-                    "display": false,
-                    "min": -8,
-                    "max": 12
+                    "display": false
                 },
                 "y": {
                     "display": false
index acaf00c9bb6e60e824081a553c2223d6793a6eb0..8640be64a7c7d6db50781cae4ea240871353b9cc 100644 (file)
@@ -23,9 +23,7 @@
                 },
                 "y": {
                     "display": false,
-                    "stacked": true,
-                    "min": -8,
-                    "max": 12
+                    "stacked": true
                 }
             }
         }
index d2270e26f655dedcd482908bbd9717df658ac00e..eb0ccb1ec916f56641141cb7c628059fa2f92e98 100644 (file)
@@ -18,9 +18,7 @@
             "scales": {
                 "x": {
                     "display": false,
-                    "stacked": true,
-                    "min": -8,
-                    "max": 12
+                    "stacked": true
                 },
                 "y": {
                     "display": false,
index 45b7fd8503d6528ac3aa6be2b7cbf8267d9817a2..e97bfcecbf882f1503dfd9b413f0ba3c95653b2d 100644 (file)
@@ -17,9 +17,7 @@
         "options": {
             "scales": {
                 "x": {
-                    "display": false,
-                    "min": -8,
-                    "max": 12
+                    "display": false
                 },
                 "y": {
                     "display": false