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

Message ListMessage List     Post MessagePost Message

  X Axis (xAxis) Label spacing issue
Posted by eddy glaister on Jun-24-2014 17:53
Attachments:
Hi there,

The spacing of labels (dates)on the X axis of my chart are bunching up.

How can I space these equally across the chart?

I have tried the following code but it never worked. It doesnt matter what amount is
entered in the SetLabelStep function it always displays the same - like the screen print.

c.xAxis().setLabelFormat("{value|dd/mm/yyyy}");

//calculate step for chart labels
double stepcount = (double)masterArrayDateTimes.Length / 5;
int step = (int)Math.Ceiling(stepcount);

//set up label step (divide number of records by 5)
c.xAxis().setLabelStep(step);

Please see attached image
graph.jpg

  Re: X Axis (xAxis) Label spacing issue
Posted by Peter Kwan on Jun-24-2014 22:52
Hi Eddy,

Are you using Layer.setXData to set the x data value to the layer, like:

myLayer.setXData(masterArrayDateTimes);

If the above is the case, it is likely the x-axis labels are automatically generated by
ChartDirector (just like the y-axis labels are automatically generated by ChartDirector). The
number of x-axis labels are not related to the number of data points, just like the number of
y-axis labels are not related to the number of data points.

The Axis.setLabelStep is only useful if your code provides the labels. If ChartDirector
automatically determines the labels, the Axis.setLabelStep has no effect (as the number of
labels are not related to the number of data points). ChartDirector would space the labels
according to Axis.setTickDensity, which defaults to 50 pixels. For your case, I suspect the
label format and font size is such that adjacent labels may occasionally overlap. In this
case, some of the labels will be hidden due to overlapping. To solve the problem, you may
use a wide tick density to ensure the labels cannot overlap. For example:

c.xAxis().setTickDensity(75);

Hope this can help.

Regards
Peter Kwan

  Re: X Axis (xAxis) Label spacing issue
Posted by eddy glaister on Jun-25-2014 17:29
That did the trick - thank you! :-)