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

Strikethrough on legend being too thick on small label size #11692

Open
ChaunceyKiwi opened this issue Feb 29, 2024 · 0 comments
Open

Strikethrough on legend being too thick on small label size #11692

ChaunceyKiwi opened this issue Feb 29, 2024 · 0 comments

Comments

@ChaunceyKiwi
Copy link

ChaunceyKiwi commented Feb 29, 2024

Feature Proposal

Based on legend strikethough implementation(code1, code2), legend strikethrough will always have lineWidth as 2 regardless of actual font size. This issue becomes clearly noticeable on small device as shown below.
IMG_0064

Possible Implementation

Would suggest to calculate lineWidth based on font size for legend. A rough idea would be updating code from

renderText(ctx, legendItem.text, x, y + (itemHeight / 2), labelFont, {
  strikethrough: legendItem.hidden,
  textAlign: rtlHelper.textAlign(legendItem.textAlign)
});

to

renderText(ctx, legendItem.text, x, y + (itemHeight / 2), labelFont, {
  strikethrough: legendItem.hidden,
  textAlign: rtlHelper.textAlign(legendItem.textAlign),
  decorationWidth: labelFont.size / 8
});

I tested locally this change and this is before and after:
compare

If hard coding ratio here is not acceptable, another option would be providing some option like the one for label to customize strikethrough width.

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

1 participant