Skip to content

Commit 80241bd

Browse files
authored
linked time: create listen area for fob and set step to null on mouseleave (#6004)
On mouse hovering the axis, we want to show the prospective fob. On mouse leaving, we want to remove the fob. This PR creates that element and implement the mouse leaving part.
1 parent d9c2cc1 commit 80241bd

File tree

5 files changed

+60
-0
lines changed

5 files changed

+60
-0
lines changed

tensorboard/webapp/metrics/views/card_renderer/scalar_card_fob_controller.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ import {MinMaxStep} from './scalar_card_types';
4141
[isProspectiveFobFeatureEnabled]="isProspectiveFobFeatureEnabled"
4242
[cardFobHelper]="cardFobHelper"
4343
[showExtendedLine]="true"
44+
(onPrespectiveStepChanged)="onPrespectiveStepChanged($event)"
4445
(onTimeSelectionChanged)="onTimeSelectionChanged.emit($event)"
4546
(onTimeSelectionToggled)="onTimeSelectionToggled.emit($event)"
4647
></card-fob-controller>
@@ -102,6 +103,10 @@ export class ScalarCardFobController {
102103
);
103104
}
104105

106+
onPrespectiveStepChanged(step: number | null) {
107+
this.prospectiveStep = step;
108+
}
109+
105110
getHighestStep(): number {
106111
return this.minMaxStep.maxStep;
107112
}

tensorboard/webapp/widgets/card_fob/card_fob_controller_component.ng.html

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@
2727
[ngClass]="isVertical() ? 'vertical-fob' : 'horizontal-fob'"
2828
></card-fob>
2929
</div>
30+
<div
31+
class="prospective-fob-area"
32+
[ngClass]="isVertical() ? 'vertical-prospective-area' : 'horizontal-prospective-area'"
33+
(mouseleave)="onProspectiveAreaMouseLeave()"
34+
></div>
3035
<div
3136
#startFobWrapper
3237
class="time-fob-wrapper"

tensorboard/webapp/widgets/card_fob/card_fob_controller_component.scss

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ limitations under the License.
1919
.time-fob-wrapper {
2020
display: inline-block;
2121
position: absolute;
22+
top: 0;
2223
width: 0;
2324
}
2425

@@ -54,3 +55,15 @@ limitations under the License.
5455
opacity: 0.8;
5556
cursor: pointer;
5657
}
58+
59+
.horizontal-prospective-area {
60+
bottom: 0;
61+
position: absolute;
62+
// Height/Width to match x-axis
63+
height: 30px;
64+
width: calc(100% - 50px); // dot on the left takes up 50px
65+
}
66+
67+
.prospective-area {
68+
display: block;
69+
}

tensorboard/webapp/widgets/card_fob/card_fob_controller_component.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ export class CardFobControllerComponent {
6767
@Output() onTimeSelectionChanged =
6868
new EventEmitter<TimeSelectionWithAffordance>();
6969
@Output() onTimeSelectionToggled = new EventEmitter();
70+
@Output() onPrespectiveStepChanged = new EventEmitter<number | null>();
7071

7172
private hasFobMoved: boolean = false;
7273
private currentDraggingFob: Fob = Fob.NONE;
@@ -349,4 +350,8 @@ export class CardFobControllerComponent {
349350

350351
this.onTimeSelectionToggled.emit();
351352
}
353+
354+
onProspectiveAreaMouseLeave() {
355+
this.onPrespectiveStepChanged.emit(null);
356+
}
352357
}

tensorboard/webapp/widgets/card_fob/card_fob_controller_test.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ import {
4444
[prospectiveStep]="prospectiveStep"
4545
(onTimeSelectionChanged)="onTimeSelectionChanged($event)"
4646
(onTimeSelectionToggled)="onTimeSelectionToggled()"
47+
(onPrespectiveStepChanged)="onPrespectiveStepChanged($event)"
4748
></card-fob-controller>
4849
`,
4950
})
@@ -65,6 +66,7 @@ class TestableComponent {
6566

6667
@Input() onTimeSelectionChanged!: (newTimeSelection: TimeSelection) => void;
6768
@Input() onTimeSelectionToggled!: () => void;
69+
@Input() onPrespectiveStepChanged!: (step: number | null) => void;
6870
}
6971

7072
describe('card_fob_controller', () => {
@@ -76,6 +78,8 @@ describe('card_fob_controller', () => {
7678
let getAxisPositionFromEndStepSpy: jasmine.Spy;
7779
let getAxisPositionFromProspectiveStepSpy: jasmine.Spy;
7880
let cardFobHelper: CardFobGetStepFromPositionHelper;
81+
let onPrespectiveStepChangedSpy: jasmine.Spy;
82+
7983
beforeEach(async () => {
8084
await TestBed.configureTestingModule({
8185
declarations: [
@@ -165,6 +169,14 @@ describe('card_fob_controller', () => {
165169

166170
onTimeSelectionToggled = jasmine.createSpy();
167171
fixture.componentInstance.onTimeSelectionToggled = onTimeSelectionToggled;
172+
173+
onPrespectiveStepChangedSpy = jasmine.createSpy();
174+
fixture.componentInstance.onPrespectiveStepChanged =
175+
onPrespectiveStepChangedSpy;
176+
onPrespectiveStepChangedSpy.and.callFake((step: number | null) => {
177+
fixture.componentInstance.prospectiveStep = step;
178+
});
179+
168180
return fixture;
169181
}
170182

@@ -1365,5 +1377,25 @@ describe('card_fob_controller', () => {
13651377

13661378
expect(prospectiveFobTopPosition).toEqual(2);
13671379
});
1380+
1381+
describe('prospective area', () => {
1382+
it('emits null step on mouseleave', () => {
1383+
const fixture = createComponent({
1384+
timeSelection: {start: {step: 4}, end: null},
1385+
axisDirection: AxisDirection.HORIZONTAL,
1386+
isProspectiveFobFeatureEnabled: true,
1387+
prospectiveStep: 2,
1388+
});
1389+
fixture.detectChanges();
1390+
1391+
const hoverArea = fixture.debugElement.query(
1392+
By.css('.prospective-fob-area')
1393+
);
1394+
hoverArea.triggerEventHandler('mouseleave', {});
1395+
fixture.detectChanges();
1396+
1397+
expect(onPrespectiveStepChangedSpy).toHaveBeenCalledWith(null);
1398+
});
1399+
});
13681400
});
13691401
});

0 commit comments

Comments
 (0)