Page 1 of 1

Axistitle above the axis

Posted: Tue Apr 05, 2005 12:20 pm
by 6929966
Hello

I have a question about the axis.title:
The Text appears always in the middle of the axis. Can i move this label and place it above the axis?

Greetings
Elric

Posted: Tue Apr 05, 2005 12:28 pm
by narcis
Hello Elric,

I'm afraid not. You can change it's size and angle but not the position. However you can draw directly on the canvas so that you can place your "custom title" wherever you want.

For help on how to draw on the canvas please have a look at Tutorial 13 - Custom Drawing on the Chart Panel. The tutorials are available at the TeeChart program group.

Posted: Tue Apr 05, 2005 2:25 pm
by 6929966
Hello Narcis
Thanks for your answer. So, placing the label needs a little bit more location-calculation, but it works. :)
Greetings
Elric

Posted: Fri Apr 08, 2005 11:32 am
by 6929966
Hello Narcis

I still have serveral problems to place the custom label at the correct position above the axis, because the number and position of the axes are variable (user can make series and axes (in)visible). So i have between 1 and 10 axes on the left side and the legend above.
The problem is the following: Because of the variable number of series, the height of legend is not fix and so the height of the left axes depends on the height of the legend. How can i calculate the "Top"-value of my custom labels, if i dont know the height of the axes. The "Left"-value is a problem, too, because i only have the relative position (to the chart) of the axis.
Do you have any idea?

Greetings
Elric

Posted: Fri Apr 08, 2005 4:06 pm
by narcis
Hi Elric,

Yes, you can get the axes size and position implementing the AfterDraw event like:

Code: Select all

		private void tChart1_AfterDraw(object sender, Steema.TeeChart.Drawing.Graphics3D g)
		{
			int Size = tChart1.Axes.Left.IAxisSize;

			tChart1.Axes.Left.PositionUnits = Steema.TeeChart.PositionUnits.Pixels;
			int Pos=tChart1.Axes.Left.Position;

			label1.Text="Left Axis Size: " + Size.ToString() + ", Lext Axis Position: " + Pos.ToString(); 
		}

Posted: Tue Apr 12, 2005 12:23 pm
by 6929966
Hello Narcis

Thank you again for your answer. I always ignored the "IAxisSize", maybe because I presumed its a interface not a public integer. I hope you accept my excuse.

So the space above the axis is

Code: Select all

 Axis.IEndPos - Axis.Size
May I ask you for another hint for calculating axis position. Because I have up to 10 axes on left side and all have very different values, so the axis all has different width. (f.e. I have axis labels with "100000" and other axis with "0.1"). At the moment I calculate the width of a axis like this:

Code: Select all

o.Axis.Labels.LabelWidth(Trend.Axis.Maximum) + o.Axis.Ticks.Length + 8
In most cases I get the correct width, but not always (f.e. if the "Maximum" has the not biggest text). Is there a easier way to get the width of a axis?

Thank you. Greetings,
Elric

Posted: Tue Apr 12, 2005 4:03 pm
by narcis
Hi Elric,
I hope you accept my excuse.
Don't mention it :)!
May I ask you for another hint for calculating axis position.
Yes, you can use:

Code: Select all

			tChart1.Axes.Bottom.PositionUnits = Steema.TeeChart.PositionUnits.Pixels;
			tChart1.Axes.Bottom.Position = 5;
Using this code you set screen co-ordinate where axis is drawn, or to set the axis relative position to the chart use:

Code: Select all

			tChart1.Axes.Bottom.PositionUnits = Steema.TeeChart.PositionUnits.Pixels;
			tChart1.Axes.Bottom.RelativePosition = 5;
Is there a easier way to get the width of a axis?
Yes, use tChart1.Axes.Bottom.AxisPen.Width.

Posted: Wed Apr 13, 2005 8:16 am
by 6929966
Hello Narcis

Thats not what I wanted, sorry. Maybe I described my problem misrepresent. I know how to set the position of a axis, what I wanted is a easier way to calculate the correct position of the axes, so that they dont overlap. The property "tChart1.Axes.Bottom.AxisPen.Width" only shows the width of the pen, that draws that single axis line.
I need the whole space a (left) axis (including labels) needs: it is the sum of
Width of the axis line (AxisPen.Width),
Lenght of the major ticks (Axis.Ticks.Length) and
Lenght of the longest AxisLabel (to get this, I must look over all AxisLabels and search for the longest value).

My question is: exists a property that gives me that sum, or must I calculate thís sum as described above? (If you dont have a answer right now, dont matter, because my code works at the moment, its even very inconvenient).

Greetings,
Elric

Posted: Wed Apr 13, 2005 10:09 am
by narcis
Hello Elric,

Thanks for your explanation and sorry for not having understood what you request before. No, there's not a property that gives you that dimension, you have to calculate it.