Polar Series Labesl

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
Thomas Klingler
Advanced
Posts: 103
Joined: Tue Mar 02, 2004 5:00 am
Location: Bad Wurzach
Contact:

Polar Series Labesl

Post by Thomas Klingler » Mon Mar 14, 2005 3:42 pm

I would like to change the labels for a Polar Series from 0-360 to a 12 hr clock format. I tried to change the labels using:

for(int x=0;x<360;x++){
AnsiString aStr = IntToStr(((360-ang)/30) + 1);
Series1->Labels[x] = aStr;
}

But I still get 0-360 on the chart. I have a couple of other series on the chart as well. I also tried editing the Series "Text" field in the Chart editor on the Series/Data display grid. Still no change. What am I doing or is it not possible?

thanks.
Kev

Marjan
Site Admin
Site Admin
Posts: 745
Joined: Fri Nov 07, 2003 5:00 am
Location: Slovenia
Contact:

Post by Marjan » Mon Mar 14, 2005 4:07 pm

Hi, Kev.

Changing XLabels array won't work in this case as polar labels are "calculated" in the TCustomPolarSeries.GetCircleLabel method. The solution in your case is to derive new series type from TPolarSeries, override it's GetCircleLabel method and change it's implementataion. In your case:

Code: Select all

type
  TPolarSeriesEx = class (TPolarSeries)
  protected
    function GetCircleLabel(Const Angle:Double; Index:Integer):String; override;
  end;

{ TPolarSeriesEx }
function TPolarSeriesEx.GetCircleLabel(const Angle: Double;
  Index: Integer): String;
var tmpAngle : Integer;
begin
  tmpAngle:=Round((360.0-Angle)/30.0);
  result := IntToStr(tmpAngle);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
    Chart1.FreeAllSeries(nil);
    Chart1.AddSeries(TPolarSeriesEx);
    With (Chart1.Series[0] as TPolarSeriesEx) do
    begin
      ClockwiseLabels := True;
      RotationAngle:=90;
      AngleIncrement := 30;
      CircleLabels := True;
      FillSampleValues(10);
    end;
end;
Very similar code can also be used with BCB.
Marjan Slatinek,
http://www.steema.com

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

Post by Narcís » Mon Mar 14, 2005 4:22 pm

Hi Kev,

It may also be of your interest knowing that there's already a clock series type (TClockSeries). This type is available at the "Other" series tab.
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