]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Horizontal axis with center position should display labels (#8221)
authorEvert Timberg <evert.timberg+github@gmail.com>
Tue, 22 Dec 2020 16:33:53 +0000 (11:33 -0500)
committerGitHub <noreply@github.com>
Tue, 22 Dec 2020 16:33:53 +0000 (11:33 -0500)
* Horizontal axes with center positions should have labels
* Linting
* Test updates
* Increase the tolerance for one test

src/core/core.scale.js
test/fixtures/core.scale/x-axis-position-center.json
test/fixtures/core.scale/x-axis-position-center.png
test/fixtures/core.scale/x-axis-position-dynamic.json
test/fixtures/core.scale/x-axis-position-dynamic.png
test/fixtures/core.scale/y-axis-position-center.json
test/fixtures/core.scale/y-axis-position-center.png
test/fixtures/core.scale/y-axis-position-dynamic.json
test/fixtures/core.scale/y-axis-position-dynamic.png

index 21c212195a0ede54450e1c19356b1031c90392a1..d04160bf7f9e656a199a9f045afce30e903fef22 100644 (file)
@@ -1398,7 +1398,8 @@ export default class Scale extends Element {
                                        } else {
                                                textOffset = (-1 * labelSizes.highest.height) + (0.5 * lineHeight);
                                        }
-                               } else if (position === 'bottom') {
+                               } else {
+                                       // eslint-disable-next-line no-lonely-if
                                        if (crossAlign === 'near' || rotation !== 0) {
                                                textOffset = Math.sin(rotation) * halfCount * lineHeight;
                                                textOffset += (rotation === 0 ? 0.5 : Math.cos(rotation) * halfCount) * lineHeight;
index cb15026bc2c15238aa95728f6b7ed8315245469b..8f3ec140980a9bf255996316112ce94165d46b7b 100644 (file)
@@ -27,7 +27,7 @@
                         "drawOnChartArea": false
                     },
                     "ticks": {
-                        "display": false
+                        "display": true
                     }
                 },
                 "y": {
@@ -40,7 +40,7 @@
                         "drawOnChartArea": false
                     },
                     "ticks": {
-                        "display": false
+                        "display": true
                     }
                 }
             }
@@ -50,6 +50,7 @@
         "canvas": {
             "height": 256,
             "width": 512
-        }
+        },
+        "spriteText": true
     }
 }
index c9ef8c8785a1c14e73d41a2a3d485754fc6c6bc8..f984570859bad411ad1ca95086a21f0007839b68 100644 (file)
Binary files a/test/fixtures/core.scale/x-axis-position-center.png and b/test/fixtures/core.scale/x-axis-position-center.png differ
index 53954acd379827eb7743693bbf346ffe5bba7d96..9661dedd2b2ff85677adba449215290747b90cd6 100644 (file)
@@ -29,7 +29,7 @@
                         "drawOnChartArea": false
                     },
                     "ticks": {
-                        "display": false
+                        "display": true
                     }
                 },
                 "y": {
@@ -42,7 +42,7 @@
                         "drawOnChartArea": false
                     },
                     "ticks": {
-                        "display": false
+                        "display": true
                     }
                 }
             }
@@ -52,6 +52,7 @@
         "canvas": {
             "height": 256,
             "width": 512
-        }
+        },
+        "spriteText": true
     }
 }
index 0ac0a903c3211247ed46fee0f4baf105a58b9b8c..856730964553ee02e3a8d6030630180b11dc413d 100644 (file)
Binary files a/test/fixtures/core.scale/x-axis-position-dynamic.png and b/test/fixtures/core.scale/x-axis-position-dynamic.png differ
index 1ba27c87c1bb18052ff73f45fa79eb78e7f32a72..ff0cf28f9c2b3688fa553b1564103a5ccc681f2a 100644 (file)
@@ -27,7 +27,7 @@
                         "drawOnChartArea": false
                     },
                     "ticks": {
-                        "display": false
+                        "display": true
                     }
                 },
                 "y": {
@@ -40,7 +40,7 @@
                         "drawOnChartArea": false
                     },
                     "ticks": {
-                        "display": false
+                        "display": true
                     }
                 }
             }
@@ -50,6 +50,7 @@
         "canvas": {
             "height": 256,
             "width": 512
-        }
+        },
+        "spriteText": true
     }
 }
index ce00eada3106bbf1d2ef41743a72663149d1545e..5d741d1880a1be84ac02ab28dad3d6f667d37c52 100644 (file)
Binary files a/test/fixtures/core.scale/y-axis-position-center.png and b/test/fixtures/core.scale/y-axis-position-center.png differ
index 0eaeb8199e99a4969bc7bedcf0bef95cdced18b9..6e44d10facda8132771f49f231737a4c4f1a99c9 100644 (file)
@@ -27,7 +27,7 @@
                         "drawOnChartArea": false
                     },
                     "ticks": {
-                        "display": false
+                        "display": true
                     }
                 },
                 "y": {
@@ -42,7 +42,7 @@
                         "drawOnChartArea": false
                     },
                     "ticks": {
-                        "display": false
+                        "display": true
                     }
                 }
             }
@@ -52,6 +52,8 @@
         "canvas": {
             "height": 256,
             "width": 512
-        }
-    }
+        },
+        "spriteText": true
+    },
+    "tolerance": 0.01
 }
index 70f4efbf30981ae17a507d62252f9eca7a54c710..33863ea8f96e3b0266bde6b84bed05788c907204 100644 (file)
Binary files a/test/fixtures/core.scale/y-axis-position-dynamic.png and b/test/fixtures/core.scale/y-axis-position-dynamic.png differ