handle fixed width formatting
This commit is contained in:
parent
973e7b09ee
commit
8a38c5050f
|
@ -6,6 +6,7 @@ import _ from "lodash";
|
||||||
import {
|
import {
|
||||||
ajax,
|
ajax,
|
||||||
forEachMonth,
|
forEachMonth,
|
||||||
|
formatFixedWidthFloat,
|
||||||
formatCurrency,
|
formatCurrency,
|
||||||
formatCurrencyCrude,
|
formatCurrencyCrude,
|
||||||
Posting,
|
Posting,
|
||||||
|
@ -406,18 +407,18 @@ function renderCurrentExpensesBreakdown(
|
||||||
.attr("class", "is-family-monospace")
|
.attr("class", "is-family-monospace")
|
||||||
.text(
|
.text(
|
||||||
(d) =>
|
(d) =>
|
||||||
`${formatCurrency(d.total)} ${sprintf(
|
`${formatCurrency(d.total)} ${formatFixedWidthFloat(
|
||||||
"%6.2f",
|
(d.total / total) * 100,
|
||||||
(d.total / total) * 100
|
6
|
||||||
)}%`
|
)}%`
|
||||||
),
|
),
|
||||||
(update) =>
|
(update) =>
|
||||||
update
|
update
|
||||||
.text(
|
.text(
|
||||||
(d) =>
|
(d) =>
|
||||||
`${formatCurrency(d.total)} ${sprintf(
|
`${formatCurrency(d.total)} ${formatFixedWidthFloat(
|
||||||
"%6.2f",
|
(d.total / total) * 100,
|
||||||
(d.total / total) * 100
|
6
|
||||||
)}%`
|
)}%`
|
||||||
)
|
)
|
||||||
.transition(t)
|
.transition(t)
|
||||||
|
|
|
@ -163,6 +163,13 @@ export function formatFloat(value, precision = 2) {
|
||||||
return sprintf(`%.${precision}f`, value);
|
return sprintf(`%.${precision}f`, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function formatFixedWidthFloat(value, width, precision = 2) {
|
||||||
|
if (obscure) {
|
||||||
|
value = 0;
|
||||||
|
}
|
||||||
|
return sprintf(`%${width}.${precision}f`, value);
|
||||||
|
}
|
||||||
|
|
||||||
export function forEachMonth(
|
export function forEachMonth(
|
||||||
start: dayjs.Dayjs,
|
start: dayjs.Dayjs,
|
||||||
end: dayjs.Dayjs,
|
end: dayjs.Dayjs,
|
||||||
|
|
Loading…
Reference in New Issue