Skip to content

Commit

Permalink
Fix label overflow
Browse files Browse the repository at this point in the history
Signed-off-by: muddana-satish <satish.muddana@ericsson.com>
  • Loading branch information
muddana-satish authored and MatthewKhouzam committed Jan 8, 2021
1 parent 39ea33b commit 369705f
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions timeline-chart/src/components/time-graph-row-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,18 +53,20 @@ export class TimeGraphRowElement extends TimeGraphComponent {
if (!this._model.label) {
return;
}
const fontName = TimeGraphRowElement.fontController.getFontName(this._options.color ? this._options.color : 0, this._options.height - 2);
const textObj = new PIXI.BitmapText(this._model.label, { fontName: fontName ? fontName : TimeGraphRowElement.fontController.getDefaultFontName() });
const fontName = TimeGraphRowElement.fontController.getFontName(this._options.color ? this._options.color : 0, this._options.height - 2) ||
TimeGraphRowElement.fontController.getDefaultFontName();
const textObj = new PIXI.BitmapText(this._model.label, { fontName: fontName });
const textWidth = textObj.getLocalBounds().width;
const position = {
x: this._options.position.x + this._options.width < 0 ? this._options.position.x : Math.max(0, this._options.position.x),
y: this._options.position.y
}
const displayWidth = this._options.displayWidth ? this._options.displayWidth : 0;
const labelText = this._model.label;
const textPadding = 0.5;

let textObjX = position.x + 0.5;
const textObjY = position.y + 0.5;
let textObjX = position.x + textPadding;
const textObjY = position.y + textPadding;
let displayLabel = "";

if (displayWidth > textWidth) {
Expand All @@ -80,10 +82,10 @@ export class TimeGraphRowElement extends TimeGraphComponent {
}
}

textObj.text = displayLabel;
textObj.x = textObjX;
textObj.y = textObjY;
this.displayObject.addChild(textObj);
const newTextObj = new PIXI.BitmapText(displayLabel, { fontName: fontName });
newTextObj.x = textObjX;
newTextObj.y = textObjY;
this.displayObject.addChild(newTextObj);
}

clearLabel() {
Expand Down

0 comments on commit 369705f

Please sign in to comment.