Skip to content
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

feat(dashboards): Improve duration Y axis label formatting #83337

Merged
merged 6 commits into from
Jan 14, 2025

Conversation

gggritso
Copy link
Member

Temporarily (while I keep working on the refactor) adds yet again duration formatter, this time for Y axis label values. I'm towards a setup where the formatting helpers don't allow arbitrary arguments for how many decimal places to show, but rather there are helper per context. A duration can be formatted for a Y axis, for a tooltip, for a table, etc.

This new formatYAxisDuration is a step in that direction. It improves Y axis labels by side-stepping some weird cases. The current approach is:

  1. Load the timeseries. Give it to ECharts, let it decide how many ticks there are
  2. Figure out the bounds of the dataset. Based on the bounds, choose a single appropriate unit (e.g., "millisecond"). Try to guess how many ticks ECharts will have, and possibly adjust
  3. When formatting Y axis labels, always use that specific unit, always use 0 decimal places

This causes a lot of weirdness. For example, if the range is narrow (e.g., between 10ms and 12ms) ECharts might make 4 ticks, but we only format 1 decimal place. The ticks are 1, 1, 2, 2. Gross. Or, If the range is wide (e.g., between 0ms and 12 years) we'll have ticks like 600d 900d etc.

Instead:

  1. Load the timeseries. Give it to ECharts, and let it decide how many ticks there are
  2. For every tick on the Y axis, figure out the appropriate unit, and format using the current locale
  3. Add support for shorter and longer units. Down to the microsecond, up to the year

This covers a lot of the edge cases, removes a lot of complexity.

@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Jan 13, 2025
Copy link

codecov bot commented Jan 13, 2025

Bundle Report

Changes will increase total bundle size by 1.26kB (0.0%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
app-webpack-bundle-array-push 31.0MB 1.26kB (0.0%) ⬆️

This comment was marked as outdated.

@gggritso gggritso marked this pull request as ready for review January 13, 2025 21:49
@gggritso gggritso requested review from a team as code owners January 13, 2025 21:49
Copy link
Member

@nikkikapadia nikkikapadia left a comment

Choose a reason for hiding this comment

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

lgtm 👍

@gggritso gggritso merged commit 18740fe into master Jan 14, 2025
42 checks passed
@gggritso gggritso deleted the feat/dashboards/impro-ve-y-axis-duration-formatting branch January 14, 2025 19:02
andrewshie-sentry pushed a commit that referenced this pull request Jan 22, 2025
Temporarily (while I keep working on the refactor) adds yet again
duration formatter, this time for Y axis label values. I'm towards a
setup where the formatting helpers don't allow arbitrary arguments for
how many decimal places to show, but rather there are helper _per
context_. A duration can be formatted for a Y axis, for a tooltip, for a
table, etc.

This new `formatYAxisDuration` is a step in that direction. It improves
Y axis labels by side-stepping some weird cases. The current approach
is:

1. Load the timeseries. Give it to ECharts, let it decide how many ticks
there are
2. Figure out the bounds of the dataset. Based on the bounds, choose a
single appropriate unit (e.g., "millisecond"). Try to guess how many
ticks ECharts will have, and possibly adjust
3. When formatting Y axis labels, always use that specific unit, always
use 0 decimal places

This causes a _lot_ of weirdness. For example, if the range is narrow
(e.g., between 10ms and 12ms) ECharts might make 4 ticks, but we only
format 1 decimal place. The ticks are 1, 1, 2, 2. Gross. Or, If the
range is wide (e.g., between 0ms and 12 years) we'll have ticks like
600d 900d etc.

Instead:

1. Load the timeseries. Give it to ECharts, and let it decide how many
ticks there are
2. For every tick on the Y axis, figure out the appropriate unit, and
format using the current locale
3. Add support for shorter and longer units. Down to the microsecond, up
to the year

This covers a lot of the edge cases, removes a lot of complexity.
@github-actions github-actions bot locked and limited conversation to collaborators Jan 30, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Scope: Frontend Automatically applied to PRs that change frontend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants