Skip to content

ui: add custom range option to counter track display menu#5222

Open
Vikx001 wants to merge 1 commit intogoogle:mainfrom
Vikx001:dev/vikashsharma/counter-track-custom-range
Open

ui: add custom range option to counter track display menu#5222
Vikx001 wants to merge 1 commit intogoogle:mainfrom
Vikx001:dev/vikashsharma/counter-track-custom-range

Conversation

@Vikx001
Copy link
Contributor

@Vikx001 Vikx001 commented Mar 21, 2026

Fixes #4441

When comparing counter tracks between two runs, users need a fixed Y-axis range so both tracks are visually comparable. The existing modes (Zero-based, Min/Max, Log) all derive the range from the data, making cross-run comparison difficult.

Changes

Add a custom Y display mode to the Display submenu with inline Min/Max text inputs. Either field can be left blank to fall back to the data-derived bound for that side. Rounding is skipped for custom values to honour the user-specified exact bounds. A yMax <= yMin guard prevents division-by-zero in the renderer.

Files changed

  • base_counter_track.ts — new custom yDisplay mode, yCustomMin/yCustomMax fields in CounterOptions, updated computeYRange() and both menu rendering paths (context menu + bulk settings descriptor)
  • base_counter_track.scss (new) — styles for the inline custom range inputs
  • perfetto.scss — imports the new stylesheet

@Vikx001 Vikx001 requested a review from a team as a code owner March 21, 2026 06:43
@Vikx001 Vikx001 force-pushed the dev/vikashsharma/counter-track-custom-range branch 2 times, most recently from 911bfda to 9838368 Compare March 22, 2026 08:32
Copy link
Member

@stevegolton stevegolton left a comment

Choose a reason for hiding this comment

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

Looks like a good first attempt, but there are quite a few rough edges.

  • The text on the y axis should indicate the scale of the counter rather than just reading 'custom'.
  • We need to consider how to make it easier to enter very small or very large values.
  • I seemed to encounter a bug while trying to enter a decimal value, though I have been seeing some bugs in the counter track's settings recently so that might be related to that.
Image

.pf-counter-track {
&__custom-range {
display: flex;
align-items: center;
Copy link
Member

Choose a reason for hiding this comment

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

Please use align-items: baseline with widgets - this will make sure to align the base line of the text in each field.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh yeah ! fixed it now Switched to baseline so the text labels and input fields sit on the same line visually.

gap: 4px;
padding: 4px 8px;
font-family: var(--pf-font-compact);
font-size: var(--pf-font-size-m);
Copy link
Member

Choose a reason for hiding this comment

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

I suspect font-family and font-size can be inherited from the parent menu and thus emitted here, but could be wrong.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, they do get inherited from the parent menu so I removed both.
Verified it still looks correct without them.

Adds a 'Custom Range' mode to the counter track's Display submenu,
letting users specify exact min/max values for the Y axis. This is
useful when comparing counter tracks across different trace files,
where using the same fixed range makes values directly comparable.

When 'Custom Range' is selected, two numeric text inputs appear
inline in the submenu for min and max. Either field can be left
blank to fall back to the data-derived bound for that side. Rounding
is skipped for custom ranges to honour the user-specified values.
A yMax <= yMin guard prevents division-by-zero in the renderer.

Fixes: google#4441

Address review feedback:
- Use type=text instead of type=number so the browser does not suppress
  the change event while typing a decimal (e.g. "1."), and to allow
  scientific notation (1e-9, 2.5e10) for very small or large values;
  parseFloat handles all valid JS numeric strings correctly.
- Remove hardcoded yLabel="custom"; fall through to the existing
  toLabel(max-min) path so the y-axis shows a human-readable scale
  (e.g. "50K", "2G") consistent with all other display modes.
- Use align-items:baseline in the custom-range row so label text and
  input text share the same baseline.
- Remove font-family/font-size from SCSS as they are inherited from
  the parent menu.
@Vikx001 Vikx001 force-pushed the dev/vikashsharma/counter-track-custom-range branch from 9838368 to 42aff4a Compare March 23, 2026 18:58
@Vikx001
Copy link
Contributor Author

Vikx001 commented Mar 23, 2026

Thanks for the detailed review @stevegolton! Addressed all three points:

image

1. Y-axis label
Removed the hardcoded 'custom' string so it falls through to the existing
toLabel(max - min) path, same as all other display modes. Now shows a
human-readable scale like 50K or 2G based on the actual custom bounds.

2. Very small/large values
Switched the inputs from type="number" to type="text" so users can type
scientific notation like 1e-9 or 2.5e10. parseFloat handles all of
these correctly.

3. Decimal entry bug
Turned out to be caused by the same type="number" issue. The browser
suppresses the change event when the input string isn't a valid number yet
(e.g. mid-typing "1."), which caused the field to reset. Switching to
type="text" fixes this since the raw string is always passed through on
blur/Enter.

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.

Add "Custom Range" option to the Counter Track graph Display submenu

2 participants