Skip to content

Commit

Permalink
Pull request #5412: Bugfix/DXCF-5765 chart viewport incorrect viewpor…
Browse files Browse the repository at this point in the history
…t position after reload page

Merge in DXCHARTS/dxchart5 from bugfix/DXCF-5765-chart-viewport-incorrect-viewport-position-after-reload-page to master

* commit '4f664c0a3126d3692ec4df8751e2747d6a566a96':
  [DXCF-5765] Chart Viewport - Incorrect viewport position after reload page // copy
  [DXCF-5765] Chart Viewport - Incorrect viewport position after reload page // init
  [DXCF-5765] Chart Viewport - Incorrect viewport position after reload page // init
  [DXCF-5765] Chart Viewport - Incorrect viewport position after reload page // init
  [DXCF-5765] Chart Viewport - Incorrect viewport position after reload page // init

GitOrigin-RevId: e11e48a474948d92c379822b06114a4d877e28c8
  • Loading branch information
Keelaro1 authored and dxcity committed Jan 13, 2025
1 parent 23df0fd commit 6bbc7c4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/chart/components/chart/chart.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ export class ChartModel extends ChartBaseElement {
const nextChartWidth = this.canvasBoundsContainer.getEffectiveChartWidth();
const nextYAxisWidth = this.canvasBoundsContainer.getEffectiveYAxisWidth();

if (this.prevChartWidth === 0) {
this.scale.isViewportValid() ? this.scale.recalculateZoom() : this.doBasicScale();
if (this.prevChartWidth === 0 && this.scale) {
this.scale.isViewportValid(false) && this.scale.recalculateZoom();
this.prevChartWidth = nextChartWidth;
this.prevYWidth = nextYAxisWidth;
return;
Expand Down
7 changes: 4 additions & 3 deletions src/chart/model/scaling/viewport.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -424,14 +424,15 @@ export abstract class ViewportModel extends ChartBaseElement implements Viewable
*
* @returns {boolean} - Returns true if the viewport is valid, false otherwise.
*/
isViewportValid() {
isViewportValid(validateZoom: boolean = true) {
// zoom is checked separately because sometimes we need to recalculate zoom based on X and Y and zoom could be incorrect
const isZoomValid = validateZoom === false || (this.zoomX > 0 && this.zoomY > 0);
return (
this.xStart !== this.xEnd &&
this.yStart !== this.yEnd &&
isFinite(this.yStart) &&
isFinite(this.yEnd) &&
this.zoomX > 0 &&
this.zoomY > 0
isZoomValid
);
}
}
Expand Down

0 comments on commit 6bbc7c4

Please sign in to comment.