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

Message ListMessage List     Post MessagePost Message

  How can I make axis labels only show each other, at an angle
Posted by David Thielen on Feb-25-2021 06:03
Attachments:
Hi;

What I want to display for the X axis is the first image below. What I am getting is the second. Not that not only is the desired text at an angle, but it also displays just every other due to lack of space.

If the chart is wide enough, then I do want it to show the text for every tick.

How can I do this?

thanks - dave
first.png
second.png

  Re: How can I make axis labels only show each other, at an angle
Posted by Peter Kwan on Feb-25-2021 20:30
Hi David,

You can use Axis.setLabelStyle to configure the rotation angle of the label. See:

https://www.advsofteng.com/doc/cdjava.htm#Axis.setLabelStyle.htm

The following is an example:

https://www.advsofteng.com/doc/cdjava.htm#candlestick.htm


From your previous code, I believe your code sets the labels using Axis.setLabels.
To hide some labels, the easiest way is to change those labels to a space character.

Your code knows the plot area width and also the number of labels and their font size (these information come from your code). So it can be used to determine how many labels need to be changed to a space character. Your code can then use a loop to change those labels to a space character before passing the labels array to ChartDirector.

There is also an API Axis.setLabelStep that can skip the labels, but with this API, it will skip the ticks as well. An example is at:

https://www.advsofteng.com/doc/cdjava.htm#simpleline.htm

Regards
Peter Kwan