How can I add a pie chart to my winforms application?
Asked Answered
F

5

9

I am trying to add a pie chart to my winforms application - but the only chart I can find in my toolbox is the regular bar chart.

Is there any way to form this bar chart as a pie chart or add a pie-chart component to my toolbox by using some existing .net 4 framework libraries (without installing any new libraries such as "DevExpress" etc)?

Fanny answered 3/9, 2012 at 15:36 Comment(0)
M
2

Without third party tools the only way around it would be for you to create a new user control in WPF for this following this tutorial:

http://www.codeproject.com/Articles/28098/A-WPF-Pie-Chart-with-Data-Binding-Support

And then hosting this within the windows form project, following this tutorial:

http://www.switchonthecode.com/tutorials/wpf-tutorial-using-wpf-in-winforms

That way you have created the control yourself without the need of downloading anything, although you may need to context switch to use the WPF tutorial - I hope this is ok :)

Mollescent answered 3/9, 2012 at 15:42 Comment(1)
You might want to moderate your claim "the only way" now that other users have explained how to get pie charts from the built-in WinForms Chart.Latchkey
L
16

You can change the chart type by selecting the series in property window or use the following sample code

 chart1.Series["Business"].ChartType =   
       System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Pie;
Lebensraum answered 4/1, 2013 at 9:45 Comment(0)
B
11

In .NET 4 and later I think you have MS Chart in the framework. Read more here: http://code.msdn.microsoft.com/Samples-Environments-for-b01e9c61

Boren answered 3/9, 2012 at 16:26 Comment(3)
Thanks for the link. I am trying out this library at the moment. The strange thing here is this; The page itself states that -"Beginning in .NET Framework 4, the Chart controls are part of the .NET Framework." --> So how come these libraries/controls are not already installed into my VS2010? I think it's rather odd. Thanks again :)Fanny
What library is that? I can only find a 3.5 one.Clayborne
Best answer in my opinion. I always prefer built-in goodness over third-party, even sometimes if the built-in ones have less features.Adios
S
8

well actually visual studio does have a pie chart. after dragging out the bar chart. go to your properties panel then under chart click series. a dialog box will appear after which you will select chart type. there is a whole list of different chart types to choose from

Sisile answered 11/3, 2016 at 16:36 Comment(0)
M
2

Without third party tools the only way around it would be for you to create a new user control in WPF for this following this tutorial:

http://www.codeproject.com/Articles/28098/A-WPF-Pie-Chart-with-Data-Binding-Support

And then hosting this within the windows form project, following this tutorial:

http://www.switchonthecode.com/tutorials/wpf-tutorial-using-wpf-in-winforms

That way you have created the control yourself without the need of downloading anything, although you may need to context switch to use the WPF tutorial - I hope this is ok :)

Mollescent answered 3/9, 2012 at 15:42 Comment(1)
You might want to moderate your claim "the only way" now that other users have explained how to get pie charts from the built-in WinForms Chart.Latchkey
B
0

I use Guna Charts regularly. It's a paid NuGet package, but it's very high quality, has animations, and is fully responsive

enter image description here

Bollix answered 29/7 at 19:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.