TPolarSeries, always fills to centre

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
wdsr
Newbie
Newbie
Posts: 1
Joined: Wed Jun 28, 2017 12:00 am

TPolarSeries, always fills to centre

Post by wdsr » Thu Jun 29, 2017 12:34 pm

Hi
I'm trying to fill the points in a TPolarSeries but the fill always includes the centre position (0,0). How do I only fill the area enclosed by the points in the series?

There is a similar positing "Polar Brush always paints to 0,0" from 2008, it appears to be the same issue but I cannot find the solution.

Thanks

Yeray
Site Admin
Site Admin
Posts: 9514
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: TPolarSeries, always fills to centre

Post by Yeray » Fri Jun 30, 2017 11:05 am

Hello,
wdsr wrote:There is a similar positing "Polar Brush always paints to 0,0" from 2008, it appears to be the same issue but I cannot find the solution.
Here the post you mention:
http://www.teechart.net/support/viewtop ... f=4&t=7592

I found a workaround using FOnDrawValue event. Ie:

Code: Select all

uses //... 
  TeEngine;
//...
  private
    procedure ChartDrawValue(Series:TChartSeries; Index:Integer);
//...
uses Chart, TeePolar;

var Chart1: TChart;
    polar: TPolarSeries;

type
  TCustomChartAccess=class(TCustomAxisPanel);
  TCustomPolarSeriesAccess=class(TCustomPolarSeries);

procedure TForm1.CBCustomBrushClick(Sender: TObject);
begin
  Chart1.Draw;
end;

procedure TForm1.CBPolarBrushClick(Sender: TObject);
begin
  if CBPolarBrush.Checked then
     polar.Brush.Style:=bsSolid
  else
    polar.Brush.Clear;
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  Chart1:=TChart.Create(Self);
  Chart1.Parent:=Self;
  Chart1.Align:=alClient;

  Chart1.View3D := false;
  Chart1.Axes.Left.SetMinMax(0, 40);

  polar:=TPolarSeries(Chart1.AddSeries(TPolarSeries));

  polar.Circled := true;
  polar.CloseCircle := true;
  polar.CircleLabels := true;
  polar.ClockWiseLabels := true;
  polar.RotationAngle := 90;
  polar.RadiusIncrement := 10;
  polar.AngleIncrement := 22.5;

  polar.AddPolar(360 - 140, 10);
  polar.AddPolar(360 - 160, 20);
  polar.AddPolar(360 - 180, 30);
  polar.AddPolar(360 - 160, 40);

  TCustomChartAccess(Chart1).FOnDrawValue:=ChartDrawValue;
end;

procedure TForm1.ChartDrawValue(Series:TChartSeries; Index:Integer);
var i: Integer;
    tmpP: TPoint;
    ptsArr: array of TPoint;
begin
  if (Index=0) and CBCustomBrush.Checked then
  begin
    SetLength(ptsArr, polar.Count);

    for i:=0 to polar.Count-1 do
    begin
      tmpP.X:=polar.CalcXPos(i);
      tmpP.Y:=polar.CalcYPos(i);

      ptsArr[i]:=tmpP;
    end;

    Chart1.Canvas.Brush.Color:=polar.Color;
    Chart1.Canvas.Polygon(ptsArr);
  end;

  TCustomPolarSeriesAccess(Series).DrawValue(Index);
end;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Post Reply