fix: store dashboard wallet balance chart and numbers widget (#7247)
What changed, and why it matters
This commit fixes a store dashboard widget that displays wallet balance charts and numbers. The changes ensure chart labels are rendered correctly (especially the last data point) and convert API timestamps from Unix seconds into ISO date strings that the chart library expects. There is no security-relevant change.
No security action required; treat as a routine UI bug fix.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch modifies BTCPayServer/Components/StoreWalletBalance/Default.cshtml. It adjusts Chartist label interpolation so the final point is always labeled and computes label spacing with Math.max/Math.ceil to avoid division-by-zero or fractional step issues. It also maps API labels (Unix timestamps in seconds) to ISO strings by multiplying by 1000 before creating Date objects. These are UI/data-formatting fixes only.
Changed components
BTCPayServer/Components/StoreWalletBalance/Default.cshtmlInspect captured patch +6 / −3
diff --git a/BTCPayServer/Components/StoreWalletBalance/Default.cshtml b/BTCPayServer/Components/StoreWalletBalance/Default.cshtml
index a515f6f..886d76f 100644
--- a/BTCPayServer/Components/StoreWalletBalance/Default.cshtml
+++ b/BTCPayServer/Components/StoreWalletBalance/Default.cshtml
@@ -99,11 +99,13 @@
const low = Math.max(min - ((max - min) / 5), 0);
const renderOpts = Object.assign({}, chartOpts, { low, axisX: {
labelInterpolationFnc(date, i) {
- return i % labelEvery === 0 ? dateFormatter.format(new Date(date)) : null
+ return i === pointCount - 1 || i % labelEvery === 0
+ ? dateFormatter.format(new Date(date))
+ : null
}
} });
const pointCount = series.length;
- const labelEvery = pointCount / labelCount;
+ const labelEvery = Math.max(1, Math.ceil((pointCount - 1) / (labelCount - 1)));
new Chartist.Line(`#${id} .ct-chart`, {
labels: labels,
series: [series]
@@ -114,7 +116,8 @@
const url = baseUrl.replace(/\/week$/gi, `/${type}`);
const response = await fetch(url);
if (response.ok) {
- data = await response.json();
+ const json = await response.json();
+ data = { ...json, labels: json.labels.map(l => new Date(l * 1000).toISOString()) };
render(data);
}
};
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.