You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have tried to figure a way to draw a PIE Chart but without success. Could anyone help to point me in a direction of how to do that? Would like to fill the pie charts, not just draw the line.
Thanks...
Christian
The text was updated successfully, but these errors were encountered:
I have added a demo to draw a pie chart. Hope it helps you.
You can find the demo program from the Examples project of source code.
And this library has been updated for the feature to draw pie geometry, please use the latest code or latest NuGet package 1.2.2.
Here is the full example code:
publicpartialclassPieChart:DemoForm{List<PieInfo>pies=newList<PieInfo>();protectedoverridevoidOnLoad(EventArgse){base.OnLoad(e);Text="PieChart Demo";CreateChart();}voidCreateChart(){pies.Clear();// define the figure origin and sizevarfigureOrigin=newD2DPoint(300,300);varfigureSize=newD2DSize(300,300);varrecords=newfloat[]{.6f,.3f,.1f};floatcurrentAngle=0;// create pie geometries from recordsforeach(varrecordinrecords){varangleSpan=record*360;varpath=Device.CreatePieGeometry(figureOrigin,figureSize,currentAngle,currentAngle+angleSpan);pies.Add(newPieInfo{path=path,color=D2DColor.Randomly()});currentAngle+=angleSpan;}Invalidate();}protectedoverridevoidOnRender(D2DGraphicsg){base.OnRender(g);// draw backgroundg.FillRectangle(100,100,400,400,D2DColor.LightYellow);// draw pie geometriesforeach(varpieinpies){g.FillPath(pie.path,pie.color);g.DrawPath(pie.path,D2DColor.LightYellow,2);}g.DrawText("Click to change color",D2DColor.Black,250,550);}protectedoverridevoidOnMouseUp(MouseEventArgse){base.OnMouseUp(e);CreateChart();}}classPieInfo{publicD2DGeometrypath;publicD2DColorcolor;}
The point is the new added method Device.CreatePieGeometry, you can simply call this method to create a pie geometry by the following parameters.
Once you have a pie geometry you can draw or fill by following code:
Hi!
I have tried to figure a way to draw a PIE Chart but without success. Could anyone help to point me in a direction of how to do that? Would like to fill the pie charts, not just draw the line.
Thanks...
Christian
The text was updated successfully, but these errors were encountered: