diff --git a/tensorbored/webapp/metrics/views/main_view/superimposed_cards_view_component.ts b/tensorbored/webapp/metrics/views/main_view/superimposed_cards_view_component.ts index e2540c921c8..65f5952bd6f 100644 --- a/tensorbored/webapp/metrics/views/main_view/superimposed_cards_view_component.ts +++ b/tensorbored/webapp/metrics/views/main_view/superimposed_cards_view_component.ts @@ -12,7 +12,13 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ==============================================================================*/ -import {ChangeDetectionStrategy, Component, Input} from '@angular/core'; +import { + ChangeDetectionStrategy, + Component, + Input, + OnChanges, + SimpleChanges, +} from '@angular/core'; import {Store} from '@ngrx/store'; import {Observable} from 'rxjs'; import {State} from '../../../app_state'; @@ -21,6 +27,9 @@ import {SuperimposedCardMetadata} from '../../types'; import {superimposedCardFullWidthChanged} from '../../actions'; import {getFullWidthSuperimposedCards} from '../../store'; +const MIN_CARD_MIN_WIDTH_IN_PX = 335; +const MAX_CARD_MIN_WIDTH_IN_PX = 735; + @Component({ standalone: false, selector: 'superimposed-cards-view-component', @@ -39,7 +48,10 @@ import {getFullWidthSuperimposedCards} from '../../store'; -
+
>; cardsAtFullHeight = new Set(); @@ -69,6 +84,21 @@ export class SuperimposedCardsViewComponent { this.cardsAtFullWidth$ = this.store.select(getFullWidthSuperimposedCards); } + ngOnChanges(changes: SimpleChanges) { + if (changes['cardMinWidth']) { + const width = changes['cardMinWidth'].currentValue; + if ( + width && + width >= MIN_CARD_MIN_WIDTH_IN_PX && + width <= MAX_CARD_MIN_WIDTH_IN_PX + ) { + this.gridTemplateColumn = `repeat(auto-fill, minmax(${width}px, 1fr))`; + } else { + this.gridTemplateColumn = ''; + } + } + } + trackByCard(index: number, card: SuperimposedCardMetadata): string { return card.id; } diff --git a/tensorbored/webapp/metrics/views/main_view/superimposed_cards_view_container.ts b/tensorbored/webapp/metrics/views/main_view/superimposed_cards_view_container.ts index 15231d87808..1ccd19084ea 100644 --- a/tensorbored/webapp/metrics/views/main_view/superimposed_cards_view_container.ts +++ b/tensorbored/webapp/metrics/views/main_view/superimposed_cards_view_container.ts @@ -17,6 +17,7 @@ import {Store} from '@ngrx/store'; import {Observable} from 'rxjs'; import {startWith} from 'rxjs/operators'; import {State} from '../../../app_state'; +import {getMetricsCardMinWidth} from '../../../selectors'; import {getSuperimposedCardsWithMetadata} from '../../store'; import {SuperimposedCardMetadata} from '../../types'; import {CardObserver} from '../card_renderer/card_lazy_loader'; @@ -28,6 +29,7 @@ import {CardObserver} from '../card_renderer/card_lazy_loader'; `, changeDetection: ChangeDetectionStrategy.OnPush, @@ -35,11 +37,13 @@ import {CardObserver} from '../card_renderer/card_lazy_loader'; export class SuperimposedCardsViewContainer { @Input() cardObserver!: CardObserver; + readonly superimposedCards$: Observable; + readonly cardMinWidth$: Observable; + constructor(private readonly store: Store) { this.superimposedCards$ = this.store .select(getSuperimposedCardsWithMetadata) .pipe(startWith([])); + this.cardMinWidth$ = this.store.select(getMetricsCardMinWidth); } - - readonly superimposedCards$: Observable; } diff --git a/tensorbored/webapp/widgets/line_chart_v2/line_chart_component.ts b/tensorbored/webapp/widgets/line_chart_v2/line_chart_component.ts index b7cbf9d5f78..911b76abd9d 100644 --- a/tensorbored/webapp/widgets/line_chart_v2/line_chart_component.ts +++ b/tensorbored/webapp/widgets/line_chart_v2/line_chart_component.ts @@ -250,6 +250,17 @@ export class LineChartComponent this.setIsViewBoxOverridden(false); } + // When the chart transitions from disabled to enabled, the container may + // have been resized while updates were suppressed (e.g. persistResize + // restoring a height, or a full-width toggle applied asynchronously). + // The ResizeDetectorDirective's skip(1) can swallow the only + // ResizeObserver event in that window, leaving the renderer and the + // interactive overlay with stale dimensions. Re-read and apply now. + if (changes['disableUpdate'] && !this.disableUpdate && this.lineChart) { + this.readAndUpdateDomDimensions(); + this.lineChart.resize(this.domDimensions.main); + } + this.isViewBoxChanged = this.isViewBoxChanged || this.userViewBoxUpdated ||