mirror of
https://github.com/we-promise/sure.git
synced 2026-09-03 13:51:29 +00:00
fix(charts): round series values to the currency's display precision (#3091)
* fix(charts): round chart values to the currency's display precision Charts are drawn from the serialized amounts, not from the formatted strings, so a sub-unit residue plotted as a visible move between two points that both read $0.00, and the trend between them reported a change. Round in `Series#as_json` so the series values stay exact for insights, goals and the assistant. Also hide the percentage when the previous value is zero, since that makes it infinite. * fix(charts): round the two payloads that bypass Series#as_json `NetWorthBreakdownSeriesBuilder` builds its payload by hand, so the reports chart never went through the rounding added in `Series#as_json` and still plotted raw amounts: adjacent points printing the same value rendered a visible move, and the tooltip it inherits reported a change between them. `Series#trend` had the same gap on the server side. It is rendered right above the chart by `UI::Account::Chart` and by the reports summary, so an account going from 0 to a sub-cent residue showed a coloured $0.00 change next to a flat line. Rounding the trend can make a previously finite percentage infinite, so guard the three views that render `percent_formatted` without checking, as `shared/_trend_change` already does. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> * fix(charts): address net worth review comments * fix(charts): tighten rounded trend handling * fix(reports): restore positive sign in print trend --------- Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com> Co-authored-by: sure-admin <sure-admin@splashblot.com>
This commit is contained in:
co-authored by
Claude Opus 5
sure-admin
parent
0ff5b0f274
commit
f0a0013da9
@@ -408,11 +408,15 @@ export default class extends Controller {
|
||||
</div>
|
||||
|
||||
${
|
||||
datum.trend.value === 0
|
||||
this._extractNumericValue(datum.trend.value) === 0
|
||||
? `<span class="w-20"></span>`
|
||||
: `
|
||||
<span class="tabular-nums" style="color: ${datum.trend.color};">
|
||||
${this._extractFormattedValue(datum.trend.value)} (${datum.trend.percent_formatted})
|
||||
${this._extractFormattedValue(datum.trend.value)}${
|
||||
datum.trend.percent === null
|
||||
? ""
|
||||
: ` (${datum.trend.percent_formatted})`
|
||||
}
|
||||
</span>
|
||||
`
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user