ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Set Text alignment of YAxis Labels
Posted by Dan on Feb-07-2017 23:30
As i understands it I need to make the text box larger in order to right align the text in YAxis labels.


Is it possible to access the YAxis text boxes to set the alignment after .layoutAxes had been performed?

What I want to do is to find the widest of the boxes and then set all the boxes to that width in order to get the text right aligned.

I want to avoid guessing what the width of the text box should be.

  Re: Set Text alignment of YAxis Labels
Posted by Dan on Feb-07-2017 23:43
Attachments:
Is it possible to use Axis.setLabelAlignment on the Y-Axis for my purpose?
Skärmavbild 2017-02-07 kl. 16.42.37.png

  Re: Set Text alignment of YAxis Labels
Posted by Peter Kwan on Feb-08-2017 16:31
Hi Dan,

For your case, you would need to use TextBox.setAlignment. As you have already known, you would need to set the size of the text box. I have tried the following code and it works in my case:


..... set up chart as usual ....,

'Assume the right axis is the yAxis2. The following is the default style of the axis labels
Set t = c.yAxis2().setLabelStyle("arialbd.ttf", 10)
Call t.setMargin(0)
Call t.setAlignment(cd.Right)

'Auto-scale axis to generate the labels
Call c.layoutAxes()

'Set the text box width to be of the same "thickness" of the axis
'*** NOTE ***: The thickness includes the axis title. If there is no axis title, then the
'thickness is the distance between the axis stem and the right side of the longest label.
Call t.setWidth(c.yAxis2().getThickness())

Hope this can help.

Regards
Peter Kwan

  Re: Set Text alignment of YAxis Labels
Posted by Dan on Feb-08-2017 19:00
Thanks,



GetThickness did the trick. FWIW: I had to substract the LabelGap from the value returned from GetThickness to get what I wanted.
Now it looks really good :-)

Great,

Dan