Skip to content

Commit

Permalink
Add ellipse and star to the character set of label text
Browse files Browse the repository at this point in the history
This commit adds the ellipse (...) and star unicode characters
to the character set of the label text in the time-graph-font
controller. This would help display the ellipse symbol in the label
text (when the text is truncated) as a single character and takes
up the same space as a single character.

Signed-off-by: Hoang Thuan Pham <hoang.pham@calian.ca>
  • Loading branch information
hoangphamEclipse committed Jan 16, 2023
1 parent 672d6b6 commit da30c1b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
4 changes: 2 additions & 2 deletions timeline-chart/src/components/time-graph-state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ export class TimeGraphStateComponent extends TimeGraphComponent<TimelineChart.Ti
else {
const textScaler = displayWidth / this.textWidth;
const index = Math.min(Math.floor(textScaler * labelText.length), labelText.length - 1)
const partialLabel = labelText.substr(0, Math.max(index - 3, 0));
const partialLabel = labelText.substr(0, Math.max(index - 1, 0));
if (partialLabel.length > 0) {
displayLabel = partialLabel.concat("...");
displayLabel = partialLabel.concat("");
}
}

Expand Down
11 changes: 10 additions & 1 deletion timeline-chart/src/time-graph-font-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export class FontController {
fill: fontColor === "White" ? "white" : "black",
fontWeight: "bold"
};
PIXI.BitmapFont.from(fontName, fontStyle, { chars: PIXI.BitmapFont.ASCII });
PIXI.BitmapFont.from(fontName, fontStyle, { chars: this.getCharacterSet() });
return fontName;
}

Expand Down Expand Up @@ -72,4 +72,13 @@ export class FontController {
}
return fontName ? fontName : "";
}

private getCharacterSet(): string[][] {
let letters: string[][]= [];
letters.push(PIXI.BitmapFont.ASCII[0]);
letters.push(['★','★']);
letters.push(['…','…']);

return letters;
}
}

0 comments on commit da30c1b

Please sign in to comment.