Chart.js icon indicating copy to clipboard operation
Chart.js copied to clipboard

BUG positioning label inside legend

Open batata004 opened this issue 1 year ago • 2 comments

Expected behavior

Hi take a look at the image below (I zoomed in). It's completely impossible to vertical align the text on the right side of each legend. Even using pointStyle as rect or rectRounded gets misaligned. Chaing the font size does not help because the text is always closer to the top.

If there was a way to set marginTop to the text (not the legend) it would help, or you dont even need to create any new option, just correctly vertical align the text because I am pretty sure 99% of people will want their text centered vertically to the box at the left.

image

image

Current behavior

The text is misaligned.

Reproducible sample

The bug is reproduceable in any legend.

Optional extra steps/info to reproduce

No response

Possible solution

No response

Context

No response

chart.js version

latest

Browser name and version

No response

Link to your project

No response

batata004 avatar Aug 28 '24 03:08 batata004

I think the problem may because that the letters are like "M, i, b, t, d" in your case, if say write a letter into three row space. The letters are all in the top and middle row. so looks like it's top padding is too small and bottom padding is too big. But the extra spaces I think it's for letters like "g, q, p, y" etc.

huqingkun avatar Sep 20 '24 05:09 huqingkun

@huqingkun you are right. But if it was possible to set a "line-height" the user could properly align the text (or if it was possible to use "padding-top" it would also help but "line-height" would be better because it automatically align verticaly at the center).

batata004 avatar Sep 20 '24 19:09 batata004