Skip to content

Commit 89475fc

Browse files
authored
Shareability: updates minMaxStep on data loaded (#6278)
* Motivation for features / changes The current logic of calculating minMaxStep$ assumes data has existed. However, for Google-internal project, we might have other card state (userMinMax, timeSelection..) first then fetch time series data later. Then minMaxStep$ will not emit new values with "withLatestFrom". Therefore, this PR simply move that part above to assume we update minMaxStep$ on data loaded.
1 parent 865c193 commit 89475fc

File tree

1 file changed

+14
-16
lines changed

1 file changed

+14
-16
lines changed

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

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -373,22 +373,20 @@ export class ScalarCardContainer implements CardRenderer, OnInit, OnDestroy {
373373
shareReplay(1)
374374
);
375375

376-
this.minMaxSteps$ = this.store
377-
.select(getMetricsCardMinMax, this.cardId)
378-
.pipe(
379-
withLatestFrom(
380-
this.store.select(getMetricsCardDataMinMax, this.cardId)
381-
),
382-
map(([minMax, dataMinMax]) => {
383-
if (!minMax || !dataMinMax) {
384-
return;
385-
}
386-
return {
387-
minStep: Math.max(minMax?.minStep!, dataMinMax?.minStep!),
388-
maxStep: Math.min(minMax?.maxStep!, dataMinMax?.maxStep!),
389-
};
390-
})
391-
);
376+
this.minMaxSteps$ = combineLatest([
377+
this.store.select(getMetricsCardMinMax, this.cardId),
378+
this.store.select(getMetricsCardDataMinMax, this.cardId),
379+
]).pipe(
380+
map(([minMax, dataMinMax]) => {
381+
if (!minMax || !dataMinMax) {
382+
return;
383+
}
384+
return {
385+
minStep: Math.max(minMax?.minStep!, dataMinMax?.minStep!),
386+
maxStep: Math.min(minMax?.maxStep!, dataMinMax?.maxStep!),
387+
};
388+
})
389+
);
392390

393391
this.dataSeries$ = partitionedSeries$.pipe(
394392
// Smooth

0 commit comments

Comments
 (0)