Skip to content

Commit

Permalink
Merge pull request #97 from devexperts/revert-96-fix-memory-leaks-in-…
Browse files Browse the repository at this point in the history
…scale-model

Revert "fix: fixed memory leaks in scale and viewport model"
  • Loading branch information
Keelaro1 authored Dec 12, 2023
2 parents c335ee1 + 644091d commit 2026bc1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 33 deletions.
20 changes: 8 additions & 12 deletions src/chart/components/y_axis/y-axis-scale.handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@ export class YAxisScaleHandler extends ChartBaseElement {

constructor(
private bus: EventBus,
private config: YAxisConfig,
config: YAxisConfig,
panning: ChartPanComponent,
private scale: ScaleModel,
private canvasInputListener: CanvasInputListenerComponent,
canvasInputListener: CanvasInputListenerComponent,
private bounds: CanvasBoundsContainer,
private hitTest: HitBoundsTest,
hitTest: HitBoundsTest,
private autoScaleCallback: (auto: boolean) => void,
) {
super();
Expand All @@ -58,17 +58,13 @@ export class YAxisScaleHandler extends ChartBaseElement {
},
);
this.addChildEntity(dragNDropYComponent);
}
}

protected doActivate(): void {
if (this.config.customScaleDblClick) {
this.addRxSubscription(
this.canvasInputListener.observeDbClick(this.hitTest).subscribe(() => {
this.autoScaleCallback(true);
if (config.customScaleDblClick) {
canvasInputListener.observeDbClick(hitTest).subscribe(() => {
autoScaleCallback(true);
this.bus.fireDraw();
}),
);
});
}
}
}

Expand Down
11 changes: 1 addition & 10 deletions src/chart/model/scale.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ type Constraints = (initialState: ViewportModelState, state: ViewportModelState)
export class ScaleModel extends ViewportModel {
public scaleInversedSubject: Subject<boolean> = new Subject<boolean>();
// y-axis component needs this subject in order to halt prev animation if axis type is percent
public beforeStartAnimationSubject: Subject<void> = new Subject<void>();
public beforeStartAnimationSubject = new Subject<void>();

// TODO rework, make a new history based on units
history: ScaleHistoryItem[] = [];
Expand Down Expand Up @@ -84,22 +84,13 @@ export class ScaleModel extends ViewportModel {
}

protected doActivate(): void {
super.doActivate();
this.scaleInversedSubject = new Subject();
this.beforeStartAnimationSubject = new Subject();
this.addRxSubscription(
this.scaleInversedSubject.subscribe(() => {
this.fireChanged();
}),
);
}

protected doDeactivate(): void {
super.doDeactivate();
this.scaleInversedSubject.complete();
this.beforeStartAnimationSubject.complete();
}

/**
* The method adds a new "constraint" to the existing list of x-axis constraints for charting.
* The "constraint" is expected to be an object containing information about the constraints, such as the minimum and maximum values for the x-axis.
Expand Down
15 changes: 4 additions & 11 deletions src/chart/model/scaling/viewport.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,16 +152,6 @@ export abstract class ViewportModel extends ChartBaseElement implements Viewable
share(),
);
//endregion

protected doActivate(): void {
super.doActivate();
this.changed = new Subject();
}

protected doDeactivate(): void {
super.doDeactivate();
this.changed.complete();
}
//region conversion methods
/**
* Converts a unit value to pixels based on the current zoom level and xStart value.
Expand Down Expand Up @@ -227,7 +217,10 @@ export abstract class ViewportModel extends ChartBaseElement implements Viewable
return pixelsToUnits(normalizedPx + unitToPixels(this.yStart, this.zoomY), this.zoomY);
} else {
// inverse by default because canvas calculation [0,0] point starts from top-left corner
return pixelsToUnits(bounds.height - normalizedPx + unitToPixels(this.yStart, this.zoomY), this.zoomY);
return pixelsToUnits(
bounds.height - normalizedPx + unitToPixels(this.yStart, this.zoomY),
this.zoomY,
);
}
}

Expand Down

0 comments on commit 2026bc1

Please sign in to comment.