Delphi 添加TeeChart函数数据源会导致访问冲突

Delphi 添加TeeChart函数数据源会导致访问冲突,delphi,vcl,teechart,delphi-10-seattle,Delphi,Vcl,Teechart,Delphi 10 Seattle,我使用的是Delphi 10西雅图订阅更新1和TeeChart标准v2015.15.150420,它们与Delphi捆绑在一起 我将TDBChart组件放在新VCL应用程序的空白表单上。然后,我使用在表单的OnCreate事件中找到的“添加函数”教程中概述的示例代码。有了这段代码,一切都正常工作,我得到了两个带样本值的条形序列和一个代表两个条形序列平均值的直线序列 如果我不希望平均值用直线序列表示,而是用条形序列表示,那么问题就来了。如果我将TLineSeries更改为TBarSeries并运行

我使用的是Delphi 10西雅图订阅更新1和TeeChart标准v2015.15.150420,它们与Delphi捆绑在一起

我将TDBChart组件放在新VCL应用程序的空白表单上。然后,我使用在表单的OnCreate事件中找到的“添加函数”教程中概述的示例代码。有了这段代码,一切都正常工作,我得到了两个带样本值的条形序列和一个代表两个条形序列平均值的直线序列

如果我不希望平均值用直线序列表示,而是用条形序列表示,那么问题就来了。如果我将TLineSeries更改为TBarSeries并运行该程序,则在将第一个条形系列作为数据源添加到函数系列(tmpLineSeries)时会导致“0x0066d665处的访问冲突:读取地址0x00000198”,例如
tmpLineSeries.DataSources.Add(tmpBarSeries1)

这是问题代码(请参阅下面的“此处发生AV”)。请注意,如前所述,与工作教程示例相比,唯一更改的代码是已更改为TBarSeries类型而不是TLineSeries类型的tmpLineSeries:

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;
这似乎是TeeChart中的一个错误,或者我缺少了BarSeries所需的配置步骤,而LineSeries则不需要


有人能看到我做错了什么,或者建议解决这个bug吗?我不认为在现阶段升级到最新版本的TeeChart是一种选择,因为据我所知,这只能通过升级Delphi(我已经在更新Delphi)或购买独立版本的TeeChart来实现。

这对我来说似乎是一个bug。我已将其添加到。我能想到的唯一解决办法是将属性设置为大于零的值,这样就不会执行有问题的代码。例如:

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

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

更新:这已在下一个TeeChart版本中修复。

谢谢!你建议的解决办法有效。还感谢您报告错误并将其修复。