]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Fix labelOffset not working for vertical axes (#4249)
authorSuhaib Khan <suheb.work@gmail.com>
Sat, 15 Jul 2017 08:19:16 +0000 (13:49 +0530)
committerSimon Brunel <simonbrunel@users.noreply.github.com>
Sat, 15 Jul 2017 08:19:16 +0000 (10:19 +0200)
src/core/core.scale.js
test/fixtures/core.scale/label-offset-vertical-axes.json [new file with mode: 0644]
test/fixtures/core.scale/label-offset-vertical-axes.png [new file with mode: 0644]
test/specs/core.scale.tests.js [new file with mode: 0644]

index 5d8d82576a6049ebed26da5ea56516b95ff68988..2938385cdc16c85226e17d3fda258707e0b75c88 100644 (file)
@@ -647,7 +647,7 @@ module.exports = function(Chart) {
 
                                        var yLineValue = me.getPixelForTick(index); // xvalues for grid lines
                                        yLineValue += helpers.aliasPixel(lineWidth);
-                                       labelY = me.getPixelForTick(index, gridLines.offsetGridLines);
+                                       labelY = me.getPixelForTick(index, gridLines.offsetGridLines) + optionTicks.labelOffset;
 
                                        tx1 = xTickStart;
                                        tx2 = xTickEnd;
diff --git a/test/fixtures/core.scale/label-offset-vertical-axes.json b/test/fixtures/core.scale/label-offset-vertical-axes.json
new file mode 100644 (file)
index 0000000..dbd979e
--- /dev/null
@@ -0,0 +1,41 @@
+{
+    "config": {
+        "type": "horizontalBar",
+        "data": {
+            "labels": ["\u25C0", "\u25A0", "\u25C6", "\u25CF"],
+            "datasets": [{
+                "data": [12, 19, 3, 5]
+            }]
+        },
+        "options": {
+            "legend": false,
+            "title": false,
+            "scales": {
+                "xAxes": [{
+                    "ticks": {
+                        "display": false
+                    },
+                    "gridLines":{
+                        "display": false,
+                        "drawBorder": false
+                    }
+                }],
+                "yAxes": [{
+                    "ticks": {
+                        "labelOffset": 25
+                    },
+                    "gridLines":{
+                        "display": false,
+                        "drawBorder": false
+                    }
+                }]
+            }
+        }
+    },
+    "options": {
+        "canvas": {
+            "height": 256,
+            "width": 512
+        }
+    }
+}
diff --git a/test/fixtures/core.scale/label-offset-vertical-axes.png b/test/fixtures/core.scale/label-offset-vertical-axes.png
new file mode 100644 (file)
index 0000000..2f6b18c
Binary files /dev/null and b/test/fixtures/core.scale/label-offset-vertical-axes.png differ
diff --git a/test/specs/core.scale.tests.js b/test/specs/core.scale.tests.js
new file mode 100644 (file)
index 0000000..58e5a33
--- /dev/null
@@ -0,0 +1,3 @@
+describe('Core.scale', function() {
+       describe('auto', jasmine.specsFromFixtures('core.scale'));
+});