Resizing Chart - axis labels in wrong location

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Nov 18, 2008 2:18 pm

Hi Mike,

We have been investigating the issue here and we agree this should be enhanced and thus we have added this issue (TV52013574) to the defect list to be improved for future versions.

To achieve what you request, in the meantime, you could use code below which sets DataTable tool to a custom position and then its position is assigned depending on how the hcart has been resize:

Code: Select all

procedure TGraphForm.Chart1MouseMove(Sender: TObject; Shift: TShiftState; X,
  Y: Integer);
begin
if (Shift = [ssLeft]) and (chart1.Axes.Bottom.Clicked(x,y)) then
 begin
   Chart1.CustomChartRect := true;
   Chart1.ChartRect.Bottom := y;

   Chart1.Axes.Left.LabelsSize:=-Chart1.Axes.Left.MaxLabelsWidth-5;
   Chart1.Axes.Bottom.LabelsSize:= -Chart1.axes.Bottom.LabelHeight(0)+4;

//   Chart1.Repaint;

    DATA.AutoPosition:=false;
    DATA.Top:= chart1.Axes.bottom.PosAxis + Chart1.Axes.Bottom.LabelsSize + 50;
 end;
end;
We used 5,4, and 50 values so that it looks correctly but you could retrieve such values from axes ticks length and similar properties. LabelHeight(0) is used to set it a little bit to the bottom and can't not be calculated.
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

msimmons
Newbie
Newbie
Posts: 15
Joined: Tue Oct 21, 2008 12:00 am

Post by msimmons » Tue Nov 18, 2008 3:02 pm

Hi Narcis,

Yes, that is much better!

But I still have a problem with the left axis title. Instead of painting to the left of the axis, it paints to the right. I cannot find a property that will let me adjust that position. Is there a way to adjust this?

Regards,
Mike Simmons

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 Nov 19, 2008 7:36 am

Hi Mike,

Sorry, we forgot that. In that case you should hide left axis title and manually paint it in TeeChart's canvas:

Code: Select all

procedure TGraphForm.Chart1AfterDraw(Sender: TObject);
var x,y: Integer;
    tmpStr: String;
begin
  tmpStr:='my title';
  x:=Chart1.Axes.Left.PosAxis - 50;
  y:=(Chart1.Height div 2) - (Chart1.Canvas.TextWidth(tmpStr) div 2);
  Chart1.Canvas.RotateLabel(x,y,tmpStr,90);
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

msimmons
Newbie
Newbie
Posts: 15
Joined: Tue Oct 21, 2008 12:00 am

Post by msimmons » Thu Nov 20, 2008 1:58 pm

That worked well.

Thank you Narcis

Best Regards,
Mike Simmons

darcy
Newbie
Newbie
Posts: 16
Joined: Mon Sep 14, 2009 12:00 am

Re: Resizing Chart - axis labels in wrong location

Post by darcy » Sun Jan 24, 2010 10:51 am

Folks,
I too have an issue with the position of my axis title being drawn to the right of the left axis. It is connect to a chart which has been defined using CustomRect. Has TeeChart been updated with a property to allow the title to be flipped from one side to the other. Note: title not labels. I understand the title position can be drawn manually on the canvas in the after draw event, however I would prefer not too.

I am using TeeChart 8.06.

Thanks
D'Arcy

>>But I still have a problem with the left axis title. Instead of painting to the left of the axis, it paints to the right. I cannot find a property that will let me adjust >>that position. Is there a way to adjust this?

Yeray
Site Admin
Site Admin
Posts: 9602
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Resizing Chart - axis labels in wrong location

Post by Yeray » Mon Jan 25, 2010 9:41 am

Hi D'Arcy,

You can try setting a TitleSize different to 0:

Code: Select all

  Chart1.Axes.Left.TitleSize:=-Chart1.Axes.Left.MaxLabelsWidth;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

darcy
Newbie
Newbie
Posts: 16
Joined: Mon Sep 14, 2009 12:00 am

Re: Resizing Chart - axis labels in wrong location

Post by darcy » Mon Jan 25, 2010 11:43 am

Hi Yeray,
Thanks for the prompt reply. Your suggestion using TitleSize does allow the axis title to be 'flipped' to the other side of the axis, however it also moves the axis labels themselves. Do I have to counter-act this in some way. E.g. TitleSize successfully moved title from right of left axis to left of left axis, however the axis labels still remain to the left of axis title. Both the labels and the title are on the correct side of the axis, they just need to be swapped.

Yeray
Site Admin
Site Admin
Posts: 9602
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Resizing Chart - axis labels in wrong location

Post by Yeray » Mon Jan 25, 2010 4:16 pm

Hi D'Arcy,

I'm not sure to see how are you drawing your axis labels. Here is an example that uses CustomChartRect and shows how to draw the left axis title at the left of the axis and the left axis labels at the right of the axis.

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
begin
  Chart1.Axes.Left.TitleSize:=-1;//-(Chart1.Axes.Left.MaxLabelsWidth+Chart1.Axes.Left.TickLength+5);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1.Legend.Visible:=false;
  Chart1.View3D:=false;
  Chart1.Axes.Left.Title.Caption:='my axis title';

  Chart1.CustomChartRect:=true;
  with Chart1.ChartRect do
  begin
    Left:=50;
    Right:=Left+400;
    Top:=50;
    Bottom:=Top+300;
  end;
end;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

darcy
Newbie
Newbie
Posts: 16
Joined: Mon Sep 14, 2009 12:00 am

Re: Resizing Chart - axis labels in wrong location

Post by darcy » Wed Jan 27, 2010 3:39 pm

Yeray,
Problem resolved. Thanks for the help. After a bit of redesign and playing with the TitleSize I have been able to order and align my axes correctly.

Regards,
D'Arcy

Yeray
Site Admin
Site Admin
Posts: 9602
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Resizing Chart - axis labels in wrong location

Post by Yeray » Wed Jan 27, 2010 4:53 pm

Hi D'Arcy,

I'm glad to hear that! You're welcome.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply