Sequence of events

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Gerard
Newbie
Newbie
Posts: 26
Joined: Fri Nov 15, 2002 12:00 am
Location: Australia
Contact:

Sequence of events

Post by Gerard » Fri Dec 12, 2003 2:27 am

I am trying to set the subtitle of my chart to the time/date representation of the span of the X-axis. (eg. 1 Jan 2003 - 30 May 2004).

I am doing this in the 'OnBeforeDrawAxis' event at which time I can access 'Chart->BottomAxis->Minimum' & 'Chart->BottomAxis->Maximum'.

At this stage I set the text of the subtitle by using -

Chart->SubTitle->Text->Text = TDateTime(startTime).DateString() + " to " + TDateTime(endTime).DateString();

Unfortunately, the subtitle does not update with this modified text until the "next" time the chart is re-drawn. If I attempt to capture the bottom axis minimum and maximum values earlier then I may not get the right range (assuming I want to capture the zoomed axis range as well).

Does anyone have any comments about this ?

David.

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

Post by Pep » Fri Dec 12, 2003 4:38 pm

Hi David,

have you tried to add :
Chart1.Draw();
after the Data is added to the Chart ?

Josep Lluis Jorge
http://support.steema.com

Gerard
Newbie
Newbie
Posts: 26
Joined: Fri Nov 15, 2002 12:00 am
Location: Australia
Contact:

re: Sequence of events (sub title)

Post by Gerard » Sun Dec 14, 2003 10:46 pm

Josep,

Executing a Chart.Draw() DOES appear to work but of course causes the chart to be drawn twice which is not the most desirable thing to do. Also, the calling of Draw() needs to be done carefully to ensure that the graph drawing does not end up in an infinite loop.

Bearing in mind that the subtitle content is based on information on the graph and I want the subtitle to be updated automatically with this; is there a better way of solving the problem ?

Regards, David Peacock.

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

Post by Pep » Tue Dec 16, 2003 3:23 pm

A workaround could be to manually draw required text in TChart.OnAfterDraw event using the Canvas.TextOut method.
This way there will be no need to call the Draw method.

Code: Select all

void __fastcall TForm1::Chart1AfterDraw(TObject *Sender)
{
startTime = Chart1->Axes->Bottom->Minimum;
endTime = Chart1->Axes->Bottom->Maximum;
Chart1->Canvas->TextOut(10,10,TDateTime(startTime).DateString() + " to " + TDateTime(endTime).DateString());
}

Josep Lluis Jorge
http://support.steema.com

Post Reply