-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Improve UX reducing timeseries tooltip to max 5 items #7046
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
base: master
Are you sure you want to change the base?
Improve UX reducing timeseries tooltip to max 5 items #7046
Conversation
…en multiple versions
… and future versions of typescript.
| spyOn(store, 'dispatch').and.callFake(((action: Action) => { | ||
| dispatchedActions.push(action); | ||
| }); | ||
| }) as any); |
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.
I think this is to suppress the errors we were getting internally, but this looks like a hack, rather than a proper solution.
Do we know why this is necessary? If so, at least adding comments to clarify would be useful.
| scalarTooltipData[minIndex].metadata.closest = true; | ||
| } | ||
|
|
||
| let sortedData: ScalarTooltipDatum[]; |
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.
The sort method sorts the data in place, so I don't think we need this additional array, and it could be a bit misleading.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort
| @ViewChild('dataTableContainer') | ||
| dataTableContainer?: ElementRef; | ||
|
|
||
| readonly MAX_TOOLTIP_ITEMS = 5; |
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.
nit: could this be just a top-level constant, instead of being defined inside this class?
| break; | ||
| } | ||
|
|
||
| this.tooltipTotalCount = sortedData.length; |
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.
nit/optional: Instead of keeping the total count and separately the getter below, consider simply storing the "additional items" and use it directly.
| tooltipDataForTesting, | ||
| cursorLocationInDataCoordForTesting, | ||
| cursorLocationForTesting | ||
| tooltipData, |
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.
To be honest, I don't quite understand what they were doing here. I don't know why these "test" components are reimplementing a good part of what the component is doing, but this seems like it's not testing the components following best practices.
I think this is just testing that the tooltip template can be specified from outside the component, but then it's not really testing the behavior of the actual tooltip, but the behavior of the "test implementation" (?).
Since this is old code, I'm ok not cleaning this up, but I also don't think there's much point in making changes here if we believe it's kind of weird. (Or perhaps you have a better understanding of the way they're testing this).
I suggest we revert these changes. If you'd like to add tests, we can add separate tests, that are better set up, but also ok omitting tests for this tooltip change. We have internal screen-diff tests that could be sufficient.
Having said that, since you already did all this work, if you prefer to keep what you have, I guess it's fine.
Motivation for features / changes
Limits tooltip display to 5 items and adds a legend indicating additional items when there are more than 5 series.
This prevents tooltips from becoming too large and improves readability and usability when many series are present.
Technical description of changes
Screenshots of UI changes
Detailed steps to verify changes work correctly
bazel test //tensorboard/webapp:karma_test_chromium-local