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

Feature: Allow tooltip sorting by X, Y, and Pixel distance from cursor #6116

Merged
merged 6 commits into from
Jan 10, 2023

Conversation

rileyajones
Copy link
Contributor

@rileyajones rileyajones commented Dec 27, 2022

Tests coming soon

Motivation for features / changes

#5854
The scalars dashboard handled the "nearest" value displayed in the tooltip differently than the time series dashboard and some users prefer that.

Technical description of changes

  • Add three new types to the TooltipSort enum
  • Because tooltip sorting is a persisted setting I have moved the type declaration to the persistent settings types. This prevents a dependency cycle and allows direct typing of the persisted settings object thus removing the need to manually deserialize it.
  • Pipe the cursor position relative to the chart through from the line_chart_interactive_view to the scalar_card_component

Screenshots of UI changes

New tooltip options in settings menu
image

All of these screenshots have my cursor at the top right of the chart.

Nearest (Before):
image

Nearest Pixel (After):
image

Nearest Y:
image

Detailed steps to verify changes work correctly (as executed by you)

I could only test this using internal tensorboard. For those looking to follow along start tensorboard with this PR merged in (e.g. cl/498013225) and check this experiment 3630455328016159781

@rileyajones rileyajones marked this pull request as ready for review December 27, 2022 20:41
@rileyajones rileyajones requested review from bmd3k and removed request for bmd3k December 27, 2022 22:34
@@ -2359,7 +2359,7 @@ describe('metrics reducers', () => {
globalSettingsLoaded({
partialSettings: {
ignoreOutliers: true,
tooltipSortString: 'descending',
tooltipSortString: 'descending' as TooltipSort,
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you just use TooltipSort.DESCENDING?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We can but, because the test is testing deserialization from browser storage, I prefer testing the string literal.

Copy link
Contributor

Choose a reason for hiding this comment

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

The reasoning doesn't seem to apply here.

At this point in the code you are several layers removed from the serialized form. The only serialized form of the string exists in LocalStorage. The type globalSettingsLoaded says it will include a TooltipSort object, so that is the ideal type to use for the test.

@@ -68,6 +68,7 @@ export interface TooltipDatum<
metadata: Metadata;
closestPointIndex: number;
point: PointDatum;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we get some consistency in naming to make the code clearer?

point and cursorLocationInDataCoord live in the same space but that's not clear.
pixelLocation and cursorLocation live in the same space but that's not clear.

Maybe instead:
pointInDataCoord and cursorInDataCoord and
pointInPixelCoord and cusorInPixelCoord?

Or maybe:
dataPoint and dataCursorLocation and
pixelPoint and pixelCursorLocation.

Another point of reference for naming is the quartet of functions getDomX, getDomY, getDataX, getDataY.

So that suggests:
dataPoint and dataCursorLocation and
domPoint and domCursorLocation.

@@ -311,7 +316,7 @@ describe('persistent_settings data_source test', () => {

expect(actual).toEqual({
scalarSmoothing: 0.5,
tooltipSortString: 'default',
tooltipSortString: 'default' as TooltipSort,
Copy link
Contributor

Choose a reason for hiding this comment

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

Use TooltipSort.DEFAULT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Because the test is testing deserialization from browser storage, I prefer testing the string literal.

Copy link
Contributor

Choose a reason for hiding this comment

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

Very similar to my other response: The only serialized form of the string exists in LocalStorage. The contract of dataSource.getSettings() says it will return a TooltipSort object, so that seems to be the type you should use for the test.

I think the reasoning you are using would apply to setSettings() tests but it doesn't really apply to getSettings() tests.

tensorboard/webapp/metrics/store/metrics_reducers.ts Outdated Show resolved Hide resolved
@@ -119,7 +119,8 @@
<ng-template
#tooltip
let-tooltipData="data"
let-cursorLoc="cursorLocationInDataCoord"
let-cursorLocationInDataCoord="cursorLocationInDataCoord"
Copy link
Contributor

Choose a reason for hiding this comment

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

Whatever names you choose line_chart_interactive_view.ts, please mirror here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

These names all look the same to me? Am I missing something? (of note, they were not the same before and I renamed them to be the same).

Copy link
Contributor

Choose a reason for hiding this comment

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

There was another comment I left about naming inconsistency, which does not seem to have been addressed. Do you mind taking a look at that one and then revisiting this one? I assume this comment doesn't make sense to you because you missed the other comment.

@@ -136,7 +137,7 @@
<tbody>
<ng-container
*ngFor="
let datum of getCursorAwareTooltipData(tooltipData, cursorLoc);
let datum of getCursorAwareTooltipData(tooltipData, cursorLocationInDataCoord, cursorLocation);
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: Can this be line wrapped?

@rileyajones rileyajones force-pushed the nearest-pixel branch 2 times, most recently from e3866e2 to b58dc0e Compare January 6, 2023 20:06
@@ -2359,7 +2359,7 @@ describe('metrics reducers', () => {
globalSettingsLoaded({
partialSettings: {
ignoreOutliers: true,
tooltipSortString: 'descending',
tooltipSortString: 'descending' as TooltipSort,
Copy link
Contributor

Choose a reason for hiding this comment

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

The reasoning doesn't seem to apply here.

At this point in the code you are several layers removed from the serialized form. The only serialized form of the string exists in LocalStorage. The type globalSettingsLoaded says it will include a TooltipSort object, so that is the ideal type to use for the test.

@@ -119,7 +119,8 @@
<ng-template
#tooltip
let-tooltipData="data"
let-cursorLoc="cursorLocationInDataCoord"
let-cursorLocationInDataCoord="cursorLocationInDataCoord"
Copy link
Contributor

Choose a reason for hiding this comment

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

There was another comment I left about naming inconsistency, which does not seem to have been addressed. Do you mind taking a look at that one and then revisiting this one? I assume this comment doesn't make sense to you because you missed the other comment.

@@ -311,7 +316,7 @@ describe('persistent_settings data_source test', () => {

expect(actual).toEqual({
scalarSmoothing: 0.5,
tooltipSortString: 'default',
tooltipSortString: 'default' as TooltipSort,
Copy link
Contributor

Choose a reason for hiding this comment

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

Very similar to my other response: The only serialized form of the string exists in LocalStorage. The contract of dataSource.getSettings() says it will return a TooltipSort object, so that seems to be the type you should use for the test.

I think the reasoning you are using would apply to setSettings() tests but it doesn't really apply to getSettings() tests.

WORKSPACE Outdated Show resolved Hide resolved
@@ -13,3 +13,16 @@ See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
export * from './internal_types';

// When adding a new value to the enum, please implement the deserializer on
Copy link
Contributor

Choose a reason for hiding this comment

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

To be honest, I didn't realize that types is just reexporting internal_types. That's odd.

Maybe (as a followup PR, please not in this one) we should just get rid of internal_types and move everything into this file. The indirection is unnecessary and we shouldn't fool ourselves into thinking anything in internal_types is actually internal.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

+1 that totally makes sense as a followup

@bmd3k
Copy link
Contributor

bmd3k commented Jan 9, 2023

Also, please update the PR description. You have tests now and you aren't supporting 'Nearest X' for example.

@rileyajones rileyajones merged commit 183ff2b into tensorflow:master Jan 10, 2023
yatbear pushed a commit to yatbear/tensorboard that referenced this pull request Mar 27, 2023
tensorflow#6116)

~Tests coming soon~

## Motivation for features / changes
tensorflow#5854
The scalars dashboard handled the "nearest" value displayed in the
tooltip differently than the time series dashboard and some users prefer
that.

## Technical description of changes
* Add three new types to the `TooltipSort` enum
* Because tooltip sorting is a persisted setting I have moved the type
declaration to the persistent settings types. This prevents a dependency
cycle and allows direct typing of the persisted settings object thus
removing the need to manually deserialize it.
* Pipe the cursor position relative to the chart through from the
`line_chart_interactive_view` to the `scalar_card_component`

## Screenshots of UI changes
New tooltip options in settings menu

![image](https://user-images.githubusercontent.com/78179109/210456117-a5932e11-3796-4298-ad9f-79c582286fa8.png)

All of these screenshots have my cursor at the top right of the chart.

Nearest (Before):

![image](https://user-images.githubusercontent.com/78179109/209720008-6a16d19b-64d6-40c3-8ce5-b94cc3ef455e.png)

Nearest Pixel (After):

![image](https://user-images.githubusercontent.com/78179109/210456192-fb9a54e5-3239-492d-8987-862a4a142659.png)

Nearest Y:

![image](https://user-images.githubusercontent.com/78179109/209719876-29779bde-3dc5-474f-a5d3-831fc3b068d5.png)

## Detailed steps to verify changes work correctly (as executed by you)
I could only test this using internal tensorboard. For those looking to
follow along start tensorboard with this PR merged in (e.g.
cl/498013225) and check this experiment `3630455328016159781`
dna2github pushed a commit to dna2fork/tensorboard that referenced this pull request May 1, 2023
tensorflow#6116)

~Tests coming soon~

## Motivation for features / changes
tensorflow#5854
The scalars dashboard handled the "nearest" value displayed in the
tooltip differently than the time series dashboard and some users prefer
that.

## Technical description of changes
* Add three new types to the `TooltipSort` enum
* Because tooltip sorting is a persisted setting I have moved the type
declaration to the persistent settings types. This prevents a dependency
cycle and allows direct typing of the persisted settings object thus
removing the need to manually deserialize it.
* Pipe the cursor position relative to the chart through from the
`line_chart_interactive_view` to the `scalar_card_component`

## Screenshots of UI changes
New tooltip options in settings menu

![image](https://user-images.githubusercontent.com/78179109/210456117-a5932e11-3796-4298-ad9f-79c582286fa8.png)

All of these screenshots have my cursor at the top right of the chart.

Nearest (Before):

![image](https://user-images.githubusercontent.com/78179109/209720008-6a16d19b-64d6-40c3-8ce5-b94cc3ef455e.png)

Nearest Pixel (After):

![image](https://user-images.githubusercontent.com/78179109/210456192-fb9a54e5-3239-492d-8987-862a4a142659.png)

Nearest Y:

![image](https://user-images.githubusercontent.com/78179109/209719876-29779bde-3dc5-474f-a5d3-831fc3b068d5.png)

## Detailed steps to verify changes work correctly (as executed by you)
I could only test this using internal tensorboard. For those looking to
follow along start tensorboard with this PR merged in (e.g.
cl/498013225) and check this experiment `3630455328016159781`
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.

2 participants