|
Staggered X Labels |
Posted by Chris on May-30-2007 22:30 |
|
I have a set of non-contiguous (skipping is not an option) data labels that are too many to be legible in the space that I have. Is it possible to stagger the the labels 2 or more different depths? If this is not clear, what I am trying to do is something like this:
_________________________________
| | | | | | |
Data1 | Data3 | Data5 | Data7
Data2 Data4 Data6
Thank You!
Chris |
Re: Staggered X Labels |
Posted by Peter Kwan on May-31-2007 03:54 |
|
Hi Chris,
You may just use a line feed character as the first character for Data2, Data4, Data6, etc.. As an alternative to the line feed character, you may use the CDML string <*br*>, which has the advantage of not affecting the tooltips (in case you are using tooltips). For example, in VB/VBScript:
For i = 1 To Ubound(labels) Step 2
labels(i) = "<*br*>" & labels(i)
Next
Personally, I would not suggest to use "2 layers or labels". It is because in your case, Data1 can still overlap with "tick" at Data2. So this method works only if the labels are too long to be in one layer, but not too long so as to overlap with the "tick" on the next position. In other words, this method only works for a very narrow range of label width, and is not useful for most applications. (Using 3 or more depths will not help, as it is still limited by Data1 overlapping with the tick position of Data2.)
I suggest you may rotate the labels by 90 degrees instead, so they flow vertically. The code is:
Call c.xAxis().setLabelStyle("arial.ttf", 8, &H000000, 90)
Hope this can help.
Regards
Peter Kwan |
Re: Staggered X Labels |
Posted by Richard on Sep-22-2009 23:04 |
|
Hi,
I have a similar issue relating to polarchart. I'm trying to replicate a labelling scheme like:
10 |-
-| 9
8 |-
-| 7
6 |-
etc. to 0
Would use alternating setTickOffset and setLabelOffset be the best way to accomplish this? |
Re: Staggered X Labels |
Posted by Peter Kwan on Sep-23-2009 11:25 |
|
Hi Richard,
In your case, I think the easiest method is to use custom label drawing. Assuming your radial axis is auto-scaled, the code is like:
#hide the original radial axis label
$c->radialAxis->setLabelStyle("Normal", 8, Transparent);
#auto-scale axis to get the tick positions on the axis
$c->layout();
$ticks = $c->radialAxis->getTicks();
#draw the labels on left/right alternatively, and the ticks at opposite side of the labels
for ($i = 0; $i < count($ticks); ++$i) {
$yCoor = $c->getYCoor($ticks[$i], 0);
$xCoor = $c->getXCoor($ticks[$i], 0);
$c->addText($xCoor, $yCoor, $ticks[$i], "arialbd.ttf", 8, 0x000000, $i % 2 ? Left : Right);
$c->addLine($xCoor, $yCoor, $xCoor + ($i % 2 ? -5 : 5), $yCoor, 0x000000);
}
Hope this can help.
Regards
Peter Kwan |
|