Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/elements/element.point.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ module.exports = Element.extend({

// Clipping for Points.
if (chartArea === undefined || (model.x >= chartArea.left && chartArea.right * errMargin >= model.x && model.y >= chartArea.top && chartArea.bottom * errMargin >= model.y)) {
ctx.strokeStyle = vm.borderColor || defaultColor;
ctx.strokeStyle = ctx.lineWidth === 0 ? 'rgba(0,0,0,0)' : vm.borderColor || defaultColor;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are trying to access ctx.lineWidth before assigning it a value (next line), is that expected?

Though, I think @benmccann suggestion was wrong because according the MDN:

lineWidth: A number specifying the line width in space units. Zero, negative, Infinity and NaN values are ignored.

image

So ctx.lineWidth will never match ctx.lineWidth === 0 (because ignored) so I would keep your first approach and cache the lineWidth value (and check for lineWidth === null or undefined using !lineWidth):

// ...
var errMargin = 1.01;
var lineWidth;

//...

lineWidth = helpers.valueOrDefault(vm.borderWidth, defaults.global.elements.point.borderWidth);
ctx.strokeStyle = !lineWidth ? 'rgba(0,0,0,0)' : vm.borderColor || defaultColor;
ctx.lineWidth = lineWidth;

ctx.lineWidth = helpers.valueOrDefault(vm.borderWidth, defaults.global.elements.point.borderWidth);
ctx.fillStyle = vm.backgroundColor || defaultColor;
helpers.canvas.drawPoint(ctx, pointStyle, radius, x, y);
Expand Down