Page 1 of 1

Move Points

Posted: Thu Mar 18, 2010 3:17 am
by 10046016
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

Re: Move Points

Posted: Fri Mar 19, 2010 11:45 am
by yeray
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;