Skip to content

Commit 73820fa

Browse files
authored
Tooltip settings input - default value to 5 (#7135)
## Motivation for features / changes Added TOOLTIP_ROWS_LIMIT_DEFAULT = 5 constant to internal_types.ts and replaced the inline 5 in METRICS_SETTINGS_DEFAULT with it. Full details: #7133
1 parent 0bafbe7 commit 73820fa

3 files changed

Lines changed: 30 additions & 2 deletions

File tree

tensorboard/webapp/metrics/internal_types.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,6 @@ export const SCALARS_SMOOTHING_MAX = 0.999;
109109

110110
/** Minimum value for the input: tooltip rows limit setting. */
111111
export const TOOLTIP_ROWS_LIMIT_MIN = 1;
112+
113+
/** Default number of rows shown in the tooltip when limiting is enabled. */
114+
export const TOOLTIP_ROWS_LIMIT_DEFAULT = 5;

tensorboard/webapp/metrics/store/metrics_reducers_test.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,11 @@ import {
4646
HistogramMode,
4747
MinMaxStep,
4848
NonPinnedCardId,
49+
TOOLTIP_ROWS_LIMIT_DEFAULT,
4950
TooltipSort,
5051
XAxisType,
5152
} from '../types';
53+
import {METRICS_SETTINGS_DEFAULT} from './metrics_types';
5254
import {ColumnHeaderType, DataTableMode} from '../../widgets/data_table/types';
5355
import {reducers} from './metrics_reducers';
5456
import {getCardId, getPinnedCardId} from './metrics_store_internal_utils';
@@ -1034,6 +1036,29 @@ describe('metrics reducers', () => {
10341036
expect(nextState.settingOverrides.ignoreOutliers).toBe(false);
10351037
});
10361038

1039+
it('uses TOOLTIP_ROWS_LIMIT_DEFAULT as the default tooltipRowsLimit', () => {
1040+
expect(METRICS_SETTINGS_DEFAULT.tooltipRowsLimit).toBe(
1041+
TOOLTIP_ROWS_LIMIT_DEFAULT
1042+
);
1043+
});
1044+
1045+
it('updates tooltipRowsLimit on metricsChangeTooltipRowsLimit', () => {
1046+
const prevState = buildMetricsState({
1047+
settings: buildMetricsSettingsState({
1048+
tooltipRowsLimit: TOOLTIP_ROWS_LIMIT_DEFAULT,
1049+
}),
1050+
settingOverrides: {},
1051+
});
1052+
const nextState = reducers(
1053+
prevState,
1054+
actions.metricsChangeTooltipRowsLimit({tooltipRowsLimit: 10})
1055+
);
1056+
expect(nextState.settings.tooltipRowsLimit).toBe(
1057+
TOOLTIP_ROWS_LIMIT_DEFAULT
1058+
);
1059+
expect(nextState.settingOverrides.tooltipRowsLimit).toBe(10);
1060+
});
1061+
10371062
it('changes xAxisType on metricsChangeXAxisType', () => {
10381063
const prevState = buildMetricsState({
10391064
settings: buildMetricsSettingsState({

tensorboard/webapp/metrics/store/metrics_types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ import {
3535
NonPinnedCardId,
3636
PinnedCardId,
3737
TimeSelection,
38-
TOOLTIP_ROWS_LIMIT_MIN,
38+
TOOLTIP_ROWS_LIMIT_DEFAULT,
3939
TooltipSort,
4040
XAxisType,
4141
} from '../types';
@@ -296,7 +296,7 @@ export const METRICS_SETTINGS_DEFAULT: MetricsSettings = {
296296
scalarSmoothing: 0.6,
297297
scalarPartitionNonMonotonicX: false,
298298
isTooltipRowsLimitEnabled: false,
299-
tooltipRowsLimit: TOOLTIP_ROWS_LIMIT_MIN,
299+
tooltipRowsLimit: TOOLTIP_ROWS_LIMIT_DEFAULT,
300300
imageBrightnessInMilli: 1000,
301301
imageContrastInMilli: 1000,
302302
imageShowActualSize: false,

0 commit comments

Comments
 (0)