Controlling the y axis range while paging

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
McMClark
Newbie
Newbie
Posts: 50
Joined: Thu Apr 15, 2004 4:00 am

Controlling the y axis range while paging

Post by McMClark » Fri Nov 03, 2006 5:52 pm

I have a DBChart with integer values on the y axis and dates on the x axis. I have many points and have defaulted to having 10 points per page. I have the left axis min max set to automatic. The problem is that the numbers vary greatly from 1 to 3000. I would like to be able to set the left axis range based on the min and max values based on the points on the page as the user pages through the DBchart.

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 08, 2006 1:00 pm

Hi McMClark,

Yes, you can achieve that doing something like this:

Code: Select all

procedure TForm8.Chart1AfterDraw(Sender: TObject);
var
  locMin,locMax: double;
  i: Integer;
begin
  locMin := Series1.YValues.Value[Series1.FirstValueIndex];
  locMax := locMin;

  for i := Series1.FirstValueIndex+1 to Series1.LastValueIndex do
  begin
    if Series1.YValues[i] < locMin then locMin := Series1.YValues[i];
    if Series1.YValues[i] > locMax then locMax := Series1.YValues[i];
  end;

  With Chart1.Axes.Left do
  begin
    Automatic := false;
    SetMinMax(locMin,LocMax);
    Chart1.Repaint;
  end;
end;

procedure TForm8.ChartPageNavigator1ButtonClicked(Index: TTeeNavigateBtn);
begin
  Chart1.Draw;
end;

procedure TForm8.FormCreate(Sender: TObject);
begin
  Chart1.Draw;
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

Post Reply