Merge pull request #1836 from nnnick/fix/1740

Draw line at edge of scales
This commit is contained in:
Evert Timberg
2015-12-29 10:09:54 -05:00
2 changed files with 94 additions and 1 deletions

View File

@@ -603,7 +603,6 @@
}
}
this.ctx.translate(xLabelValue, yLabelValue);
this.ctx.rotate(helpers.toRadians(this.labelRotation) * -1);
this.ctx.font = labelFont;
@@ -630,6 +629,25 @@
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;
y1 += helpers.aliasPixel(this.ctx.lineWidth);
y2 += helpers.aliasPixel(this.ctx.lineWidth);
} else {
x1 = x2 = this.options.position === 'left' ? this.right : this.left;
x1 += helpers.aliasPixel(this.ctx.lineWidth);
x2 += helpers.aliasPixel(this.ctx.lineWidth);
}
this.ctx.moveTo(x1, y1);
this.ctx.lineTo(x2, y2);
this.ctx.stroke();
}
}
});

View 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.5]
}, {
"name": "lineTo",
"args": [200, 100.5]
}, {
"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.5]
}, {
"name": "lineTo",
"args": [200, 100.5]
}, {
"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.5, 0]
}, {
"name": "lineTo",
"args": [30.5, 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.5, 0]
}, {
"name": "lineTo",
"args": [30.5, 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.5, 0]
}, {
"name": "lineTo",
"args": [30.5, 300]
}, {
"name": "stroke",
"args": []
}])
});
});