|
Missing x-labels |
Posted by jcagumbay on Jun-02-2011 19:04 |
|
Hi everyone,
I have a bar chart for my histogram. Everything is fine but something's wrong with my x-labels. Some of the labels are missing and when I checked the array that contains the values for the labels, it seems okay. I set the labels using setLabels() method of the xAxis.
Any help would be much appreciated. Thanks you so much!
Best regards,
jboy |
Re: Missing x-labels |
Posted by Peter Kwan on Jun-03-2011 05:08 |
|
Hi jcagumbay,
To diagnose the problem, you may try the following methods:
(a) If your labels array are genreated dynamically (eg. using data from a database), for testing, you may hard coded the labels. For example, you may just use:
$labels = array("Mon", "Tue", "Wed", "Thu", "Fri");
This can eliminate the uncertainly that whether the $labels actually contain something or not. So we can test if ChartDirector can show the x-axis labels.
(b) Apart from the x-axis labels, are there any other text in your chart (y-axis labels or chart title)? Are they visible? If all texts are invisible, it may have something to do with the fonts. If only some texts are invisible, the issue is likely not related to the fonts.
(c) To test if your labels array contains labels as expected, you may use something like:
$c->xAxis->setLabels($labels);
$c->addTitle("XXX " . $labels[0] . " YYY");
The above will include the first label in the chart title. If you can see the XXX and YYY, but not the label, it probably mean the first label is empty in your label array.
If you need further help, may be you can inform me the charting part of your code. I need to know more details (such as if there are any filter or label stepping configuration) to determine how to diagnose the problem.
Regards
Peter Kwan |
Re: Missing x-labels |
Posted by jcagumbay on Jun-03-2011 16:12 |
|
Hi Peter,
Thanks for the reply. I think adding marks on the x-axis causes this bug. After using setPos() method, the some x labels near the marks were gone. I don't know how it happens but do you have any explanation on this? Thanks!
Best regards,
jboy |
Re: Missing x-labels |
Posted by Peter Kwan on Jun-04-2011 03:19 |
|
Hi jboy,
If there is a mark on the x-axis, and by default the mark text overlaps with some x-axis labels, those x-axis labels will be removed.
Unluckily, even if you use setPos to move the mark text away, the x-axis labels will still be disabled.
If the above is the cause of the problem, you may consider to put the mark label in a position that cannot overlap with the x-axis labels by default (that is, even without using setPos). For example, you may put the mark label above the x-axis inside the plot area using Bottom alignment:
$myMark->setAlignment(Bottom);
Since you are using setPos, you just need to increase the y offset coordinates to compensate for the difference in position.
Hope this can help.
Regards
Peter Kwan |
Re: Missing x-labels |
Posted by jcagumbay on Jun-04-2011 11:34 |
|
Hi Peter,
I did use setAlignment() method and it is now okay. Thank you so much! I really appreciate
your help.
Best regards,
jboy |
|