Page 1 of 1

Polar Series Labesl

Posted: Mon Mar 14, 2005 3:42 pm
by 8443014
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

Posted: Mon Mar 14, 2005 4:07 pm
by Marjan
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.

Posted: Mon Mar 14, 2005 4:22 pm
by narcis
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.