Trending a primary series

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Conutz
Newbie
Newbie
Posts: 2
Joined: Wed May 08, 2013 12:00 am

Trending a primary series

Post by Conutz » Tue Jul 15, 2014 12:45 pm

Hi everyone,

I'm plotting a FastLine series with data that's cyclical over time, for example a share price over a couple of years. I'd like to add another series on top of this one that indicates a trend on the original plot. For example when the share price is equal to a particular value, a point is plotted in the new series. I've looked at all the various function types and tools and can't seem to figure out how to do this. Any ideas on how this can be achieved in TeeChart, without crunching the underlying dataset in code?

Thanks,
Conutz.

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Trending a primary series

Post by Narcís » Wed Jul 16, 2014 7:55 am

Hi Conutz,

There's no specific function for that. However, you can use Series OnAfterAdd event, for example:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
var i: Integer;
begin
  for i:=0 to 1000 do
    Series1.Add(i mod 100);
end;

procedure TForm1.Series1AfterAdd(Sender: TChartSeries;
  ValueIndex: Integer);
const
  CompareValue = 50;
var
  tmp: Double;
begin
  tmp:=Series1.YValues[ValueIndex];

  if tmp = CompareValue then
    Series2.AddXY(Series1.XValue[ValueIndex], tmp);
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

Conutz
Newbie
Newbie
Posts: 2
Joined: Wed May 08, 2013 12:00 am

Re: Trending a primary series

Post by Conutz » Fri Jul 18, 2014 6:26 am

Hi Narcis,

that will work well. Thank you.

Conutz.

Post Reply