How can I find the location and size of an axis title?

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
Mike Jones
Advanced
Posts: 192
Joined: Thu Feb 01, 2007 12:00 am
Contact:

How can I find the location and size of an axis title?

Post by Mike Jones » Tue Aug 19, 2008 9:29 pm

I am wanting to place a combobox over the Axis title of the bottom axis of a simple 2D, X-Y chart. I can easily create the combobox, but locating the combobox over the bottom axis title location, has proven to be difficult because the Axis.Title member does not seem to update Left and Top properties.

Is there a way I can get access that that information? I have the source code so if needed I could modify our version of the source to meet our needs.

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

Post by Pep » Wed Aug 20, 2008 11:36 am

Hello Mike,

you can know where the bottom axis title is placed using :

Code: Select all

    private void button1_Click(object sender, EventArgs e)
    {
      String text = "XXXXXXX";
      
      int twidth = (int) tChart1.Graphics3D.TextWidth(text) / 2;
      int xpos = tChart1.Axes.Bottom.IStartPos + (tChart1.Axes.Bottom.IAxisSize / 2) - twidth;
      int ypos = tChart1.Axes.Bottom.Position + tChart1.Axes.Bottom.Labels.Height + tChart1.Axes.Bottom.Ticks.Length +
           tChart1.Axes.Bottom.AxisPen.Width;
      tChart1.Graphics3D.TextOut(xpos, ypos, text);
    }

Mike Jones
Advanced
Posts: 192
Joined: Thu Feb 01, 2007 12:00 am
Contact:

That works!!!

Post by Mike Jones » Wed Aug 20, 2008 3:32 pm

That worked perfectly. Thanks!

Mike Jones
Advanced
Posts: 192
Joined: Thu Feb 01, 2007 12:00 am
Contact:

Almost perfect

Post by Mike Jones » Tue Dec 30, 2008 8:16 pm

I have a small problem. When the Chart is resized the position of my combobox is sometimes off and othertimes it is perfect.

i have a method called SetLocation() where I use the code you suggested to set the position of my combobox. I then have tried various events to call the SetLocation method.

I have tried tchart.Layout, tchart.Resize

Both of these events seem to fire inconsistently or the axis label reports bad position values. About half the time the combobox will not move after I have done something to resize the chart.

Is there another event that would work more consistently?
Is it possible to put an event on the Axis label itself ( I could modify my copy of the source to do this)?

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

Post by Pep » Fri Jan 02, 2009 3:10 pm

Hi Mike,

have you tried to use the OnAfterDraw event ?
About the axis labels, you have the OnGetAxisLabel event which allows to modify the axis labels before to draw, each time that have to be displayed.

Post Reply