Article Options
Recently Viewed
Premium Sponsor
Premium Sponsor

 »  Home  »  .NET Newbie  »  Chart Success: GDI+ Graphics at work. Part 1
 »  Home  »  Windows Development  »  Graphics  »  Chart Success: GDI+ Graphics at work. Part 1
Chart Success: GDI+ Graphics at work. Part 1
by Ged Mead | Published  03/06/2005 | .NET Newbie Graphics | Rating:
Ged Mead

Ged Mead (XTab) is a Microsoft Visual Basic MVP who has been working on computer software and design for more than 25 years. His journey has taken him through many different facets of IT. These include training as a Systems Analyst, working in a mainframe software development environment, creating financial management systems and a short time spent on military laptop systems in the days when it took two strong men to carry a 'mobile' system.

Based in an idyllic lochside location in the West of Scotland, he is currently involved in an ever-widening range of VB.NET, WPF and Silverlight development projects. Now working in a consultancy environment, his passion however still remains helping students and professional developers to take advantage of the ever increasing range of sophisticated tools available to them.

Ged is a regular contributor to forums on vbCity and authors articles for DevCity. He is a moderator on VBCity and the MSDN Tech Forums and spends a lot of time answering technical questions there and in several other VB forum sites. Senior Editor for DevCity.NET, vbCity Developer Community Leader and Admin, and DevCity.NET Newsletter Editor. He has written and continues to tutor a number of free online courses for VB.NET developers.

 

View all articles by Ged Mead...
Let’s Not Reinvent the Wheel

   In many situations the familiar pie chart is as good a way as any of presenting data in pictorial form.   The Graphics Class in .Net offers us an easy way to create this style of chart in order to display facts and figures to the world.

 

Basic Pie Chart

 

The above chart can be created with very few lines of code.  

 

   However, it is obviously of very limited use on its own.   The picture is colourful, but we need to know what the segments represent.

 

  Let’s look at a basic but quite useful way of doing this – using a chart key:

 

 

   With a key like the one shown above, it is very easy for the user to identify which part of the pie chart represents which of the companies.   To make the data even more useful, each company’s individual total is also shown in the key.


      As you will see, the Graphics Class in the .Net Framework makes it quite easy to create pie charts and keys of this kind.   So we’ll use the built-in facilities of DrawPie and DrawString and avoid reinventing the wheel.

Comments    Submit Comment

Comment #1  (Posted by an unknown user on 03/13/2005)
Rating
The subject you have picked is one of the most interesting ones in programming. But sure enough, that may just be my opinion. When an interesting subject comes with explanations that are detailed but still very readable, then this means that the author has a great talent for writing and it shows immense responsibility and patience with beginning programmers. And that’s exactly what your article has achieved.
 
Comment #2  (Posted by an unknown user on 03/16/2005)
Rating
Very nice, Ged.

A small suggestion for part II: when would you use GDI+ vs. DirectX?
 
Comment #3  (Posted by Ged Mead on 03/22/2005)
Rating
Thanks for the comments. Part 2 is out now .... but I think it'll be a while before I get round to DirectX!
 
Comment #4  (Posted by an unknown user on 06/12/2005)
Rating
Hi Ged,
Nice and the way u explained is excellent .
The explanation is in steps and easy to understand and for me it the best methord to understand .
Good work i dont have word to appriciate u but excellent job.
From
Mohd Sufian
IT Specialist
Eastern Polymer Group
Thailand
 
Comment #5  (Posted by Dave on 10/03/2005)
Rating
Explained quite well! However I have a persistence problem that you mention in your article. I am drawing inside a picture box. My drawing code is in its own function which I call from the Paint() method. When the form first opens my drawing flashes up quite briefly and then disappears. It reappears and remains whenever I resize the window. How do I get it to come up without telling it to refresh which puts it in an endless loop?
 
Comment #6  (Posted by an unknown user on 04/05/2006)
Rating
Great explanation.I would like to know how to integrate database data with GDI.
 
Comment #7  (Posted by Ronan on 04/13/2006)
Rating
Hi i have read these tutorials and am looking your help.
I am trying to develop a pie chart interface in Visual Studio 2003 for a PDA (Smart Device Application) and tried your code. however it is not compatible as it does not recognise the drawPie and FillPie commands, etc. Do you have an example i could use to help me for this?
Thank you, Ronan
 
Comment #8  (Posted by an unknown user on 08/09/2006)
Rating
Excellent article. I have learnt a lot of GDI+ Stuff from it.
 
Comment #9  (Posted by an unknown user on 10/19/2006)
Rating
Very Useful article. Prakash Bajaj
 
Comment #10  (Posted by an unknown user on 12/22/2006)
Rating
really useful
 
Comment #11  (Posted by an unknown user on 12/29/2006)
Rating
no corners cut, all is clear
 
Comment #12  (Posted by an unknown user on 07/09/2007)
Rating
thank you
Very simple
detailed explanation
 
Comment #13  (Posted by an unknown user on 07/22/2007)
Rating
best for beginner's. language is just perfect
 
Comment #14  (Posted by neelabh on 07/22/2007)
Rating
Language is clear nd decription is best for beginner
 
Comment #15  (Posted by an unknown user on 10/01/2007)
Rating
Easy to follow tutorial. Picked up the main points straight away.
 
Comment #16  (Posted by an unknown user on 12/28/2007)
Rating
I have been searching for a good graphics article to get me started...with this one I found what I was looking for...GREAT JOB. Now I need to found out how to do vertical text.
 
Comment #17  (Posted by an unknown user on 02/05/2008)
Rating
Free, good, patient advice. A rare commodity and precious to beginners.
 
Comment #18  (Posted by an unknown user on 02/06/2008)
Rating
thanks for giving such a good article to start GDI+ from scratch.
 
Comment #19  (Posted by an unknown user on 02/20/2008)
Rating
good one
 
Comment #20  (Posted by IQGUY on 09/08/2008)
Rating
Good article with nice source code.
 
Comment #21  (Posted by an unknown user on 12/01/2008)
Rating
aldomelg
 
Comment #22  (Posted by busrider on 01/04/2009)
Rating
eFront-???????? ??????? ??????? ? ???????????? ??????? www.e-front.com.ua
 
Comment #23  (Posted by an unknown user on 06/01/2009)
Rating
A very well explained starting point for setting out into the world of GDI+. I didn't even know it existed until reading this article and now I will be doing the next 4months of programming I have to do, utilising this tool.
 
Comment #24  (Posted by on 10/11/2009)
Rating

 
Comment #25  (Posted by metabolism. on 11/07/2009)
Rating
does plavix work does plavix work does plavix work . does plavix work does plavix work . does plavix work does plavix work . does plavix work maker of carisoprodol maker of carisoprodol . maker of carisoprodol maker of carisoprodol . maker of carisoprodol maker of carisoprodol . maker of carisoprodol maker of carisoprodol maker of carisoprodol . ambien sales online ambien sales online ambien sales online ambien sales online ambien sales online . ambien sales online ambien sales online ambien sales online ambien sales online ambien sales online .
 
Comment #26  (Posted by a common side effect of most opioids, on 11/24/2009)
Rating
This is one of the best sites I have ever found. Thanks!!! Very nice and informal. I enjoy being here.: URLsWithURL
 
Sponsored Links