]> git.ipfire.org Git - thirdparty/Chart.js.git/commitdiff
Draw line at edge of scales & update tests
authorEvert Timberg <evert.timberg@gmail.com>
Mon, 28 Dec 2015 14:26:59 +0000 (09:26 -0500)
committerEvert Timberg <evert.timberg@gmail.com>
Mon, 28 Dec 2015 14:26:59 +0000 (09:26 -0500)
src/core/core.scale.js
test/scale.linear.tests.js

index d28fc56b70fc699547c69ba9a962a6ae641db435..8b8d791cfae879a5f981c09f5eca76724b19d4be 100644 (file)
                                                                }
                                                        }
 
-
                                                        this.ctx.translate(xLabelValue, yLabelValue);
                                                        this.ctx.rotate(helpers.toRadians(this.labelRotation) * -1);
                                                        this.ctx.font = labelFont;
                                                this.ctx.restore();
                                        }
                                }
+
+                               // Draw the line at the edge of the axis
+                               this.ctx.lineWidth = this.options.gridLines.lineWidth;
+                               this.ctx.strokeStyle = this.options.gridLines.color;
+                               var x1 = this.left, x2 = this.right, y1 = this.top, y2 = this.bottom;
+
+                               if (this.isHorizontal()) {
+                                       y1 = y2 = this.options.position === 'top' ? this.bottom : this.top;
+                               } else {
+                                       x1 = x2 = this.options.position === 'left' ? this.right : this.left;
+                               }
+
+                               this.ctx.moveTo(x1, y1);
+                               this.ctx.lineTo(x2, y2);
+                               this.ctx.stroke();
                        }
                }
        });
index 5ca84951aea9c7bb22930cbdd3a5c797b466cbb1..cc36b7b188f77a7bb666034e7cc291b0faa8992d 100644 (file)
@@ -978,6 +978,21 @@ describe('Linear Scale', function() {
                }, {
                        "name": "restore",
                        "args": []
+               }, {
+                       "name": "setLineWidth",
+                       "args": [1]
+               }, {
+                       "name": "setStrokeStyle",
+                       "args": ["rgba(0, 0, 0, 0.1)"]
+               }, {
+                       "name": "moveTo",
+                       "args": [0, 100]
+               }, {
+                       "name": "lineTo",
+                       "args": [200, 100]
+               }, {
+                       "name": "stroke",
+                       "args": []
                }];
                expect(mockContext.getCalls()).toEqual(expected);
 
@@ -1036,6 +1051,21 @@ describe('Linear Scale', function() {
                }, {
                        "name": "fillText",
                        "args": ["myLabel", 100, 122]
+               }, {
+                       "name": "setLineWidth",
+                       "args": [1]
+               }, {
+                       "name": "setStrokeStyle",
+                       "args": ["rgba(0, 0, 0, 0.1)"]
+               }, {
+                       "name": "moveTo",
+                       "args": [0, 100]
+               }, {
+                       "name": "lineTo",
+                       "args": [200, 100]
+               }, {
+                       "name": "stroke",
+                       "args": []
                }]);
 
                // Turn off display
@@ -1480,6 +1510,21 @@ describe('Linear Scale', function() {
                }, {
                        "name": "restore",
                        "args": []
+               }, {
+                       "name": "setLineWidth",
+                       "args": [1]
+               }, {
+                       "name": "setStrokeStyle",
+                       "args": ["rgba(0, 0, 0, 0.1)"]
+               }, {
+                       "name": "moveTo",
+                       "args": [30, 0]
+               }, {
+                       "name": "lineTo",
+                       "args": [30, 300]
+               }, {
+                       "name": "stroke",
+                       "args": []
                }]);
 
                // Turn off some drawing
@@ -1596,6 +1641,21 @@ describe('Linear Scale', function() {
                }, {
                        "name": "restore",
                        "args": []
+               }, {
+                       "name": "setLineWidth",
+                       "args": [1]
+               }, {
+                       "name": "setStrokeStyle",
+                       "args": ["rgba(0, 0, 0, 0.1)"]
+               }, {
+                       "name": "moveTo",
+                       "args": [30, 0]
+               }, {
+                       "name": "lineTo",
+                       "args": [30, 300]
+               }, {
+                       "name": "stroke",
+                       "args": []
                }]);
        });
 
@@ -1838,6 +1898,21 @@ describe('Linear Scale', function() {
                }, {
                        "name": "restore",
                        "args": []
+               }, {
+                       "name": "setLineWidth",
+                       "args": [1]
+               }, {
+                       "name": "setStrokeStyle",
+                       "args": ["rgba(0, 0, 0, 0.1)"]
+               }, {
+                       "name": "moveTo",
+                       "args": [30, 0]
+               }, {
+                       "name": "lineTo",
+                       "args": [30, 300]
+               }, {
+                       "name": "stroke",
+                       "args": []
                }])
        });
 });
\ No newline at end of file