Page 1 of 1

Changing the chart/series type on the fly

Posted: Wed Nov 22, 2006 3:15 pm
by 9243129
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!

Posted: Wed Nov 22, 2006 3:34 pm
by narcis
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;

Posted: Wed Nov 22, 2006 3:45 pm
by 9243129
Thanks for your swift reply NarcĂ­s, I will try this out and will let you know my results.

Posted: Thu Nov 23, 2006 11:10 am
by 9243129
Ok, it works great! Thanks for the help.