-
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
Feature: Allow tooltip sorting by X, Y, and Pixel distance from cursor #6116
Conversation
tensorboard/webapp/metrics/views/card_renderer/scalar_card_component.ts
Outdated
Show resolved
Hide resolved
tensorboard/webapp/metrics/views/card_renderer/scalar_card_component.ts
Outdated
Show resolved
Hide resolved
tensorboard/webapp/metrics/views/card_renderer/scalar_card_component.ts
Outdated
Show resolved
Hide resolved
1040678
to
eb5123d
Compare
@@ -2359,7 +2359,7 @@ describe('metrics reducers', () => { | |||
globalSettingsLoaded({ | |||
partialSettings: { | |||
ignoreOutliers: true, | |||
tooltipSortString: 'descending', | |||
tooltipSortString: 'descending' as TooltipSort, |
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.
Can you just use TooltipSort.DESCENDING?
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.
We can but, because the test is testing deserialization from browser storage, I prefer testing the string literal.
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 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; |
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.
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, |
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.
Use TooltipSort.DEFAULT?
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.
Because the test is testing deserialization from browser storage, I prefer testing the string literal.
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.
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.
@@ -119,7 +119,8 @@ | |||
<ng-template | |||
#tooltip | |||
let-tooltipData="data" | |||
let-cursorLoc="cursorLocationInDataCoord" | |||
let-cursorLocationInDataCoord="cursorLocationInDataCoord" |
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.
Whatever names you choose line_chart_interactive_view.ts, please mirror here.
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.
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).
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.
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); |
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: Can this be line wrapped?
tensorboard/webapp/metrics/views/card_renderer/scalar_card_component.ts
Outdated
Show resolved
Hide resolved
e3866e2
to
b58dc0e
Compare
b58dc0e
to
e3ce6e7
Compare
@@ -2359,7 +2359,7 @@ describe('metrics reducers', () => { | |||
globalSettingsLoaded({ | |||
partialSettings: { | |||
ignoreOutliers: true, | |||
tooltipSortString: 'descending', | |||
tooltipSortString: 'descending' as TooltipSort, |
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 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" |
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.
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, |
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.
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.
@@ -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 |
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 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.
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.
+1 that totally makes sense as a followup
tensorboard/webapp/metrics/views/card_renderer/scalar_card_component.ts
Outdated
Show resolved
Hide resolved
tensorboard/webapp/metrics/views/card_renderer/scalar_card_test.ts
Outdated
Show resolved
Hide resolved
Also, please update the PR description. You have tests now and you aren't supporting 'Nearest X' for example. |
edf5e19
to
6d27028
Compare
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`
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`
Tests coming soonMotivation 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
TooltipSort
enumline_chart_interactive_view
to thescalar_card_component
Screenshots of UI changes
New tooltip options in settings menu
All of these screenshots have my cursor at the top right of the chart.
Nearest (Before):
Nearest Pixel (After):
Nearest Y:
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