Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A 0px legend border becomes .5px instead #3241

Closed
Pikamander2 opened this issue Sep 1, 2016 · 2 comments
Closed

A 0px legend border becomes .5px instead #3241

Pikamander2 opened this issue Sep 1, 2016 · 2 comments

Comments

@Pikamander2
Copy link
Contributor

Pikamander2 commented Sep 1, 2016

chartjs bug

If you try to set the legend's border to 0px, it becomes .5px instead. This causes a faint border to appear around the legend's color, which is undesirable.

Making the label's color value fully transparent ("rgba(0,0,0,0)") fixes this in Chrome, but not Firefox.

Here's an example: http://codepen.io/anon/pen/GjRKLX

Here's that example, scaled 3x to make it more obvious: http://codepen.io/anon/pen/yaLBky

The reason why this occurs is because, when setting canvas's lineWidth property, "zero, negative, Infinity and NaN values are ignored" and instead replaced with a value of 0.5.

To avoid this problem, Chart.js shouldn't draw the border if the borderWidth is set to 0.

@Pikamander2
Copy link
Contributor Author

Pikamander2 commented Sep 1, 2016

The issue can be fixed by checking the desired width:

var isLineWidthZero = (itemOrDefault(legendItem.lineWidth, lineDefault.borderWidth) === 0);

and then using that to decide whether a stroke should be drawn:

if (!isLineWidthZero)
{
    ctx.strokeRect(x, y, boxWidth, fontSize);
}

Pikamander2 added a commit to Pikamander2/Chart.js that referenced this issue Sep 1, 2016
Pikamander2 added a commit to Pikamander2/Chart.js that referenced this issue Sep 1, 2016
etimberg added a commit that referenced this issue Sep 2, 2016
Fix zero border width not working (issue #3241)
@etimberg
Copy link
Member

etimberg commented Sep 2, 2016

Fixed in #3242

@etimberg etimberg closed this as completed Sep 2, 2016
exwm pushed a commit to exwm/Chart.js that referenced this issue Apr 30, 2021
exwm pushed a commit to exwm/Chart.js that referenced this issue Apr 30, 2021
exwm pushed a commit to exwm/Chart.js that referenced this issue Apr 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants