Can I only export active series to a text file.

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
MarcelIbis
Newbie
Newbie
Posts: 9
Joined: Tue Jun 10, 2008 12:00 am

Can I only export active series to a text file.

Post by MarcelIbis » Wed Jul 25, 2012 8:16 am

Hello,

I'm using the TSeriesDataText to export the data to a text (csv) file. The user can activate and de-activate the series and wants only the active series to be exported.
I noticed that all the series (active and de-active) are exported to the text file.

Is there a way to only export the active series.

Thanks in advance.

Marcel

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Can I only export active series to a text file.

Post by Yeray » Thu Jul 26, 2012 9:31 am

Hi Marcel,
MarcelIbis wrote:Is there a way to only export the active series.
I'm afraid not. However you can always do you own exportation method.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

MarcelIbis
Newbie
Newbie
Posts: 9
Joined: Tue Jun 10, 2008 12:00 am

Re: Can I only export active series to a text file.

Post by MarcelIbis » Mon Jul 30, 2012 8:47 am

Hello Yeray,

Thanks for your reply.

I noticed that in the TChartEditor component you have the oportunity to select all sereies or select one serie (see tab Export, Data).
Can this code not be used to add only the active series to the TSeriesDataText component?

If yes, do you have an example how to add series to the TSeriesData component?

I noticed also that the help file Tchart8.hlp is (very) old. Is there a new version available?

Thanks in advance.

Marcel

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Can I only export active series to a text file.

Post by Yeray » Tue Jul 31, 2012 8:39 am

Hi Marcel,
MarcelIbis wrote:I noticed that in the TChartEditor component you have the oportunity to select all sereies or select one serie (see tab Export, Data).
Can this code not be used to add only the active series to the TSeriesDataText component?
I'm afraid not. This is how it's made in TeeStore:

Code: Select all

  if Assigned(Series) then
     DoSeries(Series)
  else
  for t:=0 to Chart.SeriesCount-1 do
      DoSeries(Chart[t]);
Changing the code above for this works as you wish:

Code: Select all

  if Assigned(Series) then
     DoSeries(Series)
  else
  for t:=0 to Chart.SeriesCount-1 do
      if Chart[t].Active then DoSeries(Chart[t]);
But applying this change would break the backwards compatibility. So we should probably add a boolean to control if the Chart[t].Active should be considered or not (not by default, as always).
I've added it to the wish list.
MarcelIbis wrote:I noticed also that the help file Tchart8.hlp is (very) old. Is there a new version available?
Do you see this file in an actual installation of TeeChart VCL v2012.06? I can only find a TeeChart2012.hlp in the Docs folder into the TeeChart installation.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Can I only export active series to a text file.

Post by Yeray » Tue Jul 31, 2012 9:16 am

Hi Marcel,

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.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

MarcelIbis
Newbie
Newbie
Posts: 9
Joined: Tue Jun 10, 2008 12:00 am

Re: Can I only export active series to a text file.

Post by MarcelIbis » Wed Aug 01, 2012 12:52 pm

Hello Yeray

Thank you for your suggestions to improve the export function.

For the time being I use the following workarround:
I delete the non active series before the export as shown below.
Than create the series again.

for i := Chart.SeriesList.Count -1 downto 0 do begin
if not Chart.Series.Active then
Chart.Series.Free;
end;

ExcelData := TSeriesDataText.Create(Chart, nil);
try
ExcelData.TextDelimiter := ';';
ExcelData.IncludeLabels := True;
ExcelData.IncludeHeader := True;
ExcelData.ValueFormat := '0.000 E+0';

ExcelData.SaveToFile(Datafile);

finally
ExcelData.Free;
end;

MakeSeries.

Regards,

Marcel

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Can I only export active series to a text file.

Post by Yeray » Wed Aug 01, 2012 1:36 pm

Hi Marcel,

Right. And instead of removing and recreating the inactive series, you could move them into a temporal list and restore them after exporting the series.
Here it is an example.
However, if you want the order of the series to be maintained, you should improve it.

Code: Select all

uses Series, TeeStore;

procedure TForm1.FormCreate(Sender: TObject);
var i, j: Integer;
begin
  Chart1.View3D:=false;
  Chart1.Legend.CheckBoxes:=true;

  for i:=0 to 5 do
    with Chart1.AddSeries(TBarSeries) do
    begin
      Title:='Series nº' + IntToStr(i+1);
      Color:=OperaPalette[i mod Length(OperaPalette)];
      Marks.Style:=smsValue;
      Active:=(i mod 2 = 0);

      for j:=0 to 5 do
        Add(random*75+25, 'Value nº ' + IntToStr(j+1));
    end;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  ExportActiveSeries;
end;

procedure TForm1.ExportActiveSeries;
var i: Integer;
    tmpSeriesList: TChartSeriesList;
begin
  tmpSeriesList:=TChartSeriesList.Create;

  for i:=Chart1.SeriesCount-1 downto 0 do
  begin
    if not Chart1[i].Active then
    begin
      tmpSeriesList.Add(Chart1[i]);
      Chart1[i].ParentChart:=nil;
    end;
  end;

  with TSeriesDataText.Create(Chart1) do
  begin
    IncludeHeader:=true;
    IncludeLabels:=true;
    ValueFormat:='0.000 E+0';
    TextDelimiter:=';';
    SaveToFile('C:\tmp\testExport.csv');
  end;

  for i:=tmpSeriesList.Count-1 downto 0 do
  begin
    tmpSeriesList[i].ParentChart:=Chart1;
  end;
end;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

MarcelIbis
Newbie
Newbie
Posts: 9
Joined: Tue Jun 10, 2008 12:00 am

Re: Can I only export active series to a text file.

Post by MarcelIbis » Wed Aug 01, 2012 3:15 pm

Hello Yeray

Your workarround works great. :D
Saves time to create and fill the series again!

One minor detail, I had to include the TeEngine unit in the uses clause for version 8.

Thanks for the grear service.

Regards,

Marcel

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Can I only export active series to a text file.

Post by Yeray » Thu Aug 02, 2012 10:48 am

Hi Marcel,

I'm glad to hear it works and you like it! :)
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

David Berneda
Site Admin
Site Admin
Posts: 83
Joined: Wed Nov 12, 2003 5:00 am
Location: Girona, Catalonia
Contact:

Re: Can I only export active series to a text file.

Post by David Berneda » Tue Dec 03, 2013 2:30 pm

A new property in TSeriesData class has been introduced to allow exporting only a selected list of Series.

http://bugs.teechart.net/show_bug.cgi?id=243

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;

MarcelIbis
Newbie
Newbie
Posts: 9
Joined: Tue Jun 10, 2008 12:00 am

Re: Can I only export active series to a text file.

Post by MarcelIbis » Wed Dec 04, 2013 11:59 am

Hello David,

Great! Thanks for this update.
Could every wish of me being solved this way. :wink:

In which version is this implemented?

Regards,

Marcel Horsthuis.

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

Re: Can I only export active series to a text file.

Post by Narcís » Mon Dec 09, 2013 12:09 pm

Hi Marcel,
MarcelIbis wrote: In which version is this implemented?
Not a public version yet but the next maintenance release. It will be announced in this forum and other Steema Software channels as well.
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

Post Reply