Steema Issues Database

Note: This database is for bugs and wishes only. For technical support help, if you are a customer please visit our online forums;
otherwise you can use StackOverflow.
Before using this bug-tracker we recommend a look at this document, Steema Bug Fixing Policy.



Bug 243 - [TV52016283] There is a customer who would like to export the series data to a csv...
Summary: [TV52016283] There is a customer who would like to export the series data to ...
Status: RESOLVED FIXED
Alias: None
Product: VCL TeeChart
Classification: Unclassified
Component: Export (show other bugs)
Version: unspecified
Hardware: All All
: Normal major
Target Milestone: ---
Assignee: Steema Issue Manager
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-07-31 12:15 EDT by yeray alonso
Modified: 2013-12-03 09:28 EST (History)
1 user (show)

See Also:
Chart Series: ---
Delphi / C++ Builder RAD IDE Version:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description yeray alonso 2013-11-20 10:34:13 EST
There is a customer who would like to export the series data to a csv, but only for the active series.
I see 2 Options (second more flexible):
Option1: We could add a new boolean (ie AllSeries) to set if all the series should be considered or only the active (all by default, to preserve backwards compatibility).
In TeeStore.pas, in the TSeriesDataText.PointToString function the following code is executed:
  if Assigned(Series) then
     DoSeries(Series)
  else
  for t:=0 to Chart.SeriesCount-1 do
      DoSeries(Chart[t]);
We could modify it for the following:
  if Assigned(Series) then
     DoSeries(Series)
  else
  for t:=0 to Chart.SeriesCount-1 do
      if AllSeries or Chart[t].Active then DoSeries(Chart[t]);

There is at least another place where we should add this extra verification.
The Header function is a nested function into TSeriesDataText.AsString function (still in TeeStore.pas). At the end, it says:
    if Assigned(Series) then
       result:=result+HeaderSeries(Series)
    else
    if Chart.SeriesCount>0 then
    begin
      result:=result+HeaderSeries(Chart[0]);
      for t:=1 to Chart.SeriesCount-1 do
          result:=result+TextDelimiter+HeaderSeries(Chart[t]);
    end;
So we should modify it to also add the header only when needed:
    if Assigned(Series) then
       result:=result+HeaderSeries(Series)
    else
    if Chart.SeriesCount>0 then
    begin
      if AllSeries or Chart[0].Active then result:=result+HeaderSeries(Chart[0])+TextDelimiter;
      for t:=1 to Chart.SeriesCount-1 do
          if AllSeries or Chart[t].Active then result:=result+HeaderSeries(Chart[t])+TextDelimiter;
    end;
-----
Option2: Alternativelly, we could make the Series property in TSeriesDataText to accept an array of series. This would allow the user to export only the desired series. This would be more flexible.
http://www.teechart.net/support/viewtopic.php?f=3&t=13447&p=58855#p58855 [created:2012-07-31T11:15:50.000+01:00 reported by:yeray@steema.com reported in version:2012.06.120613 (TeeChart VCL)]
Comment 1 david berneda 2013-12-03 09:28:09 EST
This wish has been implemented, at the base class TSeriesData (TeeStore.pas unit), so all derived export format classes now have a new property (an array of Series) to filter which Series should be exported.

This applies to TSeriesDataText (txt, csv), TSeriesDataXML (xml), TSeriesDataHTML (html <table>), TSeriesDataXLS (Excel) and TSeriesDataJSON (json).

Usage example:

uses TeeStore;

procedure TForm1.FormCreate(Sender: TObject);
var data : TSeriesDataText;
begin
  data:=TSeriesDataText.Create(Chart1);

  data.IncludeHeader:=True;
  
  data.SeriesList.Clear;

  // Add only the Series you want to export:

  data.SeriesList.Add(Series3);
  data.SeriesList.Add(Series5);
  data.SeriesList.Add(Series6);

  Memo1.Text:=data.AsString;

  data.Free;
end;