|
Axis Label styles and alignment |
Posted by JC on Nov-28-2008 02:16 |
|
I am just wondering is ways to set the justification orientation to the labels axis.
Justification orientation as in Left/Center/Right justified.
In my current prototype, I am using the axis setLabelStyle property and capturing the return value in a CD textbox object. Then using the textbox object I am trying to use the 'setAlignment' property but I am unable to see the axis text change. |
Re: Axis Label styles and alignment |
Posted by Peter Kwan on Nov-28-2008 03:54 |
|
Hi JC,
For Left/Center/Right justification, the text must be justified relative to something. For the axis labels, each label is justified relative to the bounding box of the label. By default, the bounding box is automatically adjusted to be the same size as the label, so the label just fits the bounding box, and justification as no effect.
To see the justification, you need to set a bounding box wider than the label. For example, you may try:
Dim t As ChartDirector.TextBox = c.yAxis().setLabelStyle("Arial", 8)
t.setSize(60, 0)
t.setAlignment(Chart.Left)
You should set the y-axis labels justisfied to the left.
There are other methods to adjust the label positions depending on what effect you want to achieve. If you need further help, may be you can provide an example on the effect you want to achieve. I will try to suggest a method to achieve it.
Hope this can help.
Regards
Peter Kwan |
Re: Axis Label styles and alignment |
Posted by JC on Nov-29-2008 00:38 |
|
Thanks for the clarification on how Axis justification will work.
I have been looking into setting "underline" style to the Axis labels (regardless of X or Y). How can I accomplish this with the two scenarios I have.
1. When CD generates the ranges and label...
2. When I push in data for axis labels. Is there any another way other than loop through each array element and concatenating "<*underline=2*>"?
I notice when I try to set the width Axis Title textbox and justified the text content. The Axis Title textbox start position is base off the alignment. How can I get the axis title to span the width of the chart and set the content justification base on specification?
This is what I have...
c.setPlotArea(100,100)
Dim t As ChartDirector.TextBox = c.xAxis().setTitle("Winter is HERE")
t.setSize(100,0)
t.setAlignment(c.right) |
Re: Axis Label styles and alignment |
Posted by Peter Kwan on Nov-29-2008 02:05 |
|
Hi JC,
1. When CD generates the ranges and label...
If the labels are generated by CD, the code is:
c.yAxis().setLabelFormat("<*underline=2*>{value}");
If the labes are provided by your code, but is still formatted by ChartDirector (as is in Axis.setLabels20), you can still ask ChartDirector to add the <*underline*>.
c.xAxis().setLabels2(myLabels, "<*underline=2*>{value}");
If the labels are pre-formatted by your code (are already text strings), the easiest method I can think of is to concatenating "<*underline=2*>" when you format your labels (just like what ChartDirector does internally). If your labels are from a database, you can also ask the database to concatenating the <*underline=2*> using SQL.
I think the method of "loop through each array element and concatenating <*underline=2*>" is also acceptable, as it is in my opinion also very simple.
Hope this can help.
Regards
Peter Kwan |
Re: Axis Label styles and alignment |
Posted by JC on Dec-01-2008 22:53 |
|
Is there a way after I populate the Axis Labels to determine the max character length of the axis labels? |
Re: Axis Label styles and alignment |
Posted by Peter Kwan on Dec-02-2008 01:23 |
|
Hi JC,
I assume you are referrring to the labels generated by ChartDirector by auto-scaling. (If the labels are from your code, it should know the maximum character length.)
The code to determine the maximum number of characters are:
'freeze chart and auto-scale the axis
c.layout()
Dim ticks() As Double = c.yAxis().getTicks()
Dim maxCharLength As Integer = 0
Dim i As Integer
For i = 0 To UBound(ticks)
maxCharLength = Math.Max(maxCharLength, Len(c.yAxis().getLabel(i)))
Next
Hope this can help.
Regards
Peter Kwan |
|