List series for XML output

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
nisbus
Newbie
Newbie
Posts: 18
Joined: Wed Jan 18, 2006 12:00 am
Location: Iceland
Contact:

List series for XML output

Post by nisbus » Mon Sep 10, 2007 3:52 pm

Hi,

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>
This is just for illustrative purposes so I've omitted closing tags.
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;
This way I would get one Series Node for each Series but I would also get multiple instances of the same series if more than one functions used the series as a datasource.
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

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

Post by Pep » Mon Sep 17, 2007 4:57 pm

Hi nisbus,

I'm afraid there's not other way to do it. The best one that I can think of is as you do (checking each Series if it is a Function, etc..).

Post Reply