Page 1 of 1

Trending a primary series

Posted: Tue Jul 15, 2014 12:45 pm
by 16465866
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.

Re: Trending a primary series

Posted: Wed Jul 16, 2014 7:55 am
by narcis
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;

Re: Trending a primary series

Posted: Fri Jul 18, 2014 6:26 am
by 16465866
Hi Narcis,

that will work well. Thank you.

Conutz.