Align top and bottom axis grid/labels

TeeChart for ActiveX, COM and ASP
Post Reply
Craig
Newbie
Newbie
Posts: 25
Joined: Sat Aug 09, 2003 4:00 am
Location: Calgary, Alberta
Contact:

Align top and bottom axis grid/labels

Post by Craig » Wed Jan 07, 2004 6:13 pm

Does anyone know how I could align the top axis labels and grid lines to match the bottom axis?

Pep
Site Admin
Site Admin
Posts: 3303
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Wed Jan 07, 2004 7:06 pm

Hi Graig,

you should set the same imcrement for both (top and bottom axis) :

TChart1.Axis.Top.Increment = X
TChart1.Axis.Bottom.Increment = X

Josep Lluis Jorge
http://support.steema.com

Craig
Newbie
Newbie
Posts: 25
Joined: Sat Aug 09, 2003 4:00 am
Location: Calgary, Alberta
Contact:

Post by Craig » Wed Jan 07, 2004 9:23 pm

That won't work because they are different units. Plus, the increment has little influence on the interval of the labels themselves.

Any other ideas?

Pep
Site Admin
Site Admin
Posts: 3303
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Fri Jan 09, 2004 9:10 am

No, that I know of. The only way is to :

a) Make sure both axes have the same number of labels displayed. This can be done by setting axis increment property.
b) Both axes start labeling at the same position. This can be to some degree controlled by seting right axis minimum and maximum value.

All in all, not an easy task to do. Alternatively, you could simply hide right axis gridlines and you won't have duplicate gridlines.

Josep Lluis Jorge
http://support.steema.com

Craig
Newbie
Newbie
Posts: 25
Joined: Sat Aug 09, 2003 4:00 am
Location: Calgary, Alberta
Contact:

Post by Craig » Mon Jan 12, 2004 5:33 pm

Here's my solution to this:

OnGetAxisLabel, I get the increment of the first bottom axis label relative to the max value, as a percentage. Then the second increment percentage, between the first label and next label.

Then, OnGetNextAxisLabel, I manually set each label for the top axis.
First Label = max - (Increment1Percentage*(max-min));
Every other label = Previous Label - (Increment2Percentage*(max-min));

Note that this is always based on the bottom axis, so the user can't change the scale of the top axis, that is the next step. And also allow the user to select number of ticks for both top and bottom axes.

Another little problem is that when axis is automatic, TeeChart returns the offset as '0', when it is not. So if the user changes anything, which switches automatic to off, the other axis is not aligned because it still has an offset.

Maybe in the future, TeeChart will fix these and make this process easier.

Post Reply