Page 1 of 1
Autoadjust of width for y axis?
Posted: Tue Apr 24, 2007 8:32 am
by 9349911
Hi !
I just bought TeeChart Pro and have a little question regarding the Y-axis.
Have a look at this picture:
As you can see the the green axis overwrites the blue one. Is there a possibility to autoadjust custom axis? Or did you have a piece of code to do it manually?
Posted: Tue Apr 24, 2007 10:21 am
by yeray
Hi moelski,
you should try setting different values for the following properties:
Code: Select all
Chart1.CustomAxes.Items[0].PositionUnits:=muPercent;
Chart1.CustomAxes.Items[0].PositionPercent:=-10;
Chart1.MarginLeft:=10;
Also by design-time you can adjust them to your wishes.
And for further information you can take a look at the tutorials:
"Tutorial 2 - Chart display properties" (Margins).
"Tutorial 4 - Axis Control" (Axis position).
Posted: Tue Apr 24, 2007 11:10 am
by 9349911
Hi Yeray,
well that won´t solve my problem...
Chart1.CustomAxes.Items[0].PositionUnits:=muPercent;
Chart1.CustomAxes.Items[0].PositionPercent:=-10;
Chart1.MarginLeft:=10;
This results in the following ...
If you resize the chart size the axis change their distance percental to the width of the chart. That´s not what we want.
The distance between chart and axis should be the same if you resize the chart. This can be done if you use position in pixel and not in %.
The problem is when the Axis values get bigger. Then thy will override the other axis. (See picture). This is what we wanna change. If the axis values are to big, the axis position should be recalculated.
Posted: Thu Apr 26, 2007 8:57 am
by yeray
Hi moelski,
I've sent you a project to show you how to solve your request. You have to calculate your custom (and left) axes positions using basically those functions:
Code: Select all
Chart1.CustomAxes.Items[0].PositionUnits := muPixels; // to count position in pixels
Chart1.CustomAxes.Items[0].PositionPercent := 0; // to place your custom at chart beginning (for example)
Chart1.CustomAxes.Items[0].MaxLabelsWidth // your custom axis labels width in pixels
Chart1.CustomAxes.Items[0].TickLength // your custom axis tick lenght in pixels
So you will be able to do, for example:
Code: Select all
Chart1.CustomAxes.Items[0].PositionPercent := - Chart1.Axes.Left.MaxLabelsWidth - Chart1.Axes.Left.TickLength - 10;
Chart1.MarginLeft := 7;