Page 1 of 1

TDonutSeries with DonutPercent

Posted: Wed Feb 13, 2019 2:09 am
by 9236183
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 ?

Re: TDonutSeries with DonutPercent

Posted: Wed Feb 13, 2019 2:20 am
by 9236183
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 ?

Re: TDonutSeries with DonutPercent

Posted: Wed Feb 13, 2019 2:22 am
by 9236183
Image example :-

Re: TDonutSeries with DonutPercent

Posted: Wed Feb 13, 2019 3:17 am
by 9236183
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;

Re: TDonutSeries with DonutPercent

Posted: Wed Feb 13, 2019 4:34 am
by 9236183
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.

Re: TDonutSeries with DonutPercent

Posted: Wed Feb 13, 2019 3:43 pm
by yeray
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.

Re: TDonutSeries with DonutPercent

Posted: Mon Feb 18, 2019 9:10 pm
by 9236183
Only just had time to verify and yes that seems to have sorted it.

Much appreciated.