mirror of
https://github.com/chartjs/Chart.js.git
synced 2024-10-06 04:09:08 +02:00
Fix mismatch between hit boxes and drawn items in legend plugin (#11352)
* Fix mismatch between hit boxes and drawn items in legend plugin * fixes padding calculation
This commit is contained in:
parent
1c2dd6898e
commit
57bbd8229d
@ -428,7 +428,7 @@ export class Legend extends Element {
|
|||||||
cursor.x += width + padding;
|
cursor.x += width + padding;
|
||||||
} else if (typeof legendItem.text !== 'string') {
|
} else if (typeof legendItem.text !== 'string') {
|
||||||
const fontLineHeight = labelFont.lineHeight;
|
const fontLineHeight = labelFont.lineHeight;
|
||||||
cursor.y += calculateLegendItemHeight(legendItem, fontLineHeight);
|
cursor.y += calculateLegendItemHeight(legendItem, fontLineHeight) + padding;
|
||||||
} else {
|
} else {
|
||||||
cursor.y += lineHeight;
|
cursor.y += lineHeight;
|
||||||
}
|
}
|
||||||
@ -575,7 +575,7 @@ function calculateItemHeight(_itemHeight, legendItem, fontLineHeight) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function calculateLegendItemHeight(legendItem, fontLineHeight) {
|
function calculateLegendItemHeight(legendItem, fontLineHeight) {
|
||||||
const labelHeight = legendItem.text ? legendItem.text.length + 0.5 : 0;
|
const labelHeight = legendItem.text ? legendItem.text.length : 0;
|
||||||
return fontLineHeight * labelHeight;
|
return fontLineHeight * labelHeight;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 17 KiB |
Loading…
Reference in New Issue
Block a user