Move Points

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Nicho
Newbie
Newbie
Posts: 13
Joined: Mon Jul 09, 2007 12:00 am
Location: Adelaide Australia
Contact:

Move Points

Post by Nicho » Thu Mar 18, 2010 3:17 am

Hello,
I have Series1(TLineSeries) on a graph.
After I draw the line on a graph I need all the points of Series1 that have the X values between begin and end of the line moved to the line.
I can replace line with another series (Series2 that will have 2 points 1 - the begining of the line, another - end of the line), but do not know how to find Y value on the line or Series2 if I know the X value (from Series1, that will be the same on the line or Series2). Please help

Yeray
Site Admin
Site Admin
Posts: 9612
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Move Points

Post by Yeray » Fri Mar 19, 2010 11:45 am

Hi Nicho,

If I understand well you would like to do something as following.

Code: Select all

uses series;

procedure TForm1.FormCreate(Sender: TObject);
var Series1: TLineSeries;
    Series2: TPointSeries;
begin
  Chart1.View3D:=false;

  Series1:=Chart1.AddSeries(TLineSeries.Create(self)) as TLineSeries;
  Series1.FillSampleValues();

  Series2:=Chart1.AddSeries(TPointSeries.Create(self)) as TPointSeries;
  Series2.Color:=Series1.Color;
  Series2.AddXY(Series1.XValue[0], Series1.YValue[0]);
  Series2.AddXY(Series1.XValue[Series1.Count-1], Series1.YValue[Series1.Count-1]);
end;
And then if you want you could call a function similar to the following at OnScroll, on Zoom and UndoZoom events:

Code: Select all

procedure TForm1.RecalcPoints;
begin
  Series2.XValue[0]:=Series1.XValue[Series1.FirstDisplayedIndex];
  Series2.YValue[0]:=Series1.YValue[Series1.FirstDisplayedIndex];
  Series2.XValue[1]:=Series1.XValue[Series1.LastDisplayedIndex];
  Series2.YValue[1]:=Series1.YValue[Series1.LastDisplayedIndex];
end;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply