Adding a TeeChart function datasource causes access violation

0

I am using Delphi 10 Seattle Subscription Update 1 and TeeChart Standard v2015.15.150420 which came bundled with Delphi.

I drop a TDBChart component on a new VCL application's blank form. I then use the sample code as outlined in the "Adding a Function" tutorial found at http://www.teechart.net/docs/teechart/vclfmx/tutorials/UserGuide/Tutorials/tutorial7.htm#AddFunction in the form's OnCreate event. With this code everything works as it should and I get two bar series populated with sample values and one line series which represents the average of the two bar series.

The problem comes in if I don't want the average represented by a line series, but rather by, say, a bar series. If I change the TLineSeries to a TBarSeries and run the program, it causes an "access violation at 0x0066d665: read of address 0x00000198" on adding the first bar series as a datasource to the function series (tmpLineSeries), eg. tmpLineSeries.DataSources.Add( tmpBarSeries1 );.

Here's the problem code (see "AV occurs here" below). Note that the only code that changed from the working tutorial example was, as explained, tmpLineSeries that had been changed to a TBarSeries type instead of a TLineSeries type :

procedure TForm1.FormCreate(Sender: TObject);
var tmpBarSeries1,
    tmpBarSeries2 : TBarSeries;
    tmpLineSeries : TBarSeries;
begin
  //Add 2 data Series

  tmpBarSeries1:=TBarSeries.Create(Self);
  tmpBarSeries2:=TBarSeries.Create(Self);

  DBChart1.AddSeries(tmpBarSeries1);
  DBChart1.AddSeries(tmpBarSeries2);

  //Populate them with data (here random)
  tmpBarSeries1.FillSampleValues(10);
  tmpBarSeries2.FillSampleValues(10);

  //Add a series to be used for an Average Function
  tmpLineSeries:=TBarSeries.Create(Self);
  DBChart1.AddSeries(tmpLineSeries);

  //Define the Function Type for the new Series
  tmpLineSeries.SetFunction(TAverageTeeFunction.Create(Self));

  //Define the Datasource for the new Function Series
  //Datasource accepts the Series titles of the other 2 Series
  tmpLineSeries.DataSources.Clear;
  tmpLineSeries.DataSources.Add( tmpBarSeries1 ); ////// AV occurs here!!!
  tmpLineSeries.DataSources.Add( tmpBarSeries2 );

  //    *Note - When populating your input Series manually you will need to
  //    use the Checkdatasource method
  //    - See the section entitled 'Defining a Datasource'
  //Change the Period of the Function so that it groups averages
  //every 2 Points

  tmpLineSeries.FunctionType.Period := 2;
end;

It seems to either be a bug in TeeChart or I am missing a configuration step necessary for BarSeries that is not necessary for LineSeries.

Can anyone see what I am doing wrong, or alternatively suggest a workaround for the bug? I don't think upgrading to the latest version of TeeChart is an option at this stage because, as I understand it, this can only be done by upgrading Delphi (I'm already at the latest update of Delphi), or alternatively purchasing the standalone version of TeeChart.

delphi
vcl
teechart
delphi-10-seattle
asked on Stack Overflow Mar 30, 2016 by Edrean Ernst

1 Answer

0

This looks like a bug to me. I have add it (bug #1484) to Steema Software's bugzilla. The only workaround I can think of is setting TTeeFunction.Period property to a value greater than zero so the offending code is not executed. For example:

  //workaround
  tmpLineSeries.FunctionType.Period:=1;

  tmpLineSeries.DataSources.Add( tmpBarSeries1 ); ////// AV occurs here!!!
  tmpLineSeries.DataSources.Add( tmpBarSeries2 );

UPDATE: This has been fixed for the next TeeChart release.

answered on Stack Overflow Mar 30, 2016 by Narcís Calvet • edited Mar 31, 2016 by Narcís Calvet

User contributions licensed under CC BY-SA 3.0