Page 1 of 1

Controlling the y axis range while paging

Posted: Fri Nov 03, 2006 5:52 pm
by 9337074
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.

Posted: Wed Nov 08, 2006 1:00 pm
by narcis
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;