Change dynamically the Bottom Axis Title

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Piero
Newbie
Newbie
Posts: 3
Joined: Mon Jan 07, 2013 12:00 am

Change dynamically the Bottom Axis Title

Post by Piero » Tue Jan 22, 2013 3:12 pm

Hello,
I have an application in which I want to dynamically change the bottom axis title caption of a TChart.
In fact in the chart I have some TLineSeries representing time course of a variable, so the bottom axis is the time scale.
I want to show the current time value (depending from the application status) in the bottom axis title caption.
To do this, I simply added some code in the Chart.OnAfterDraw event handler to set the new value of Chart.BottomAxis.Title.Caption.
But the title caption text that I set is not displayed, I need to force another TChart refresh to display it and this slows down the application.
Could you please help me?
I'm using VCL2011 for RAD Studio XE.

Thank you very much.
Piero

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Change dynamically the Bottom Axis Title

Post by Sandra » Wed Jan 23, 2013 9:59 am

Hello Piero,

I can not reproduce your problem using next code in last version of TeeChartVCL2012:

Code: Select all

procedure TForm1.Button1Click(Sender: TObject);
begin
Series1.FillSampleValues(10);
end;

procedure TForm1.Chart1AfterDraw(Sender: TObject);
begin
Chart1.Axes.Left.Title.Caption:= 'Title:'+ IntToStr(Index1);
Index1:= Index1+1;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
Chart1.View3D:= False;
Series1.FillSampleValues(10);
Chart1.Axes.Left.Title.Visible:=True;
Index1:=0;
Chart1.Draw;
end;
Check if my previous code works in your your version of TeeChartVCL, if it work please try to use it to solver your problem in your application.
On the other hand, would be very grateful, if you can check your project using the TeeChartVCL 2012 Evaluation version, and tell us if your problem appears using last version of TeeChartFor.Net. If your problem persist using last version, please try to arrange a simple code because we can reproduce your problem here and try to find a solution for you.


Thanks,
Best Regards,
Sandra Pazos / 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

Piero
Newbie
Newbie
Posts: 3
Joined: Mon Jan 07, 2013 12:00 am

Re: Change dynamically the Bottom Axis Title

Post by Piero » Wed Jan 23, 2013 11:47 am

Hello Sandra,
your code works in my TeeChart VCL. By comparing it with my application, I discovered that the problem occurs when there are two forms,
that is one form containing the TChart, and the second form that indirectly sets the TChart title caption.
I attach a simple two forms project made with Delphi XE to this post so you can try to reproduce the problem, or tell me if there is something I'm doing wrong.
Thank you very much for your support.
Regards,
Piero
Attachments
BottomAxisPrj.zip
Sample Project
(88.39 KiB) Downloaded 334 times

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

Re: Change dynamically the Bottom Axis Title

Post by Narcís » Thu Jan 24, 2013 11:19 am

Hi Piero,

Thanks for the example project. What about updating the bottom axis title at the ChangeValueIndex method so you don't need to repaint the chart to update it? Here's the code modified:

Code: Select all

procedure TForm14.ChangeIndexValue(NewVal: integer);
begin
   IndexValue:=NewVal;
   Label1.Caption:='Index1: '+IntToStr(IndexValue);
   //Chart1.Refresh;
   Chart1.Axes.Bottom.Title.Caption:= XAxisTitle+ IntToStr(IndexValue);
end;

procedure TForm14.Chart1AfterDraw(Sender: TObject);
begin
   //Chart1.Axes.Bottom.Title.Caption:= XAxisTitle+ IntToStr(IndexValue);
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

Piero
Newbie
Newbie
Posts: 3
Joined: Mon Jan 07, 2013 12:00 am

Re: Change dynamically the Bottom Axis Title

Post by Piero » Thu Jan 24, 2013 1:12 pm

Hello Narcis,
you're right, in this way it works. I put the code in th OnChartAfterDraw event just because in that event handler there is some other code, but I can also use an external procedure as you suggested.
So thank you very much for your support!
Best Regards,
Piero

Post Reply