Skip to content

fix(compare): keep each chart axis inside its metric's range, in one format with distinct ticks - #398

Merged
harenome merged 3 commits into
ThinkFlowLab:mainfrom
harenome:fix/chart-zero-axis
Nov 24, 2026
Merged

harenome merged 3 commits into
ThinkFlowLab:mainfrom
harenome:fix/chart-zero-axis

Conversation

@harenome

@harenome harenome commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #390

What

  • Range: a single value of 0 gets the range 0 to 1, in nice_ticks, for every chart kind. A metric can carry bounds; rates carry 0 and 1, so one rate at a bound pads inwards only.
  • Labels: an axis is written in one format. The formatter gets the tick, the step and the largest tick: the unit comes from the largest tick (k or M, s or m), the decimals from the step in that unit, the same for every tick. Labels are exact, so each is its own. The origin keeps the unit and drops its decimals ($0, 0k, 0%, 0m).
  • Fewest decimals: a rate or token axis whose step would need a decimal more than twice the step doubles it (90% 95% 100%, not 92.5%).
  • The formatters per unit (cost, tokens, rate, minutes, score, count) sit beside the existing axis table in app/web/compare.py; app/nullius/charts.py keeps the step arithmetic and imports no web code. Values outside axes (readings, table cells) are unchanged.

Touches

backend, web

Before and after

Before After
before-scatter-all-zero-1280 after-scatter-all-zero-1280
before-dots-wall-time-1280 after-dots-wall-time-1280

Rows: Compare, Chart view, at 1280 px: scatter of Cost against Adjusted rate, nop against oracle; dots of Run wall time, the same runs.

Verified

  • Backend suite (2860) and route suite (665), in a clean container, on main as of today.
  • New table test over bars, dots and scatter and every unit: tick labels distinct, one unit per axis, one precision apart from a bare origin, none below zero, rates at most 100%, and exact labels for five cases. 18 of its 18 cases fail on main.
  • Tick labels, main then this branch:
    • cost dots $0.01, $0.03: $0.01 $0.01 $0.02 $0.03 $0.03; $0.010 $0.015 $0.020 $0.025 $0.030
    • one cost $0.02: five $0.02; $0.018 to $0.022
    • tokens 1000, 1100: 1.0k 1.0k 1.1k 1.1k 1.1k; 1.00k 1.05k 1.10k
    • minutes 1, 3: 1m 2m 2m 2m 3m; 1.0m 1.5m 2.0m 2.5m 3.0m
    • scores 0.001, 0.004: four 0.00; 0.001 to 0.004
    • cost bars $0.01: 0 $0.0025 $0.0050 $0.0075 $0.01; $0 $0.0025 $0.0050 $0.0075 $0.0100
    • token bars 1000: 0 250 500 750 1.0k; 0k 0.5k 1.0k; 1M: 0 250.0k ... 1.00M; 0M 0.5M 1.0M
    • minutes bars 2: 0 30s 1m 2m 2m; 0m 0.5m 1.0m 1.5m 2.0m
    • rates all 1.0: 90% 100% 110%; 90% 95% 100%
    • cost bars $0.50: 0 $0.20 $0.40 $0.60; $0 $0.20 $0.40 $0.60
    • all-zero cost scatter: $-1.0000 0 $1.00; $0 $1.00
  • Chromium, both pairs of runs: no page errors.

Risk

Every Compare chart's tick labels. A chart axis can show more decimals than the table ($0.018, 1.05k), and a rate or token axis can have fewer ticks than before. A unit missing from the axis table falls back to plain numbers. Undone by a revert.

nice_ticks padded a single value both ways, so an axis of zeros ran from -1 to 1, and a cost axis mixed $-1.0000 with $1.00. A zero now gets 0 to 1; the bars' own special case for it goes.
…, inside the metric's range

A tick label used the value formatter, so labels repeated after rounding ($0.02 five times), changed precision or unit within an axis (0 $0.0025 $0.01, 500 beside 1.0k, 30s 1m 2m) and the origin read a bare 0. An axis now picks one unit from its largest tick and the decimals its step needs in that unit. A rate's axis keeps to 0 to 100%: one value at a bound pads inwards only.
… and tokens in the fewest

The origin keeps its unit and drops its decimals ($0, 0k, 0%, 0m). A rate or token axis whose step needs a decimal more than twice the step doubles it, so all rates of 100% read 90% 95% 100% and tokens 1000 and 1100 read 1.00k 1.05k 1.10k.
@harenome
harenome merged commit e3bc760 into ThinkFlowLab:main Nov 24, 2026
2 checks passed
@harenome
harenome deleted the fix/chart-zero-axis branch November 24, 2026 15:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compare chart: axes leave their metric's range and tick labels repeat or change format within an axis

1 participant