Skip to content

fix(trading): keep price chart y-axis labels distinct - #180

Open
RaphaelFakhri wants to merge 1 commit into
callstack:mainfrom
RaphaelFakhri:fix/chart-axis-labels
Open

RaphaelFakhri wants to merge 1 commit into
callstack:mainfrom
RaphaelFakhri:fix/chart-axis-labels

Conversation

@RaphaelFakhri

Copy link
Copy Markdown

Summary

The price chart on the asset details screen formats y-axis ticks with a fixed precision: one decimal of thousands above $1,000 and whole dollars above $1. The chart shows the last 60 one-minute closes, so the y-axis range is usually narrow, and victory-native picks ticks closer together than that precision can show. Several ticks then get the same label, for example:

Asset Ticks Labels before Labels after
ETH 3865, 3870, 3875, 3880 $3.9k $3.9k $3.9k $3.9k $3.865k $3.87k $3.875k $3.88k
SOL 176.5, 177, 177.5, 178 $177 $177 $178 $178 $176.5 $177 $177.5 $178
XRP 2.31, 2.32, 2.33 $2 $2 $2 $2.31 $2.32 $2.33

This change moves the formatter into a formatAxisPrice helper next to formatPrice in the SDK. The helper keeps the k suffix and the $ prefix, but uses maximumFractionDigits instead of toFixed, so each tick keeps its significant digits without padding zeros.

Test plan

  • Added packages/host/src/__tests__/formatAxisPrice-test.ts, which checks that tick sequences for each price range get distinct labels. With the previous formatting logic, 4 of 5 cases fail. With this change, all 5 pass.
  • pnpm test, pnpm lint, pnpm typecheck and pnpm format:check pass.
  • To check manually, open the details screen for ETH, SOL or XRP and confirm that the y-axis labels differ from each other.

Fixes #179

This branch has not been deployed

No deployments
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.

Price chart y-axis shows the same label on several ticks

1 participant