Click here to Skip to main content
Licence 
First Posted 24 Sep 2006
Views 74,443
Downloads 3,619
Bookmarked 82 times

Realtime Chart and Graph in One

By | 16 May 2007 | Article
A basic Chart and Graph control.

Sample Image - ChartGraph.png

Introduction

I worked on a project in which I needed a graph control. Later on, I was also required to use a chart control. So I thought, hey, let's just combine them both into one nice and simple control.

Using the code

This control is very simple to use. First, we must create the control and initialize it.

//Creating the control
private ChartControl.ChartControlForm chartControlForm1;
chartControlForm1 = new ChartControl.ChartControlForm();
//Initializing the Control
chartControlForm1.InitChart();

Now we can start adding values.

//Adding Values to the control
float ValueAdd;
ValueAdd = 5.3;
chartControlForm1.AddValue(ValueAdd);

As we add the values, the control automatically redraws itself, so there is no need to call any function.

The variable in charge of the Graph/Chart mode is OpenType. Please note that its default value is ChartControlOpenType.Bar.

Change to Graph mode:

chartControlForm1.OpenType = ChartControl.ChartControlOpenType.Graph;

Change to Chart mode:

chartControlForm1.OpenType = ChartControl.ChartControlOpenType.Bar;

Additional Features

Loading from an array/list can easily be done by using the overloaded function LoadFromValues (may receive a float Array or an ArrayList).

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

Roy Reznik



Israel Israel

Member

I've been into programming for the last 5 years, doing all sort of stuff, from the old dos borland c++ to C#.NET.

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
QuestionReset chart data PinmemberMember 87076244:28 4 Apr '12  
QuestionRealTime graph Pinmembercicekbilal200222:51 3 Feb '12  
AnswerRe: RealTime graph PinmemberMazen el Senih7:46 6 Feb '12  
Generalreply! Pinmemberluongvn2:35 26 Feb '11  
GeneralRe: reply! PinmemberRoy Reznik7:54 14 May '11  
GeneralWeb Version Pinmembergirishmeena0:12 21 Sep '10  
QuestionHow could i adjust with all values when array exceed range of values? Pinmemberhuynhdangthai23:52 27 Jul '10  
QuestionI got some problem with it, help please.. Pinmemberrpurnama18:41 15 Feb '10  
Generalcannot run... Pinmemberyanadi6:02 30 May '09  
AnswerRe: cannot run... PinmemberRoy Reznik3:04 26 Jun '09  
GeneralMy Solution for the exception Pinmemberrcn2116:10 18 May '09  
GeneralRe: My Solution for the exception PinmemberRoy Reznik3:10 26 Jun '09  
GeneralRe: My Solution for the exception PinmemberNeoDimension2:15 5 Aug '09  
GeneralChange bar width Pinmemberelcharro5:59 10 Aug '07  
GeneralImplementing realtime graph [modified] Pinmemberjamezun21:30 18 Jun '07  
Hi, I want to implement your realtime graph in my temperature monitoring software, the range og my temperature will be 0-100 deg celcius. But I realize your application can only go up to 40. How can I change the setting,so that the 0 point white line will be lower instead of in the middle and how can I get up to 100 by changing the coding in ChartControlForm.cs ?
 
I mananged to change the valuemultiplier to 0.5, so it can show up to 80 or more, but the chart didnt show up the value...just flat line..
 
When I wanna move the axes lower(the white line):
g.DrawLine(new Pen(AxesColor),0,(int)(ChartPanel.Size.Height/8),ChartPanel.Size.Width,(int)(ChartPanel.Size.Height/8));
 
Why the line jump up intead of appearing in the lower PART OF THE CHART..?
 
Please add me if you do got a msn, thz for your attention.
jamezun@hotmail.com
 
James
 

 

-- modified at 5:09 Tuesday 19th June, 2007
GeneralThanks for the update! PinmemberMarc Leger8:51 19 May '07  
QuestionLoad Array PinmemberGwannoes23:04 10 May '07  
AnswerRe: Load Array PinmemberRoy Rez10:10 16 May '07  
Generaltest application issues and chart control issues PinmemberToothRobber10:09 10 Nov '06  
GeneralRe: test application issues and chart control issues PinmemberRoy Rez10:19 10 Nov '06  
QuestionReal Time? PinmemberMBirchmeier10:19 6 Nov '06  
AnswerRe: Real Time? PinmemberRoy Rez10:17 10 Nov '06  

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
Web01 | 2.5.120529.1 | Last Updated 16 May 2007
Article Copyright 2006 by Roy Reznik
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid