Skip to content

fix(insights): Show <0.0001 for very small numeric values instead of 0#111228

Merged
gggritso merged 7 commits intomasterfrom
georgegritsouk/dain-1378-when-values-are-very-small-theyre-shown-as-0-rather-than
Mar 24, 2026
Merged

fix(insights): Show <0.0001 for very small numeric values instead of 0#111228
gggritso merged 7 commits intomasterfrom
georgegritsouk/dain-1378-when-values-are-very-small-theyre-shown-as-0-rather-than

Conversation

@gggritso
Copy link
Member

@gggritso gggritso commented Mar 20, 2026

When a numeric value is very small (less than 0.0001), the field renderer and dashboard widgets were silently rounding it to 0 due to fractional digit capping. This was misleading — e.g. the Jobs widget could show "0 failed jobs" when the actual rate was tiny but nonzero.

e.g.,

A

Values below the minimum representable threshold now display as <0.0001 instead of 0. A tooltip on hover shows the locale-formatted actual value so users can still see the precise number if needed. This is the pattern we also follow for other value types, like rates.

e.g.,
Screenshot 2026-03-20 at 12 13 58 PM

Longer term, when we come back and talk about how we want to format numbers across the product, we'll come back to this decision. There's a decent chance we'll be using scientific notation, for example.

Fixes DAIN-1378

gggritso and others added 3 commits March 20, 2026 11:29
When a numeric value is smaller than the minimum representable value
at the current precision (< 0.0001), the field renderer was silently
rounding it to 0. This was misleading — e.g. the Jobs widget showed
"0 failed jobs" when the actual rate was tiny but nonzero.

Now values in the range (0, 0.0001) are displayed as scientific
notation with 2 significant digits (e.g. 3.3e-5). In table cells, a
tooltip on hover shows the full-precision value. The same fix is
applied to ECharts tooltip formatting.

The minimum-value threshold is derived from the existing
NUMBER_MAX_FRACTION_DIGITS constant so there are no new magic numbers.

Fixes DAIN-1378
Co-Authored-By: Claude <noreply@anthropic.com>
…table

Mirrors the tooltip behavior added to fieldRenderers.tsx: when a numeric
value in the breakdown legend table is smaller than NUMBER_MIN_VALUE,
wrap the scientific notation in a Tooltip that shows the full value on
hover.

Co-Authored-By: Claude <noreply@anthropic.com>
…values

Replace the scientific notation display (e.g. 3.3e-5) with a simpler
threshold indicator (<0.0001) for values below NUMBER_MIN_VALUE. This is
more readable for users who may not be familiar with scientific notation.

Tooltip titles use toLocaleString() instead of toString() so the hover
value is also locale-formatted.

Co-Authored-By: Claude <noreply@anthropic.com>
@gggritso gggritso requested review from a team as code owners March 20, 2026 18:23
@linear-code
Copy link

linear-code bot commented Mar 20, 2026

@gggritso gggritso marked this pull request as draft March 20, 2026 18:23
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Mar 20, 2026
…d table

Introduce a purpose-built formatter for the breakdown legend table under
charts, replacing the reuse of formatTooltipValue (which is scoped to
ECharts hover tooltips). The new formatter handles null values (em dash)
and delegates everything else to formatTooltipValue.

Also adds the missing dataType === 'number' guard on the small-value
Tooltip in the legend table, so the tooltip is not incorrectly applied
to duration, rate, and other non-number types.

Co-Authored-By: Claude <noreply@anthropic.com>
@gggritso
Copy link
Member Author

@cursor review

Copy link
Contributor

@DominikB2014 DominikB2014 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor comment seems plausible? but otherwise lgtm

…and tooltip

The legend and chart tooltip serve different purposes, so small "number"
values (< 0.0001) should be formatted differently in each context:

- Legend: shows "<0.0001" — space-constrained, threshold indicator is enough
- Chart tooltip: shows full precision with 4 significant digits (e.g.
  "0.00003345") — the tooltip's purpose is to show detail, so "<0.0001"
  would be actively misleading there

Also escapes the valueFormatter return value in timeSeriesWidgetVisualization
to prevent HTML injection, matching the existing escaping on nameFormatter.

Co-Authored-By: Claude <noreply@anthropic.com>
…downLegendValue

After the null check, `value` is still `number | string` because
ECHARTS_MISSING_DATA_VALUE is a string constant. Add a `typeof value === 'number'`
guard to narrow the type before the `>` and `<` comparisons.

Co-Authored-By: Claude <noreply@anthropic.com>
@gggritso
Copy link
Member Author

@cursor review

The tooltip on small number values in table cells was calling
toLocaleString() directly. It should use formatTooltipValue instead,
which applies the same 4-significant-digit precision formatting that
chart tooltips use for small numbers.

Co-Authored-By: Claude <noreply@anthropic.com>
@gggritso gggritso marked this pull request as ready for review March 24, 2026 15:57
@gggritso
Copy link
Member Author

@cursor review

Copy link
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

@gggritso gggritso merged commit 3974941 into master Mar 24, 2026
87 of 92 checks passed
@gggritso gggritso deleted the georgegritsouk/dain-1378-when-values-are-very-small-theyre-shown-as-0-rather-than branch March 24, 2026 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants