I have an application that relies heavily on TeeChart and I'm trying to write a reporting component on top of it.
In my app the user adds series to a chart and has the option to add functions as well.
I have an XML structure something like this:
Code: Select all
<Chart>
<Series>
<Color>
<Database>
<Dataset>
<Column>
<etc.>
<Functions>
<Function>
<Periods>
<Functions>
<Function>
<Periods>
</Functions>
</function>
</Functions>
</Series>
</Chart>
As you can see the structure includes a node for each series and each series node can have childnodes with functions.
Each function node can then have childnodes with functions ad infinitum.
Now comes the problem of reading the chart.
I can traverse through the chart using a for loop:
Code: Select all
function ReadChartToXML : TStrings;
var
ParentSer : TchartSeries;
XMLStr : TStrings;
begin
for i := 0 to Chart1.SeriesCount -1 do
begin
//Check if the series is a function
if Chart1.Series[i].FunctionType <> nil then
begin
ParentSer := TChartSeries(Chart1.Series[i].DataSource);
// Write the parentSer to an XML structure
XMLStr.Add(<Series>);
XMLStr.Add('the rest of the series properties');
XMLStr.Add('<Functions>');
XMLStr.Add(TTeeFunctionClass(
DBChart1.Series[i].FunctionType.ClassType).ClassName);
XMLStr.Add('Periods of the function');
end;
end;
Also this doesn't take into account functions that use functions as datasources.
So what I'm thinking is some sort of a tree view of the series so that each series get listed and then functions get listed as children of each series and child functions as children of their parent functions.
Is there a way to do this without checking each series multiple times for functions etc.?
It would be great if one could detect if a series is a datasource for functions instead of the other way around.
Any ideas?
Thanks,
nisbus