TDonutSeries with DonutPercent

TeeChart VCL for Borland/CodeGear/Embarcadero RAD Studio, Delphi and C++ Builder.
Post Reply
bdw
Advanced
Posts: 130
Joined: Mon Mar 07, 2005 5:00 am
Location: New Zealand
Contact:

TDonutSeries with DonutPercent

Post by bdw » Wed Feb 13, 2019 2:09 am

Hi,

Just trying to work out an issue I'm getting with the TDonutSeries when using the DonutPercent value which used to display correctly on an older TChart version but getting an issue with v2018.26.181203.

Code example is :-

Code: Select all

	TDonutSeries* d = new TDonutSeries(Chart1);

	d->Add(20);
	d->Add(10);
	d->Add(20);
	d->Add(25);
	d->Add(25);

	d->AngleSize = 180;
	d->Marks->Visible = false;
	d->DonutPercent = 60;

	Chart1->AddSeries(d);
	Chart1->View3D = false;
	Chart1->Legend->Visible = false;
	// add
	Chart1->Hover->Visible = false;


	Series1->Clear();
	Series1->Add(20);
	Series1->Add(10);
	Series1->Add(20);
	Series1->Add(25);
	Series1->Add(25);

	Series1->AngleSize = 180;
	Series1->Marks->Visible = false;

	Chart2->View3D = false;
	Chart2->Legend->Visible = false;
Which produces an image like this on the left with the items all crammed together rather than spread out around the donut ?
Attachments
Donutissue.PNG
Donutissue.PNG (26.39 KiB) Viewed 21421 times

bdw
Advanced
Posts: 130
Joined: Mon Mar 07, 2005 5:00 am
Location: New Zealand
Contact:

Re: TDonutSeries with DonutPercent

Post by bdw » Wed Feb 13, 2019 2:20 am

Actually just realized when I was playing around I had changed the Series1 to a TPieSeries.

When I change that back to a TDonutSeries it draws all together as well.

But question is the same, why is the dount not spread around the series ?

If I turn on 3D it displays correctly but not when 2D ?

bdw
Advanced
Posts: 130
Joined: Mon Mar 07, 2005 5:00 am
Location: New Zealand
Contact:

Re: TDonutSeries with DonutPercent

Post by bdw » Wed Feb 13, 2019 2:22 am

Image example :-
Attachments
Donutissue2.PNG
Donutissue2.PNG (56.58 KiB) Viewed 21420 times

bdw
Advanced
Posts: 130
Joined: Mon Mar 07, 2005 5:00 am
Location: New Zealand
Contact:

Re: TDonutSeries with DonutPercent

Post by bdw » Wed Feb 13, 2019 3:17 am

Ok looks like its been a bug since v24 and been around for quite a while.

http://bugs.teechart.net/show_bug.cgi?id=2031

Same issue looks like work around is to make 3D and set the following :-

Chart1->Chart3DPercent = 0;
Chart1->Aspect->Elevation = 0;

bdw
Advanced
Posts: 130
Joined: Mon Mar 07, 2005 5:00 am
Location: New Zealand
Contact:

Re: TDonutSeries with DonutPercent

Post by bdw » Wed Feb 13, 2019 4:34 am

In our actual application it does not draw correctly with those settings unless GDI+ is used.

I removed in our code :-

// graph_->Canvas = new TTeeCanvas3D;

I have not been able to replicate that in a test application though, so not sure why on this aspect.

We had been using GDI due to speed issue with background images but I'm guessing this may have been resolved at some point.

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

Re: TDonutSeries with DonutPercent

Post by Yeray » Wed Feb 13, 2019 3:43 pm

Hello,

I did a modification to try to fix this problem:
viewtopic.php?f=3&t=16643

However, precisely today I found that fix broke the TDonutSeries drawing when using GDI and 2D.
The Donut function I modified assumes StartAngle and EndAngle are already in radians.
To fix v2018.27, please revert that Donut function in TeCanvas.pas removing the DegToRad call and leave it as it was before:

Code: Select all

procedure TTeeCanvas3D.Donut( XCenter,YCenter,XRadius,YRadius:Integer;
                              Const StartAngle,EndAngle,HolePercent:Double);
//...
  CalcPoint(StartAngle,x3,y3);
  CalcPoint(EndAngle,x4,y4);
Then, to fix the TPointSeries pointer you can modify the DrawPointer function at TeEngine.pas as follows:

Code: Select all

Procedure TSeriesPointer.DrawPointer( const ACanvas:TCanvas3D;
                                      Is3D:Boolean;
                                      px,py,Horiz,Vert:Integer;
                                      ColorValue:TColor;
                                      AStyle:TSeriesPointerStyle);

//...
        psDonut: if Is3D then
                    if ACanvas.View3DOptions.Orthogonal then
                    begin
                      tmpP:=ACanvas.Calculate3DPosition(PX,PY,tmpZ);
                      Donut({$IFDEF FMX}Round{$ENDIF}(tmpP.X),{$IFDEF FMX}Round{$ENDIF}(tmpP.Y),Horiz,Vert,0,DegToRad(360),50);
                    end
                    else
                      EllipseWithZ(PXMinus,PYMinus,PXPlus,PYPlus,tmpZ)
                 else
                    Donut(PX,PY,Horiz,Vert,0,DegToRad(360),50);
This fix will be included in the next maintenance release.
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

bdw
Advanced
Posts: 130
Joined: Mon Mar 07, 2005 5:00 am
Location: New Zealand
Contact:

Re: TDonutSeries with DonutPercent

Post by bdw » Mon Feb 18, 2019 9:10 pm

Only just had time to verify and yes that seems to have sorted it.

Much appreciated.

Post Reply