Problems using a function at runtime

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
STC
Newbie
Newbie
Posts: 23
Joined: Wed Mar 10, 2004 5:00 am

Problems using a function at runtime

Post by STC » Tue Jan 17, 2006 1:18 pm

Hello

I am trying to add a RMS function series to my chart.

When I try to view my chart the new series that should have been added is not displayed, and I get an access violation

I am trying to do this at runtime, but I cant see that this should cause a problem?

Is it important what I use as the owner?

I have used the line below

objChart.Chart.Series[0].SetFunction(TRMSFunction.Create(objChart.Chart.Series[0]));

where objChart is my chart

Cheers

Paul

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Post by Narcís » Tue Jan 17, 2006 1:50 pm

Hi Paul,

Have you read "Tutorial 7 - Working with Functions"? You'll find the tutorials at the "Docs" folder in the TeeChart program group.

BTW: It works fine here, you should do something like:

Code: Select all

procedure TForm1.FormCreate(Sender: TObject);
var
  tmpBarSeries1,tmpBarSeries2:TBarSeries;
  tmpLineSeries:TLineSeries;
begin
  With Chart1 do
  begin
    //Add 2 data Series
    tmpBarSeries1:=TBarSeries.Create(self);
    tmpBarSeries2:=TBarSeries.Create(self);
    AddSeries(tmpBarSeries1);
    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:=TLineSeries.Create(self);
    AddSeries(tmpLineSeries);
    //Define the Function Type for the new Series
    tmpLineSeries.SetFunction(TRMSFunction.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 );
    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;
end;
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

STC
Newbie
Newbie
Posts: 23
Joined: Wed Mar 10, 2004 5:00 am

Post by STC » Tue Jan 17, 2006 2:55 pm

Thanks for this

I will give this a go now

My chart is set up inside a report builder report. I would prefer to have the series added and set up ready to go at design time so that when the report template is loaded my chart is just ready for the data

However, as soon as I put a series with a function onto my chart, my application goes mental when I close, do you know of any issues with objects being freed twice? When using FastMem it shows that an attempt is being made to free a function object twice

I get access violations, invalid pointer operations, etc

Pep
Site Admin
Site Admin
Posts: 3299
Joined: Fri Nov 14, 2003 5:00 am
Contact:

Post by Pep » Fri Jan 20, 2006 12:30 pm

Hi Paul,

I think the problem is a bug in TeeChart code. In short, in combination with Report Builder and if chart series datasource is another series or function, then the destroying mechanism tries to free/destroy series (and functions) which were already freed.

We've fixed the problem for series in TeeChart v7.0 and right now we're tackling the function problem.
A temporary solution/workaround is to disconnect and free functions/series in code at runtime before report (form) is destroyed.

Post Reply