Skip to content

Commit

Permalink
Update data model on resize
Browse files Browse the repository at this point in the history
When the time graph canvas width is increased by a resize event, the
data model may no longer be at the appropriate resolution. Invoke the
debounced method to maybe fetch new data, in the same way as is done
when the view range is changed.

Update the data model when the resolution is changed either way (not
only when zooming in) so that an appropriately sized and consistent data
model is always used.

Change-Id: I33373a3fa490ae94e157e20638423de149c91021
Signed-off-by: Patrick Tasse <patrick.tasse@ericsson.com>
  • Loading branch information
PatrickTasse committed Feb 16, 2022
1 parent 7b97ced commit ae1adb0
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions timeline-chart/src/layer/time-graph-chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ export class TimeGraphChart extends TimeGraphChartLayer {
private _mouseWheelHandler: { (ev: WheelEvent): void; (event: Event): void; (event: Event): void; };
private _contextMenuHandler: { (e: MouseEvent): void; (event: Event): void; };

private _debouncedMaybeFetchNewData = debounce(() => this.maybeFetchNewData(), 400);

// Keep track of the most recently clicked point.
// If clicked again during _multiClickTime duration (milliseconds) record multi-click
private _recentlyClickedGlobal: PIXI.Point | null = null;
Expand Down Expand Up @@ -333,7 +335,7 @@ export class TimeGraphChart extends TimeGraphChartLayer {
}
};
this.unitController.onViewRangeChanged(this._viewRangeChangedHandler);
this.unitController.onViewRangeChanged(debounce(() => this.maybeFetchNewData(), 400));
this.unitController.onViewRangeChanged(this._debouncedMaybeFetchNewData);

if (this.unitController.viewRangeLength && this.stateController.canvasDisplayWidth) {
this.maybeFetchNewData();
Expand All @@ -349,6 +351,7 @@ export class TimeGraphChart extends TimeGraphChartLayer {

update() {
this.updateScaleAndPosition();
this._debouncedMaybeFetchNewData();
}

updateZoomingSelection() {
Expand Down Expand Up @@ -410,7 +413,7 @@ export class TimeGraphChart extends TimeGraphChartLayer {
if (viewRange && (
viewRange.start < this.providedRange.start ||
viewRange.end > this.providedRange.end ||
resolution < this.providedResolution ||
resolution != this.providedResolution ||
update
)) {
try {
Expand Down

0 comments on commit ae1adb0

Please sign in to comment.