Skip to content

Commit

Permalink
apply strokeStyle only when is actually set
Browse files Browse the repository at this point in the history
  • Loading branch information
joseraul committed Jan 10, 2020
1 parent 91797dd commit 9a0d766
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/core/core.scale.js
Original file line number Diff line number Diff line change
Expand Up @@ -1271,6 +1271,7 @@ class Scale extends Element {

const ctx = me.ctx;
const items = me._labelItems || (me._labelItems = me._computeLabelItems(chartArea));
const useTextWithStroke = optionTicks.lineWidth > 0 && optionTicks.strokeStyle !== '';
let i, j, ilen, jlen;

for (i = 0, ilen = items.length; i < ilen; ++i) {
Expand All @@ -1285,20 +1286,27 @@ class Scale extends Element {
ctx.fillStyle = tickFont.color;
ctx.textBaseline = 'middle';
ctx.textAlign = item.textAlign;
ctx.strokeStyle = optionTicks.strokeStyle;
ctx.lineWidth = optionTicks.lineWidth;

if (useTextWithStroke) {
ctx.strokeStyle = optionTicks.strokeStyle;
ctx.lineWidth = optionTicks.lineWidth;
}

const label = item.label;
let y = item.textOffset;
if (isArray(label)) {
for (j = 0, jlen = label.length; j < jlen; ++j) {
// We just make sure the multiline element is a string here..
ctx.strokeText('' + label[j], 0, y);
if (useTextWithStroke) {
ctx.strokeText('' + label[j], 0, y);
}
ctx.fillText('' + label[j], 0, y);
y += tickFont.lineHeight;
}
} else {
ctx.strokeText(label, 0, y);
if (useTextWithStroke) {
ctx.strokeText(label, 0, y);
}
ctx.fillText(label, 0, y);
}
ctx.restore();
Expand Down

0 comments on commit 9a0d766

Please sign in to comment.