custom axis title position

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
David Novo
Newbie
Newbie
Posts: 71
Joined: Fri Jul 02, 2004 4:00 am
Location: Culver City
Contact:

custom axis title position

Post by David Novo » Tue Apr 04, 2006 11:44 pm

Hello,

I have modified by chartAxis.positionPercent such that the axes are located at the 0,0 data point

see below:
Image

As you can see in the image, the axis titles are still located just below, and to the left of the axes. What I would like to do is put the axis titles at the bottom and left of the plot. Is there any way to do that? I could not seem to find an AxisTitlePos property or something along those lines.

David Novo
Newbie
Newbie
Posts: 71
Joined: Fri Jul 02, 2004 4:00 am
Location: Culver City
Contact:

Post by David Novo » Wed Apr 05, 2006 2:23 am

Hello,

One idea I stumbled across was to leave the bottomAxis and leftAxis alone, and create custom axes at the zero position of the data. I would only make the title of the left and bottom visible, and would associate the tickmarks and labels with the custom axes. That would give me the effect that I want, with the titles at the bottom and left and the axes at the zero position of the data.

This works great, except that it seems that I can only associate one series with one axis. Does that mean I have to make a second series that is a duplicate of my real data series in order to use the custom axis? I don't want the series to be drawn twice. I don't mind creating a "fake series" as long as I can tell it not to draw its data.

I have done this in a sample app by making a fake series and setting the data source to the real series. However, as soon as I make the fake series invisible, the custom axis for the fake series becomes invisible.

Any help would be appreciated.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Apr 05, 2006 7:36 am

Hi David,

An easy solution would be custom drawing on TeeChart's canvas in the OnAfterDraw event:

Code: Select all

procedure TForm1.Chart1AfterDraw(Sender: TObject);
begin
  With Chart1.Canvas do
  begin
    Font.Color:=clRed;
    Font.Size:=12;
    TextOut((Chart1.Width div 2) - 10,Chart1.ChartRect.Bottom+20,'Bottom title');
    RotateLabel(Chart1.ChartRect.Left-40,(Chart1.Height div 2)+10,'Left title',90);
  end;
end;
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

David Novo
Newbie
Newbie
Posts: 71
Joined: Fri Jul 02, 2004 4:00 am
Location: Culver City
Contact:

Post by David Novo » Wed Apr 05, 2006 2:58 pm

Hi Narcis,

How do I then tell the chart frame to leave room for the title as the chart frame is figuring out its size. Currently, it sizes the chartRect to accomodate the title. If I made the title text blank on the tChartAxis, so it does not show up in the middle of the plot, will the chart leave room at the bottom.

Also, I make use of many of your title properties like the background color, shadow, alignment etc that I will have to duplicate on my own.

Is there a way to get the custom axes to work without making another series?

I did not think this would be such a rare thing? Don't most people put the axes at the zero points of the data? If so, do they all have the axis titles in the middle of the data?

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Wed Apr 05, 2006 3:04 pm

Hi David,
How do I then tell the chart frame to leave room for the title as the chart frame is figuring out its size. Currently, it sizes the chartRect to accomodate the title. If I made the title text blank on the tChartAxis, so it does not show up in the middle of the plot, will the chart leave room at the bottom.
You can set TChart's panel margins:

Code: Select all

  Chart1.MarginLeft:=100;
  Chart1.MarginBottom:100;
This will give you absolute control of where your custom titles are positioned.
Also, I make use of many of your title properties like the background color, shadow, alignment etc that I will have to duplicate on my own.
You can draw a color rectangle and the text over it or use an annotation tool or a rectangel tool which have those features and allow text. The only inconvenient is that the text can not be rotated.
Is there a way to get the custom axes to work without making another series?
Not for now. It is on our wish-list to implemented for future releases that a series can have more than one horizontal and vertical axis associated.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

David Novo
Newbie
Newbie
Posts: 71
Joined: Fri Jul 02, 2004 4:00 am
Location: Culver City
Contact:

Post by David Novo » Fri Apr 07, 2006 11:37 pm

Hi Narcis,

Thanks for the detailed answer.

Do you think I can create a fake series with no data and link it to my custom axis. As long as I set the tickmarks, min max, etc. etc the same on the custom axis as my "real axis", then do you think that should work? I should be able to have my real axis on the bottom showing just the title, and my custom axis anywhere I want showing the tickmarks and labels.

Do you think that has a chance?

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Mon Apr 10, 2006 8:23 am

Hi David,

Yes, that works:

1. Create 2 series, the "real" series and one series without data.
2. Create one horizontal and one vertical custom axis.
3. Associate custom axes to the "real" series.
4. Set custom axes position where you want them to be.
5. Set default left and bottom axes title.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply