Click here to Skip to main content
Licence 
First Posted 26 Jan 2004
Views 76,579
Bookmarked 33 times

Bar Graph Control

By | 26 Jan 2004 | Article
Simple bar graph control class derived from CStatic

Introduction

Here is a simple bar graph control class derived from CStatic. It supports displaying real-time data, using any number of bars with different colors, using scale both in cm and inch, etc.

Using the code

How to add this control to your project:

  1. Copy files GraphCtrl.h and GraphCtrl.cpp to your project directory, and add to your project.
  2. Include GraphCtrl.h in files where you need to use this class.
  3. Change CStatic definitions to CGraphCtrl.
  4. Use the API described below.
int SetNumberOfBars(int num)
//Sets the number of bars you want to display. 
//If successful, it returns number of bars set, otherwise -1.
int SetBarColor(int idx, COLORREF clr)
//Sets the color for the bars.  idx is the index of the 
//bar from left to right (1,2,3..etc.)
//If successful, it returns index of the bar for which 
//the color was set, otherwise -1.
void SetUnit(int unit)
//Sets the scale to cm or inch. Send UCM for cm and UINCH for inch
void SetBarValue(int idx, int value)
//Sets the value of a bar.  idx is the index of the bar 
//for which the value to be set and 
//the parameter value is the value we have to set for it.

Example of Use

m_Graph.SetNumberOfBars(18); //Number of bars to be shown

m_Graph.SetBarColor(1,RGB(200,200,200)); 
    //Sets the color to the bar of index 1

m_Graph.SetBarValue(1,22); //Sets value to the bar of index 1

m_Graph.SetUnit(UCM);  //Sets scale to cm

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here

About the Author

Shaibujan

Team Leader

India India

Member

Mr. Shaibujan has got 9+ yrs of programming experience in C/C++, on various domains like Cryptography, Biometric Security, Network Security, Pattern Recognition, Image Processing, MPEG2, MPEG4, H.264, AAC etc.

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralMy vote of 2 PinmemberDRLaverdure9:27 18 Sep '10  
GeneralThere is a nice bar chart .Net component as well Pinmemberoklook1:40 14 Aug '09  
Questionlarge number of bars? PinmemberJared CompEng2:14 29 Apr '07  
Questionambiguous size of bar ??!!!? Pinmembermohsen nourian20:24 20 Sep '06  
GeneralSave to Bitmap File Pinmembervarandas793:00 18 Jun '06  
Generalerror in line : using namespace std Pinmembermohsen nourian2:25 24 Sep '06  
Generalproblem with big values PinmemberKostis Mentzelos12:32 4 Apr '04  
GeneralRe: problem with big values Pinmembermohsen nourian19:27 24 Sep '06  
GeneralSetBarColor PinmemberKostis Mentzelos3:33 4 Apr '04  
GeneralRe: SetBarColor Pinmemberhucker11:01 14 Jun '04  
GeneralRe: SetBarColor PinmemberNiFF23:44 8 Dec '04  
General- Memory Leak PinmemberChaitanya1239:18 2 Mar '04  
GeneralRe: - Memory Leak PinmemberShaibujan6:07 3 Mar '04  
GeneralIncorrect Device MapMode ... PinmemberBehzad Ebrahimi2:49 3 Feb '04  
GeneralRe: Incorrect Device MapMode ... PinmemberShaibujan6:21 3 Feb '04  
GeneralQuestion on OnCustomDraw PinmemberYoSilver15:17 27 Jan '04  
GeneralRe: Question on OnCustomDraw PinmemberShaibujan6:49 28 Jan '04  
GeneralFinally about time... PinmemberSnyp12:00 27 Jan '04  
GeneralRe: Finally about time... PinmemberShaibujan19:27 27 Jan '04  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120517.1 | Last Updated 27 Jan 2004
Article Copyright 2004 by Shaibujan
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid