Steema Issues Database

Note: This database is for bugs and wishes only. For technical support help, if you are a customer please visit our online forums;
otherwise you can use StackOverflow.
Before using this bug-tracker we recommend a look at this document, Steema Bug Fixing Policy.



Bug 1484

Summary: Setting Bar datasources throws an Access Violation error.
Product: VCL TeeChart Reporter: narcís calvet <narcis>
Component: FunctionsAssignee: Steema Issue Manager <issuemanager>
Status: RESOLVED FIXED    
Severity: major    
Priority: High    
Version: 150901   
Target Milestone: ---   
Hardware: PC   
OS: Windows   
URL: http://stackoverflow.com/questions/36306669/adding-a-teechart-function-datasource-causes-access-violation
Chart Series: Bar Delphi / C++ Builder RAD IDE Version:

Description narcís calvet 2016-03-30 10:39:04 EDT
Code below crashes with an Access Violation error when setting first datasource series. If tmpLineSeries is a line series, it works fine. A workaround is setting function's period > 0.

uses Series, TeeFunci;

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;

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

  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;