Align top and bottom axis grid/labels
Align top and bottom axis grid/labels
Does anyone know how I could align the top axis labels and grid lines to match the bottom axis?
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
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
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
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
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.
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.