Article Options
Recently Viewed
Premium Sponsor
Premium Sponsor

 »  Home  »  .NET Newbie  »  Chart Success: GDI+ Graphics At Work. Part 2  »  Summary
Chart Success: GDI+ Graphics At Work. Part 2
by Ged Mead | Published  03/16/2005 | .NET Newbie | 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...
Summary

  This article built on the basic skills and techniques covered in Part 1 and also added some new ones.     We saw that with a very small amount of code a bar chart can be created completely from scratch.  

   By calculating the scaling, we ensured that that the bars accurately represented the sales figures, making use of the full height of the drawing area available.    Using variables to represent values, such as the margins around the chart,  the code is made easier to read and edit.

   Using double buffering, the chart was drawn on a Bitmap object out of sight of the user and then the bitmap was applied to a PictureBox once it was complete.  This technique reduced flicker and also ensured that once chart was displayed, it will persist (that is, it will be redrawn whenever it has been obscured or changed in some way).

      Although the completed code is quite short, several important Graphics Class methods and other drawing skills have been used:-

• Bitmap object
• Brushes
• Create a Graphics object FromImage
• Disposing of Graphics objects
• Drawing on a PictureBox control
• DrawLine
• DrawRectangle
• DrawString
• FillRectangle
• Font object
• Offset method
• Pens
• Points
• Rectangle object
• Scaling

  In Part 3, we will return to the Pie Chart and will take user input at runtime to create a chart based on the user’s data and display decisions.  The solid colors of the pie will also be replaced with HatchStyles selected by the user.

How would you rate the quality of this article?
1 2 3 4 5
Poor Excellent
Tell us why you rated this way (optional):

Article Rating
The average rating is: No-one else has rated this article yet.

Article rating:4.36363636363638 out of 5
 55 people have rated this page
Article Score42255
Article Series
Related Articles
Attachments
Comments    Submit Comment

Comment #1  (Posted by an unknown user on 03/14/2005)
Rating
Part one is very good.

Where is part two?
 
Comment #2  (Posted by Ged Mead on 03/16/2005)
Rating
Slight technical hitch there :-}
Part 2 now published. Hope you find it useful.
 
Comment #3  (Posted by an unknown user on 04/18/2005)
Rating
Great Article!
 
Comment #4  (Posted by an unknown user on 05/01/2005)
Rating
Keep up the great work.. I'm at Virginia Tech (Go Hokies).. doing my montrous VB.net final project and this has helped me a bit. Thank you so much. You might wanna add a small blurb for newbies to know how to change the scale. Other than that...A++

 
Comment #5  (Posted by Ged Mead on 05/01/2005)
Rating
Thanks - Scaling will be included in the upcoming Part 4 of the series (Back to the Bar). Also 3D bars and multiple colors.
 
Comment #6  (Posted by an unknown user on 06/15/2005)
Rating
This walk-through is absolutely perfect. I've been looking to draw a simple chart on my project for weeks now, and this was the ONLY comprehensive explaination I've found! Thank You!!!
 
Comment #7  (Posted by an unknown user on 06/15/2005)
Rating
This walk-through is absolutely perfect. I've been looking to draw a simple chart on my project for weeks now, and this was the ONLY comprehensive explaination I've found! Thank You!!!
 
Comment #8  (Posted by an unknown user on 07/26/2005)
Rating
Ged, I can't thank you enough for taking the time to make something like this available to the on-line community. I am in the process of teaching my self vb.net and your tutorial has taught me far more then I ever expected to learn. Once again many thanks!
 
Comment #9  (Posted by an unknown user on 12/08/2005)
Rating
Clearly explained.
 
Comment #10  (Posted by an unknown user on 01/18/2006)
Rating
This is really very nice article explained in a detailed way..

Thanks for providing such a great article.
 
Comment #11  (Posted by an unknown user on 01/30/2006)
Rating
excellent learning tutorial on working with graphics. Explanations for each steps great.
 
Comment #12  (Posted by an unknown user on 02/07/2006)
Rating
Superb article !! helped me a lot in my project
 
Comment #13  (Posted by Samer on 07/01/2006)
Rating
Thanks for ALL the articles. They helped me alot. Can you please write an article about drawing objects (Lines, Rectangles, Circles, ...etc) and then using the mouse to select the object and change their attributes (color, size, position, delete...etc)
 
Comment #14  (Posted by Ankur Adarsh on 07/31/2006)
Rating
this is good but i do not understand how to use picture box in web programming, because i can not see picture box control in web form.
 
Comment #15  (Posted by an unknown user on 10/19/2006)
Rating
Very good article. Prakash Bajaj
 
Comment #16  (Posted by Roy Oliver on 12/04/2006)
Rating
Thanks for the lessons Ged. Knowing how to manipulate graphics was the only thing missing from my skill set.
 
Comment #17  (Posted by an unknown user on 01/20/2007)
Rating
hey dude i love this and i'm going to pass my visual basic test with flying colours..love you keep going dude
 
Comment #18  (Posted by an unknown user on 08/24/2007)
Rating
very simple
 
Comment #19  (Posted by an unknown user on 01/03/2008)
Rating
thank you so much. i need it very much.
 
Comment #20  (Posted by shohreh on 01/03/2008)
Rating
it was excellent.
 
Comment #21  (Posted by an unknown user on 06/28/2008)
Rating
Ged Mead thank man
amazing tutorial.
Helped me more ways than one..

kasbaba
 
Comment #22  (Posted by sreelakshmi on 07/03/2008)
Rating
Hey its gr8 article. can u tell me hoe to draw doughnut pie charts .Thanks in anticipation
 
Comment #23  (Posted by an unknown user on 12/01/2008)
Rating
acelcn
 
Comment #24  (Posted by tranzostor on 03/03/2009)
Rating
comment5,
 
Comment #25  (Posted by an unknown user on 05/11/2009)
Rating
Simply the best for newbie!
 
Comment #26  (Posted by an unknown user on 05/11/2009)
Rating
Simply the best for newbie!
 
Comment #27  (Posted by viagra billig on 07/28/2009)
Rating
nuHv78 nrlcgtqh dlgkssbj rmjxvqrf
 
Comment #28  (Posted by on 10/11/2009)
Rating

 
Comment #29  (Posted by Grunenthal has promoted it as an opioid with on 11/27/2009)
Rating
Very realistic and amusing site.: URLsWithURL
 
Comment #30  (Posted by an unknown user on 12/07/2009)
Rating
THANKS FOR UR HELP.
I AM SO HAPPY.
PLEASE NOTE IT MY MAIL ID PLEASE HELP MY DEVELOPING.mohanrajp04@gmail.com.

thank you......................
 
Sponsored Links