0

I'm using a TDBChart to display 3 barseries of the data. Can you point me to a good example of adding a trend line to each barseries? The example that comes with TeeChart download is not at all helpful.

Thanks

Narcís Calvet
  • 7,304
  • 5
  • 27
  • 47

1 Answers1

1

Here you have a simple example of creating 3 TBarSeries with random values and then creating 3 TTrendFunction (with their respective TLineSeries):

uses Series, CurvFitt;

procedure TForm1.FormCreate(Sender: TObject);
var
  tmpBar:TBarSeries;
  tmpTrend:TTrendFunction;
  tmpLine: TLineSeries;
  i, nSeries: Integer;
begin
  Chart1.Legend.Visible:=false;
  Chart1.View3D:=false;

  for i:=0 to 2 do
  begin
    tmpBar:=Chart1.AddSeries(TBarSeries) as TBarSeries;
    with tmpBar do
    begin
      Marks.Visible:=false;
      FillSampleValues;
    end;
  end;

  nSeries:=Chart1.SeriesCount;

  for i:=0 to nSeries-1 do
  begin
    tmpBar:=Chart1[i] as TBarSeries;
    tmpTrend:=TTrendFunction.Create(Self);
    tmpTrend.Period:=3;

    tmpLine:=Chart1.AddSeries(TLineSeries) as TLineSeries;
    with tmpLine do
    begin
      Color:=tmpBar.Color;
      SetFunction(tmpTrend);
      DataSource:=tmpBar;
    end;
  end;
end;
Yeray
  • 5,009
  • 1
  • 13
  • 25