Repository navigation
fix(kpi_grid): show decimal KPI values at their own precision - #921
Open
executorrr86 wants to merge 1 commit into
Open
executorrr86 wants to merge 1 commit into
executorrr86 wants to merge 1 commit into
Conversation
The count-up rounded every value to an integer, so 1.76 showed "2" and 0.4 showed "0". remotion's spring also settles just under 1, so 12.5 stayed at "12" on every frame. The counter now keeps the target's decimal places. Integers and K/M values render exactly as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
KPIGridshows decimal values wrong. The count-up doesMath.round(metric.value * countProgress), so 1.76 shows "2", 0.72 shows "1" and 0.4 shows "0". remotion'sspring()also settles just under 1 (0.9999999999999998 and 0.9999999999999999 for the two configs KPIGrid uses), so 12.5 stays at "12" on every frame. A KPI card with 12.5 / 1.76 / 0.72 renders pixel-identical to one with 12 / 2 / 1.The counter now keeps the precision the value was written with, in line with the precise-label approach of #656.
Related issue
None. Refs #518, which sees the same
Math.roundand adds an opt-indecimalsfield. Without that field it keeps rounding, so 12.5 still shows "12".Changes
charts/format.ts:decimalsOf(n)gives the decimal places of a value, as written.formatKpiValue(target, progress)gives the animated counter. Scale (K/M) and digits come from the target, so they never jump mid-animation.KPIGrid.tsxusesformatKpiValuein place ofMath.round+formatDisplayValue, which is removed.changeindicator keepstoFixed(1). Happy to cover it in a follow-up if you want it at full precision too.Testing
npx tsc --noEmit: clean.pytest tests: 2926 passed, 17 skipped.tests/contracts/test_kpi_grid_value_format_contract.pyruns the productionformat.tsin Node:remotion still) that a 12.5 / 1.76 / 0.72 card no longer matches the 12 / 2 / 1 card. It fails onmainand passes here. It is skipped when Remotion is not installed, so it does not run in the current CI job.mainat frames 20, 40 and 120 (mid count-up and final).Checklist
make test-contracts/make test) where applicable.🤖 Generated with Claude Code