Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Creating ChartSeries at Runtime from RAP again

edited September 2002 in General
Hi.. Here we go again. :)
It's all working fine, the series are being created, each detail band add a
chartseries. This is what my report looks like, and the code here is just to
show you what i'm doing, he is lil different from this.

Group Header
Detail Band
code:
testbar := TBarSeries.Create(Report);
testBar.ParentChart := Chart.Chart;
testBar.Title := DBTextDescricaoLinha.FieldValue;
Testbar.Add(DBText1.FieldValue, 'Jan', TestBar.SeriesColor);
Group Footer
code:
for i := 0 to Chart.Chart.SeriesCount do
begin
Chart.Chart.RemoveSeries(Chart.Chart.Series[i]); //try
Chart.Chart.ParentChar := SecondChart.Chart;
end;

So, i need that after the footer print the added series to be released.
I'm trying to use the TCustomChart.RemoveSeries method but nothing happens.
Looking at RemoveSeries Help it say that the only code at this method is:
ChartSeries.ParentChart := nil;
So i've put other chart on detailband and i'm trying to change the
parentchart of the series to this second chart. Well, nothing happens again.
I think that the problem is when trying to assign a value tu the ParentChart
property.

I know is annoying but here is the portion of code:

class function TPlanDBChartRTTI.RefClass: TClass;
begin
Result := TCustomChart; //TppDPTeeChart;
end; { class function RefClass() }

class procedure TPlanDBChartRTTI.GetPropList(aClass: TClass; aPropList:
TraPropList);
begin
inherited GetPropList(aClass, aPropList);
aPropList.AddProp('Series');
aPropList.AddProp('SeriesCount');
aPropList.AddProp('Title');
aPropList.AddMethod('AddSeries');
aPropList.AddMethod('RemoveSeries');
end; { class procedure, GetPropList }

class function TPlanDBChartRTTI.GetPropRec(aClass: TClass; const aPropName:
string; var aPropRec: TraPropRec): Boolean;
begin
Result := True;
if ppEqual(aPropName, 'Series') then
begin
AccessSpecifierToRec(aPropName, aPropRec)
end
else if ppEqual(aPropName, 'SeriesCount') then //Integer
begin
PropToRec(aPropName, daInteger, True, aPropRec)
end
else if ppEqual(aPropName, 'Title') then
begin
AccessSpecifierToRec(aPropName, aPropRec)
end
else if ppEqual(aPropName, 'AddSeries') then
MethodToRec(aPropName, True, aPropRec)
else if ppEqual(aPropName, 'RemoveSeries') then
MethodToRec(aPropName, True, aPropRec)
else
Result := inherited GetPropRec(aClass, aPropName, aPropRec);
end; { class function, GetPropRec }

class function TPlanDBChartRTTI.GetParams(const aMethodName: string):
TraParamList;
begin
if ppEqual(aMethodName, 'AddSeries') then
begin
Result := TraParamList.Create;
Result.AddParam('ASeries', daClass, nil, '', True, False);
end
else if ppEqual(aMethodName, 'RemoveSeries') then
begin
Result := TraParamList.Create;
Result.AddParam('ASeries', daObject, TChartseries, '', false, True);
end
else if ppEqual(aMethodName, 'Series') then
begin
Result := TraParamList.Create;
Result.AddParam('Index', daInteger, nil, '', False, False);
Result.AddParam('Result', daObject, TChartSeries, '', False, False);
end
else
Result := inherited GetParams(aMethodName);
end; { class function, GetParams }

class function TPlanDBChartRTTI.CallMethod(aObject: TObject; const
aMethodName: string; aParams: TraParamList; aGet: Boolean): Boolean;
var
lChart: TCustomChart; //TppDPTeeChart;
liIndex: Integer;
lChartSeries: TChartSeries;
lChartTitle: TChartTitle;
begin
Result := True;
lChart := tcustomchart(aObject);
if ppEqual(aMethodName, 'AddSeries') then
begin
aParams.GetParamValue(0, lChartSeries);
lChart.AddSeries(lChartSeries);
end
else if ppEqual(aMethodName, 'RemoveSeries') then
begin
aParams.GetParamValue(0, lChartSeries);
lChart.RemoveSeries(lChartSeries);
//lChartSeries.Free; This generate an AV
// lChartSeries.ParentChart := nil;
end
else if ppEqual(aMethodName, 'Series') then
if aGet then
begin
aParams.GetParamValue(0, liIndex);
Integer(lChartSeries) := Integer(lChart.Series[liIndex]);
aParams.SetParamValue(1, Integer(lChartSeries));
end
else if ppEqual(aMethodName, 'Title') then
if aGet then
begin
lChartTitle := TChart(lChart).Title;
aParams.SetParamValue(0, lChartTitle);
end
else
begin
aParams.GetParamValue(0, lChartTitle);
TChart(lChart).Title := lChartTitle;
end
else
Result := inherited CallMethod(aObject, aMethodName, aParams, aGet);
end; { class function, CallMethod }


TIA.
Valdir and Filipe.

Comments

  • edited September 2002
    Hi Valdir,

    a
    to

    any problems regarding RAP should be better discussed in the RAP news group,
    thankyou.

    regards,
    Chris Ueberall;
  • edited September 2002
    Ok, sorry. So Jim Bennets should said that before.

This discussion has been closed.