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

Message ListMessage List     Post MessagePost Message

  Move bar layer so that the ticks will be between the bars
Posted by at on Apr-12-2022 17:45
Hi Peter, in the attached image, how can I move the bars halfway to the right so that the ticks will always be in between the bars? Basically, that's a histogram with 50 slots and what I want is to always put the two red vertical marks to be always between the bars since their values always correspond to one of the x-axis labels. I tried setting the x-axis offset to 0.5 but it's not what I want since it's only moving the ticks but not the marks.

  Re: Move bar layer so that the ticks will be between the bars
Posted by at on Apr-12-2022 17:51
Attachments:
Here's the image, did not notice that the first attempt exceeds the max size limit.
Screen Shot 2022-04-12 at 17.33.59 PM-min.png
Screen Shot 2022-04-12 at 17.33.59 PM-min.png

102.33 Kb

  Re: Move bar layer so that the ticks will be between the bars
Posted by Peter Kwan on Apr-12-2022 19:08
Hi at,

ChartDirector allows you to move the ticks, the labels, the marks and/or the bars. I am not sure how you configure the x-axis and position the bars. Is the x-axis configured using Axis.setLabels, in which case the x-axis labels (like "984") are just names for human reading? Or is it a numeric axis configured using Axis.setLinearScale, in which case the bars must be using Layer.setXData to set their x-coordinates.

The following is an example of using a numeric axis for the x-axis:

https://www.advsofteng.com/doc/cdphp.htm#histogram.htm

If your existing chart is a label based axis, shift the mark by 0.5 units will put the mark in between the bars. For example:

$c->xAxis->addMark(1 + 0.5, 0xff0000, $labels[1]);

You can also use Axis.setTickOffset and Axis.setLabelOffset to shift the ticks and the labels by 0.5 units. If the labels 984, 988 refers to the center of the bar, then you should not shift the labels. If they refer to the left and right boundaries of the bar, then you should shift both the ticks and the labels. Of course, you can shift the bars instead, in which case you would need to use Layer.setXData to configure the x-position of the bars.

Regards
Peter Kwan