MinYValue and MaxYValue to get X value as date/time?

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Nonstop
Newbie
Newbie
Posts: 1
Joined: Thu Oct 06, 2005 4:00 am
Location: Scottsdale, AZ USA
Contact:

MinYValue and MaxYValue to get X value as date/time?

Post by Nonstop » Fri Nov 04, 2005 5:10 pm

I have a chart with values in the Y axis and date/time on the X axis.

I currently display the Series.MinYValue and Series.MaxYValue but would like to also display date/time from the X axis that coresponds to the min and max.

Also is there a Series Average value available?

Steve...

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 08, 2005 4:29 pm

Hi Steve,

Yes, you can use something like:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
var
  i, YMinIndex, YMaxIndex: Integer;
  avg: double;
begin
  Series1.FillSampleValues();

  YMinIndex:=0;
  YMaxIndex:=YMinIndex;
  Series1.XValues.DateTime := true;
  avg:=Series1.YValues[0];
  for i:=1 to Series1.Count-1 do
  begin
    if Series1.YValues[i]<Series1.YValues[YMinIndex] then YMinIndex:=i
    else if Series1.YValues[i]>Series1.YValues[YMaxIndex] then YMaxIndex:=i;

    avg:=avg+Series1.YValue[i]
  end;

  avg:=avg/Series1.Count;

  Chart1.Title.Text[0]:=DateTimeToStr(Series1.XValue[YMinIndex])+' , '+
          DateTimeToStr(Series1.XValue[YMaxIndex])+'. Average:'+
          FloatToStr(avg);
end;
Also is there a Series Average value available?
See "avg" variable output already added in the code before. You have to calculate this value manually.
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