From 38d3154ddfc264eb665da08390604f3677e50ef1 Mon Sep 17 00:00:00 2001 From: d11n Date: Mon, 2 May 2022 14:32:24 +0200 Subject: [PATCH] Dashboard: Prevent y-axis labels from getting cut off (#3702) Fixes #3692. --- .../Components/StoreWalletBalance/Default.cshtml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/BTCPayServer/Components/StoreWalletBalance/Default.cshtml b/BTCPayServer/Components/StoreWalletBalance/Default.cshtml index 28308e9f0..6eedf0bb3 100644 --- a/BTCPayServer/Components/StoreWalletBalance/Default.cshtml +++ b/BTCPayServer/Components/StoreWalletBalance/Default.cshtml @@ -32,7 +32,7 @@ const min = Math.min(...series); const max = Math.max(...series); const low = Math.max(min - ((max - min) / 5), 0); - new Chartist.Line(`#${id} .ct-chart`, { + const chart = new Chartist.Line(`#${id} .ct-chart`, { labels, series: [series] }, { @@ -40,6 +40,14 @@ fullWidth: true, showArea: true }); + // prevent y-axis labels from getting cut off + window.setTimeout(() => { + const yLabels = [...document.querySelectorAll('.ct-label.ct-vertical.ct-start')]; + if (yLabels) { + const width = Math.max(...(yLabels.map(l => l.innerText.length * 8))) + chart.update(null, { axisY: { offset: width } }) + } + }, 0) }; const update = async type => { const url = baseUrl.replace(/\/week$/gi, `/${type}`);