Page 1 of 1

TPolarSeries, to draw a semi-circle chart and set the min

Posted: Wed Jan 27, 2016 9:29 am
by 16576306
Hello,
For TPolarSeries, there are some useful properties, such as AngleIncrement, RadiusIncrement, to improve the chart appearance. Can I set the minimum / maximum of Angle, Radius? Can I draw a semi-circle or quarter-circle chart if my series angles are always limited in 180 or 90 degrees?
Best regards,
Xiushan

Re: TPolarSeries, to draw a semi-circle chart and set the min

Posted: Wed Jan 27, 2016 3:45 pm
by yeray
Hello Xiushan,

I'm afraid it's not possible right now so I've added it to the public tracker:
http://bugs.teechart.net/show_bug.cgi?id=1418

However, you could still hide most part of the TPolarSeries and draw your semicircle manually. Ie, you can start with something like this:

Code: Select all

const PolarAngle=180;

procedure TForm1.Chart1BeforeDrawSeries(Sender: TObject);
var polar: TPolarSeries;
begin
  if (Chart1.SeriesCount>0) and (Chart1[0] is TPolarSeries) then
  begin
    polar:=Chart1[0] as TPolarSeries;

    with Chart1.Canvas do
    begin
      Pen.Color:=clLtGray;
      Brush.Clear;
      Pie(polar.CircleRect, 0, PolarAngle);
    end;
  end;
end;

procedure TForm1.FormCreate(Sender: TObject);
var i, n: Integer;
begin
  Chart1.View3D:=false;

  n:=5;
  with Chart1.AddSeries(TPolarSeries) as TPolarSeries do
  begin
    for i:=0 to n-1 do
      AddPolar(i*PolarAngle/n, random*100);

    CircleBrush.Clear;
    CirclePen.Visible:=false;

    OnGetCircleLabel:=PolarGetCircleLabel;
    GetVertAxis.Grid.Visible:=false;
    GetHorizAxis.Grid.Visible:=false;
    GetHorizAxis.Ticks.Visible:=false;
    GetHorizAxis.MinorTicks.Visible:=false;
    Chart1.Axes.Left.Visible:=false;
  end;

  Chart1.Draw;
end;

procedure TForm1.PolarGetCircleLabel(Sender:TCustomPolarSeries; const Angle:Double;
                             Index:Integer; var Text:String);
begin
  if Angle>PolarAngle then
    Text:='';
end;