From 1fafa8ef1563db3f6ed20edfa67bae3279636826 Mon Sep 17 00:00:00 2001 From: Rodrigo Pinto Date: Thu, 12 Aug 2021 16:24:35 -0400 Subject: [PATCH] Center x-axis labels Currently the labels of the x-axis are aligned to the left, 5 pixels after their corresponding tick in the axis. This commit centers the labels according to their ticks. The position of the text is calculated by using the position of the tick, minus half the width of the text. Fixes [issue 440 in theia-ide/theia-trace-extension](https://github.com/theia-ide/theia-trace-extension/issues/440). Signed-off-by: Rodrigo Pinto --- timeline-chart/src/components/time-graph-axis-scale.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/timeline-chart/src/components/time-graph-axis-scale.ts b/timeline-chart/src/components/time-graph-axis-scale.ts index 4bda562..b34a631 100644 --- a/timeline-chart/src/components/time-graph-axis-scale.ts +++ b/timeline-chart/src/components/time-graph-axis-scale.ts @@ -107,7 +107,7 @@ export class TimeGraphAxisScale extends TimeGraphComponent { fontSize: 10, fill: lineColor }); - text.x = position.x + 5; + text.x = position.x - (text.width / 2); text.y = position.y + lineStyle(label).lineHeight; this.labels.push(text); this._displayObject.addChild(text); @@ -169,4 +169,4 @@ export class TimeGraphAxisScale extends TimeGraphComponent { end } } -} \ No newline at end of file +}