Repository navigation
Respect configured mantissa on time chart Y-axis tick labels #3030
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
af43e69
Respect configured mantissa on time chart Y-axis tick labels
arj22 75c2cb8
Add changeset for axis tick mantissa fix
arj22 6d0bbf9
Merge branch 'main' into fix/axis-tick-mantissa
MikeShi42 15881f5
Cap honored axis mantissa at 2 decimal places
arj22 7a7183f
Merge remote-tracking branch 'origin/fix/axis-tick-mantissa' into fix…
arj22 5213f40
Merge branch 'main' into fix/axis-tick-mantissa
arj22 4f54359
Make axis mantissa magnitude-aware: 0 for ticks >= 1, capped otherwise
arj22 609caf6
Merge remote-tracking branch 'origin/fix/axis-tick-mantissa' into fix…
arj22 e307b6a
Fix percent scaling and zero-tick regressions; raise threshold to 10
arj22 e419ce9
Merge branch 'main' into fix/axis-tick-mantissa
arj22 aca43a9
Merge branch 'main' into fix/axis-tick-mantissa
pulpdrew File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| --- | ||
| "@hyperdx/app": patch | ||
| "@hyperdx/cli": patch | ||
| --- | ||
|
|
||
| fix(charts): show decimals on Y-axis ticks under 10 in magnitude | ||
|
|
||
| The Y-axis of a time series chart (and the CLI's termchart equivalent) | ||
| always rounded tick labels to 0 decimal places, regardless of the chart's | ||
| Number Format settings. Charts whose values live under 1 (fractional | ||
| gauges, ratios, sub-1 rates) rendered every axis tick as `0` even though | ||
| the tooltip and legend showed the correct value. | ||
|
|
||
| A tick under 10 in magnitude (as displayed - a percent tick's magnitude is | ||
| checked against its ×100 value, not its raw 0-1 ratio) now honors the | ||
| chart's configured decimals, capped at 2 to keep the label within the | ||
| axis's fixed width. A tick of 10 or more, and a tick of exactly 0, stay | ||
| integers exactly as before, whatever the chart's Number Format configures | ||
| - so ordinary counts and the byte/percent tiles in the bundled dashboard | ||
| templates are unaffected. |
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| import { describe, expect, it } from '@jest/globals'; | ||
|
|
||
| import { axisTickFormatter } from '@/shared/formatNumber'; | ||
|
|
||
| // Mirrors packages/app/src/__tests__/HDXMultiSeriesTimeChart.test.ts's | ||
| // formatAxisTick suite - this file is a documented @source port of that | ||
| // function (see formatNumber.ts's axisTickFormatter docblock) and is | ||
| // expected to stay behaviorally in sync with it. | ||
| describe('axisTickFormatter', () => { | ||
| it('returns undefined when the chart has no number format', () => { | ||
| expect(axisTickFormatter(undefined)).toBeUndefined(); | ||
| }); | ||
|
|
||
| it('falls back to mantissa 0 when the format has none configured', () => { | ||
| const format = axisTickFormatter({ output: 'number' }); | ||
| expect(format?.(1234)).toBe('1k'); | ||
| }); | ||
|
|
||
| it('honors an explicit mantissa for a tick under the magnitude threshold', () => { | ||
| const format = axisTickFormatter({ output: 'number', mantissa: 2 }); | ||
| expect(format?.(0.14)).toBe('0.14'); | ||
| }); | ||
|
|
||
| it('caps a small tick`s mantissa at 2 instead of honoring it outright', () => { | ||
| const format = axisTickFormatter({ output: 'number', mantissa: 10 }); | ||
| expect(format?.(0.14)).toBe('0.14'); | ||
| }); | ||
|
|
||
| it('forces 0 decimals for any tick >= 10, regardless of configured mantissa', () => { | ||
| const format = axisTickFormatter({ output: 'number', mantissa: 2 }); | ||
| expect(format?.(200)).toBe('200'); | ||
| expect(format?.(10)).toBe('10'); | ||
| expect(format?.(-15)).toBe('-15'); | ||
| }); | ||
|
|
||
| it('honors configured mantissa up to 9.99 in magnitude, positive or negative', () => { | ||
| const format = axisTickFormatter({ output: 'number', mantissa: 2 }); | ||
| expect(format?.(9.99)).toBe('9.99'); | ||
| expect(format?.(-1.5)).toBe('-1.50'); | ||
| }); | ||
|
|
||
| it('always renders exactly 0 as a bare integer', () => { | ||
| expect(axisTickFormatter({ output: 'number', mantissa: 2 })?.(0)).toBe('0'); | ||
| expect(axisTickFormatter({ output: 'byte', mantissa: 1 })?.(0)).toBe('0 B'); | ||
| }); | ||
|
|
||
| it('checks a percent tick`s magnitude against its displayed (x100) value', () => { | ||
| const format = axisTickFormatter({ output: 'percent', mantissa: 2 }); | ||
| expect(format?.(0.25)).toBe('25%'); | ||
| expect(format?.(0.001)).toBe('0.10%'); | ||
| }); | ||
|
|
||
| it('preserves shipped byte/throughput tiles that configure a mantissa', () => { | ||
| expect( | ||
| axisTickFormatter({ output: 'byte', mantissa: 1 })?.(268435456), | ||
| ).toBe('256 MB'); | ||
| expect( | ||
| axisTickFormatter({ output: 'throughput', mantissa: 2 })?.(1234567), | ||
| ).toBe('1234567'); | ||
| }); | ||
| }); |
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.