Changing the chart/series type on the fly

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Steve Chamberlain
Newbie
Newbie
Posts: 15
Joined: Mon Nov 20, 2006 12:00 am
Location: The Netherlands
Contact:

Changing the chart/series type on the fly

Post by Steve Chamberlain » Wed Nov 22, 2006 3:15 pm

Hi all,

I am fairly new to the TChart components. I created a polar plot based on a set of series already present in our program. The chart used to be a simple line chart.

Is there any way to loop through the series of my TChart component and switch them to line or polar plot at will? The client would like to have a radio button with the options "Line" and "Polar Plot", with the graph changing appropriately.

Is this easy to do? And if so, a bit of sample code would be very much appreciated!

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

Post by Narcís » Wed Nov 22, 2006 3:34 pm

Hi Steve,

Yes, you can do something like in the What's New?\Welcome!\New in Series\Contour Foot example in the features demo (which uses radio buttons). You'll find the features demo at the program group created by TeeChart's binary installer.

You can also do something like this:

Code: Select all

uses TeePolar;

procedure TForm9.FormCreate(Sender: TObject);
var i: Integer;
begin
  for i := 0 to Chart1.SeriesCount - 1 do
    Chart1[i].FillSampleValues();
end;

procedure TForm9.Button1Click(Sender: TObject);
var
  i: Integer;
  tmp: TChartSeries;
begin
  for i := 0 to Chart1.SeriesCount - 1 do
  begin
    tmp:=Chart1[i];

    if (tmp is TLineSeries) then
      ChangeSeriesType(tmp,TPolarSeries)
    else
      ChangeSeriesType(tmp,TLineSeries);
  end;
end;
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

Steve Chamberlain
Newbie
Newbie
Posts: 15
Joined: Mon Nov 20, 2006 12:00 am
Location: The Netherlands
Contact:

Post by Steve Chamberlain » Wed Nov 22, 2006 3:45 pm

Thanks for your swift reply Narcís, I will try this out and will let you know my results.

Steve Chamberlain
Newbie
Newbie
Posts: 15
Joined: Mon Nov 20, 2006 12:00 am
Location: The Netherlands
Contact:

Post by Steve Chamberlain » Thu Nov 23, 2006 11:10 am

Ok, it works great! Thanks for the help.

Post Reply