-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Adds specialized formatter to histogram component. #5818
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
if (absNum >= LARGE_NUMBER){ | ||
return d3LargeFormatter(x); | ||
} | ||
if (absNum < SMALL_NUMBER){ | ||
return d3SmallFormatter(x); | ||
} | ||
return d3MiddleFormatter(x); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very nitpicky but it's a little strange that this is ordered LARGE_NUMBER
, SMALL_NUMBER
, MEDIUM_NUMBER
.
Perhaps consider gating around a series minimums.
if (absNum >= LARGE_NUMBER){ | |
return d3LargeFormatter(x); | |
} | |
if (absNum < SMALL_NUMBER){ | |
return d3SmallFormatter(x); | |
} | |
return d3MiddleFormatter(x); | |
if (absNum >= LARGE_NUMBER){ | |
return d3LargeFormatter(x); | |
} | |
if (absNum >= SMALL_NUMBER){ | |
return d3MiddleFormatter(x); | |
} | |
return d3SmallFormatter(x); |
If taking this suggestion you might also consider renaming SMALL_NUMBER
to MEDIUM_NUMBER
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add some tests if it is reasonable to do.
Factored out the formatter and added tests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A little late but LGTM. Thanks!
Motivation for features / changes
Using SI notation for histogram bins smaller than 1 causes confusion. '500m' can mean many things, not just '0.5'. Googlers see b/238492397
Technical description of changes
Replaces tick formatter with a 3 way switch. SI notation for small values, Exponential notation for large values, and natural notation for middle values.
Screenshots of UI changes
before:
after:
Detailed steps to verify changes work correctly (as executed by you)
Ran TensorBoard standalone locally and compared across a very wide range of histogram bin bucket sizes.
Alternate designs / implementations considered
It may be possible to update tensorboard/webapp/widgets/histogram/histogram_component.ts and re-use formatters from there. Did not pursue as it would require extra customization there, and this was deemed sufficiently clear.