vertically scaling each page

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
pssdelphi
Newbie
Newbie
Posts: 29
Joined: Thu Oct 21, 2004 4:00 am

vertically scaling each page

Post by pssdelphi » Wed Jan 18, 2017 10:45 pm

What is the best way to vertically scale each page of a series on a scrollable chart to full the entire chart display height? Scrollable like in your Tee#New.exe 'Scrollbar' example.
Unless there is a built in way that I do not know about, I am assuming that one must find the min & max values that are in the currently viewible series portion and scale with
Series1.GetVertAxis.SetMinMax(PageLow, PageHigh);
Is there another / built-in way?

Thanks,
Dave

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

Re: vertically scaling each page

Post by Sandra » Thu Jan 19, 2017 11:49 am

Hello Dave,

I have made a simple code where I have used a Scrollbar component vertically. Below you can show the code:

Code: Select all

uses Chart, TeeScroB, Series,TeeThemes;
var Chart1: TChart;
    ScrollBar1: TChartScrollBar;
    horizLine1: THorizLineSeries;
   LookoutT: TLookoutTheme;

procedure TForm1.FormCreate(Sender: TObject);
begin

   Chart1 := TChart.Create(Self);
   Chart1.Parent := Self;
   Chart1.Align := alClient;
   LookoutT := TLookoutTheme.Create(Chart1);
    LookoutT.Apply;

   horizLine1:=Chart1.AddSeries(THorizLineSeries) as THorizLineSeries;
   horizLine1.FillSampleValues(20);
   Chart1.Axes.Left.SetMinMax(0, 1);
   ScrollBar1 := TChartScrollBar.Create(Self);
   ScrollBar1.Parent := Self;
   ScrollBar1.Align := alRight;
   ScrollBar1.Kind := sbVertical;
   ScrollBar1.Width := 17;
   ScrollBar1.Min := 0;
   ScrollBar1.Max := 100;
   ScrollBar1.Chart := Chart1;
   ScrollBar1.RecalcPosition();
end;
Could you confirm us if it works in the way you want?

Thanks in advance
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

pssdelphi
Newbie
Newbie
Posts: 29
Joined: Thu Oct 21, 2004 4:00 am

Re: vertically scaling each page

Post by pssdelphi » Thu Jan 19, 2017 5:13 pm

I am referring to the vertical scaling of the chart to fill the chart window as the serires is scrolled not the orientation of the chart or the scrollbar. Here is a sample of what I am talking about that I would like to know if there is a simpler or built-in way other then what I have done.

Code: Select all

const
  PointsPerPage = 20;
  RightEdgePad = 2;
  VertPad = 2;
  TotalPoints = 100;

var
  Form1: TForm1;
  Chart1: TChart;
  ScrollBar1: TChartScrollBar;
  Line1: TLineSeries;

procedure TForm1.FormCreate(Sender: TObject);
begin
   Chart1 := TChart.Create(Self);
   Chart1.Parent := Self;
   Chart1.Align := alClient;
   Chart1.Legend.Visible := false;

   Line1 := Chart1.AddSeries(TLineSeries) as TLineSeries;
   Line1.FillSampleValues(TotalPoints);
   Chart1.Axes.Bottom.SetMinMax(0,  PointsPerPage - 1);
   ScrollBar1 := TChartScrollBar.Create(Self);
   ScrollBar1.Parent := Self;
   ScrollBar1.Align := alBottom;
   ScrollBar1.Kind := sbHorizontal;
   ScrollBar1.Width := 17;
   ScrollBar1.Min := 0;
   ScrollBar1.Max := TotalPoints - 1;// - PointsPerPage;
   ScrollBar1.SmallChange := 1;
   ScrollBar1.Chart := Chart1;
   ScrollBar1.OnChange := ScrollBar1Change;
   ScrollBar1Change(nil);
   ScrollBar1.RecalcPosition();
end;

procedure TForm1.ScrollBar1Change(Sender: TObject);
const
  VertSentLowVal = 1000000;
var
  ci, LeftViewTickPos, RightViewTickPos: integer;
  PageLow, PageHigh, VRange: double;
  ts: string;
begin
    PageLow := VertSentLowVal;
    PageHigh := 0;
    if ScrollBar1.Position > PointsPerPage then
      LeftViewTickPos := ScrollBar1.Position
    else
      LeftViewTickPos := 0;
    RightViewTickPos := ScrollBar1.Position + PointsPerPage - 1; 
    if RightViewTickPos > TotalPoints then begin
      RightViewTickPos := TotalPoints;
    end;
    with Line1 do begin
    for ci := LeftViewTickPos to RightViewTickPos do begin
      if YValue[ci] > 0 then begin
        if YValue[ci] < PageLow then
          PageLow := YValue[ci];
        if YValue[ci] > PageHigh then
          PageHigh := YValue[ci];
      end;
    end;
    if PageLow <> VertSentLowVal then begin   // do not scale if no Ticks visible
      GetVertAxis.SetMinMax(PageLow, PageHigh);
    end;
    end; // with
  end;

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

Re: vertically scaling each page

Post by Sandra » Fri Jan 20, 2017 4:20 pm

Hello Dave,

If I understand well, you want scroll the vertical axis at same time you scroll horizontal axis through the ChartBarScroll component, is that?
In that case, the code you use is correct to achieve your request, so you need change the axes scale in the ChartBarScroll Change events always.

Thanks in advance
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

pssdelphi
Newbie
Newbie
Posts: 29
Joined: Thu Oct 21, 2004 4:00 am

Re: vertically scaling each page

Post by pssdelphi » Fri Jan 20, 2017 5:17 pm

Thanks Sandra for looking it over. Since what I was doing was typical for financial use, I thought there was probably a built-in way to do the same that I was over looking.

Dave

Post Reply