Skip to content

Commit

Permalink
Center x-axis labels
Browse files Browse the repository at this point in the history
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](eclipse-cdt-cloud/theia-trace-extension#440).

Signed-off-by: Rodrigo Pinto <rodrigo.pinto@calian.ca>
  • Loading branch information
Rodrigoplp committed Aug 12, 2021
1 parent 2d3f4d8 commit 1fafa8e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions timeline-chart/src/components/time-graph-axis-scale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export class TimeGraphAxisScale extends TimeGraphComponent<null> {
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);
Expand Down Expand Up @@ -169,4 +169,4 @@ export class TimeGraphAxisScale extends TimeGraphComponent<null> {
end
}
}
}
}

0 comments on commit 1fafa8e

Please sign in to comment.