-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use TextMetrics to measure label text width before rendering
Currently, the timeline-chart creates a BitMapText object to measure the width of the label text for every state, before actually rendering it. If a label text does not fit within its state, the BitMapText object is not used, and will remain there until the chart deletes the state. This hogs the performance of the timeline chart, especially when a large number of states need to be removed, because the chart needs to delete the BitMapText objects as well. This commit uses PIXI.TextMetrics.measureText() as a faster alternative to measure the text label width. The advantage of this method is that it is a static method, which requires no object construction. Thus the timeline-chart will only create and remove BitMapText objects that are actually used to display label texts. The disadvatage is that the measurement between the 2 methods are not the same, since TextMetrics works with PIXI.Text objects, and not PIXI.BitMapText. Through trials, it is found that the ratio between the text width returned by the two methods is consistent. Hence, this commit uses this ratio as a temporary solution to properly calculate the text width, until PIXI supports TextMetrics for BitMapText. Signed-off-by: Hoang Thuan Pham <hoang.pham@calian.ca>
- Loading branch information
1 parent
4694a71
commit 9b23c78
Showing
2 changed files
with
106 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters