From: stockiNail Date: Tue, 20 Jun 2023 16:20:12 +0000 (+0200) Subject: Fix mismatch between hit boxes and drawn items in legend plugin (#11352) X-Git-Tag: v4.3.1~7 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=57bbd8229daa0c2f607aae8967ac518a28ef83ae;p=thirdparty%2FChart.js.git 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 --- diff --git a/src/plugins/plugin.legend.js b/src/plugins/plugin.legend.js index 8d8264d63..6ed994135 100644 --- a/src/plugins/plugin.legend.js +++ b/src/plugins/plugin.legend.js @@ -428,7 +428,7 @@ export class Legend extends Element { cursor.x += width + padding; } else if (typeof legendItem.text !== 'string') { const fontLineHeight = labelFont.lineHeight; - cursor.y += calculateLegendItemHeight(legendItem, fontLineHeight); + cursor.y += calculateLegendItemHeight(legendItem, fontLineHeight) + padding; } else { cursor.y += lineHeight; } @@ -575,7 +575,7 @@ function calculateItemHeight(_itemHeight, 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; } diff --git a/test/fixtures/plugin.legend/legend-doughnut-right-center-mulitiline-labels.png b/test/fixtures/plugin.legend/legend-doughnut-right-center-mulitiline-labels.png index 6be697361..1e92045fc 100644 Binary files a/test/fixtures/plugin.legend/legend-doughnut-right-center-mulitiline-labels.png and b/test/fixtures/plugin.legend/legend-doughnut-right-center-mulitiline-labels.png differ