Skip to content

Commit

Permalink
Merge pull request #959 from tradingview/fix943-fix-price-axis-width
Browse files Browse the repository at this point in the history
  • Loading branch information
timocov authored Jan 10, 2022
2 parents ea26553 + 6b010d8 commit feade2b
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/gui/price-axis-widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ const enum CursorType {
NsResize,
}

const enum Constants {
DefaultOptimalWidth = 34,
}

type IPriceAxisViewArray = readonly IPriceAxisView[];

export class PriceAxisWidget implements IDestroyable {
Expand Down Expand Up @@ -171,8 +175,7 @@ export class PriceAxisWidget implements IDestroyable {
return 0;
}

// need some reasonable value for scale while initialization
let tickMarkMaxWidth = 34;
let tickMarkMaxWidth = 0;
const rendererOptions = this.rendererOptions();

const ctx = getContext2D(this._canvasBinding.canvas);
Expand Down Expand Up @@ -207,12 +210,14 @@ export class PriceAxisWidget implements IDestroyable {
);
}

const resultTickMarksMaxWidth = tickMarkMaxWidth || Constants.DefaultOptimalWidth;

let res = Math.ceil(
rendererOptions.borderSize +
rendererOptions.tickLength +
rendererOptions.paddingInner +
rendererOptions.paddingOuter +
tickMarkMaxWidth
resultTickMarksMaxWidth
);
// make it even
res += res % 2;
Expand Down

0 comments on commit feade2b

Please sign in to comment.