Page 1 of 1

Statistics ChartTool

Posted: Fri Dec 03, 2021 6:38 pm
by 16589592
I am running into the following problem
a) I have created a new chart tool
b) I activate the charttool in code
c) I assigned a series to it
d) I have created a Tstring variable to hold results

when running the code I am getting an "access violation" error. See code below

Code: Select all

var
  sLines : TStrings;
  MyPoints: Array [0 .. 10] of TPointSeries;

      //code to format chart
      chartTool3.Active := true;
      chartTool3.Series := MyPoints[iseries];
     //code to populate  MyPoints[iseries] 
    chartTool3.Statistics(sLines); // access violation
Any help would be appreciated

Re: Statistics ChartTool

Posted: Tue Dec 07, 2021 10:14 am
by yeray
Hello,

Give it a try at the example bellow, which seems to work fine for me here. Just drop a TChart and a TMemo into the form at design time.

Code: Select all

uses Series, TeeSeriesStats;

procedure TForm1.FormCreate(Sender: TObject);
var Series1: TLineSeries;
    SeriesStats: TSeriesStatsTool;
begin
  Chart1.View3D:=False;
  Chart1.Legend.Hide;
  Chart1.Gradient.Visible:=False;
  Chart1.Color:=clWhite;
  Chart1.Walls.Back.Gradient.Visible:=False;
  Chart1.Walls.Back.Color:=clWhite;

  Series1:=TLineSeries(Chart1.AddSeries(TLineSeries));
  Series1.FillSampleValues;

  SeriesStats:=TSeriesStatsTool.Create(self);
  with SeriesStats do
  begin
    Series:=Series1;
  end;
  Chart1.Tools.Add(SeriesStats);

  SeriesStats.Statistics(Memo1.Lines);
end;

Re: Statistics ChartTool

Posted: Tue Dec 07, 2021 5:06 pm
by 16589592
That works. Thanks a lot.