When gridLines.display is false, the axis border is still drawn (#7014)

This commit is contained in:
Evert Timberg 2020-01-27 17:57:31 -05:00 committed by GitHub
parent 47c7a42aae
commit b59dd5082e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1161,11 +1161,6 @@ class Scale extends Element {
_drawGrid(chartArea) { _drawGrid(chartArea) {
const me = this; const me = this;
const gridLines = me.options.gridLines; const gridLines = me.options.gridLines;
if (!gridLines.display) {
return;
}
const ctx = me.ctx; const ctx = me.ctx;
const chart = me.chart; const chart = me.chart;
let context = { let context = {
@ -1176,34 +1171,36 @@ class Scale extends Element {
const items = me._gridLineItems || (me._gridLineItems = me._computeGridLineItems(chartArea)); const items = me._gridLineItems || (me._gridLineItems = me._computeGridLineItems(chartArea));
let i, ilen; let i, ilen;
for (i = 0, ilen = items.length; i < ilen; ++i) { if (gridLines.display) {
const item = items[i]; for (i = 0, ilen = items.length; i < ilen; ++i) {
const width = item.width; const item = items[i];
const color = item.color; const width = item.width;
const color = item.color;
if (width && color) { if (width && color) {
ctx.save(); ctx.save();
ctx.lineWidth = width; ctx.lineWidth = width;
ctx.strokeStyle = color; ctx.strokeStyle = color;
if (ctx.setLineDash) { if (ctx.setLineDash) {
ctx.setLineDash(item.borderDash); ctx.setLineDash(item.borderDash);
ctx.lineDashOffset = item.borderDashOffset; ctx.lineDashOffset = item.borderDashOffset;
}
ctx.beginPath();
if (gridLines.drawTicks) {
ctx.moveTo(item.tx1, item.ty1);
ctx.lineTo(item.tx2, item.ty2);
}
if (gridLines.drawOnChartArea) {
ctx.moveTo(item.x1, item.y1);
ctx.lineTo(item.x2, item.y2);
}
ctx.stroke();
ctx.restore();
} }
ctx.beginPath();
if (gridLines.drawTicks) {
ctx.moveTo(item.tx1, item.ty1);
ctx.lineTo(item.tx2, item.ty2);
}
if (gridLines.drawOnChartArea) {
ctx.moveTo(item.x1, item.y1);
ctx.lineTo(item.x2, item.y2);
}
ctx.stroke();
ctx.restore();
} }
} }