Click here to Skip to main content
15,350,252 members
Articles / Programming Languages / C#
Posted 12 Nov 2006


262 bookmarked

High Speed, Feature Rich, and Easy-To-Use Graphs and Charts

Rate me:
Please Sign up or sign in to vote.
4.91/5 (74 votes)
29 Nov 20066 min read
High speed graphs and charts that are also very easy to configure and use. As easy as inserting a simple chart in MS Excel!

Sample Image - GraphComponents.jpg


This project was developed for the impatient developer (that's me sometimes, and probably you!) who's sitting late at night downloading charting libraries only to figure out that it's too complex to set up, isn't dynamic, and doesn't provide the necessary customizations.

Well, GraphComponents hopes to provide an answer to these common problems. In short, GraphComponents is a .NET user control that provides you the following features:

  • Easy to use in the Visual Studio designer IDE
  • Easy to configure during runtime
  • High speed updating
  • Rich features like custom color settings, custom background settings, smart numbering, reference values and lines, grids, transparent bars, etc.

GraphComponents currently supports Bar Graphs, Stacked Bar Graphs (Multi-bar Graphs), and a N-Channel Plotter Oscilloscope (Plotter CRO). Future versions should see other kinds of graphs too.


GraphComponents is accessible as a control from the control toolbox in Visual Studio .NET. To access GraphComponents, first launch Visual Studio .NET, and create a new Windows Application project. Open the Form Design so that it appears in the current window. View the toolbox using the View/Toolbox menu command. Right-click inside the "General" or "Components" sub-pane of the tool box, and select the "Add/Remove Items..." option. In the "Customize Toolbox" dialog that appears, select ".NET Framework Components". Click "Browse...", and navigate to the GraphComponents.dll file. Once this file is added, you should see a BarGraph, StackedBarGraph, and a Plotter option in the toolbox.

Using the Stacked Bar Graph

  • Create a new Windows Application project as described above.
  • Drag and drop the StackedBarGraph onto the form.
  • Drag and drop two Buttons (Button1 and Button2) onto the form.
  • Double click Button1. This will place a Button1_Click() function in your C# file.
  • Double click Button2. This will place a Button2_Click() function in your C# file.
  • Add the following code in the Button1_Click() function:
    // Increment the bar value by 10
    stackedBarGraph1.Bars[1].BarValue += 10;
    stackedBarGraph1.UpdateDisplay ();
  • Add the following code in the Button2_Click() function:
    // Decrement the bar value by 10
    stackedBarGraph1.Bars[1].BarValue -= 10;
    stackedBarGraph1.UpdateDisplay ();
  • Build and run the application. You have a very basic framework ready for using the StackedBarGraph. Examine the sources of the walkthrough projects for both the BarGraph and the StackedBarGraph.
  • Now, getting back to the Form Design view, adjust some of the properties of the graph in the Properties pane.
  • Set the BarOrientation property to Horizontal to get a horizontal bar graph. Notice that any change you make is instantly updated in the form's design view itself.
  • To perform high speed updating for measuring various things like pulse count, cylinder pressure of a 6 cylinder engine, music tones etc., you just have to set up a timer and update the bars accordingly. Examine the source of the GraphUsageDemo application for configuring high speed displays.

Using the Plotter Oscilloscope

The plotter oscilloscope is useful when you want to capture various input signals and observe them. The Performance tab of the Windows Task Manager has two simple plotters for monitoring CPU usage history and page file usage history. On Windows 2000 or XP, you can view the Windows Task Manager by pressing Ctrl + Shift and then pressing Esc.

Another thing about plotters and CROs in general is that they receive inputs through their 'channels'. If you observe the Plotter in the GraphUsageDemo application, you can see that the Advanced Body Measurement System measures four parameters (voltage, current, body pulses, and metabolism) through its four channels. While a simple low-end CRO has two channels, a hi-fi CRO (called as a spectrum analyser) can have many input channels. OK, enough with electronics theory! Let's get back to .NET.

  • To use a plotter, create a new Windows Application project as described above.
  • Drag and drop the Plotter onto the form.
  • In the form's constructor, add the following line after the InitializeComponent(); line:
    // Start the plotter
    plotter1.Start ();
    // Set the plot rate to 200 ms - which means that
    // the plotter's samples are spaced 200 milisecond apart
    plotter1.PlotRate = 200;
  • Go back to the Form Design view and drag and drop a Button (Button1) onto the form.
  • Double click Button1. This will place a Button1_Click() function in your C# file.
  • Add the following code in the Button1_Click() function:
    // Generate random values for plotting on the 1st and 2nd channel
    Random r = new Random ( (int) DateTime.Now.Ticks);
    plotter1.Channels[0].CurrentValue = r.Next (0, 100);
    plotter1.Channels[1].CurrentValue = r.Next (0, 5);
    plotter1.UpdateDisplay ();
  • Build and run the application. Keep clicking Button1, and the plotter starts plotting two separate lines for its two channels. You now have a very basic framework ready for using the Plotter. On the top left hand corner of the plotter, you can see the < and > icons. These are used for navigating to the next and previous channels. On surfing channels, the currently active channel appears brighter. The + and - icons below are used for offset adjustment. You can experiment by clicking these buttons and repeatedly clicking Button1.
  • By default, channels 1 and 2 are enabled, while channels 3 and 4 are disabled. The X axis time range is set to 9 seconds. Once the plotter has reached the right side, it automatically scrolls to the left. Also, by default, the upper and lower limits for channel 1 are set to 100 and 0. The upper and lower limits for channel 2 are set to 5 and 0.
  • Examine the sources of the PlotterWalkThrough project and the Plotter part of GraphUsageDemo.
  • Now, getting back to the Form Design view, adjust some of the properties of the plotter in the Properties pane. For example, adjust the PlotRate, GraphMarginLeft, and GraphMarginTop.
  • To perform high speed updating for measuring various things like voltages, currents, etc., you just have to set up a timer. Also note that the PlotRate must tally with the timer's Interval to get an accurate measurement. Examine the source of the GraphUsageDemo application for configuring high speed displays.

While using this in your code, it is useful to know the following things:

  • Start() starts the plotter.
  • Stop() stops the plotter. If the plotter has scrolled, then a scroll bar appears allowing you to see the earlier plots.
  • Start() and Stop() also act like Resume and Pause. So you can pause, examine the graphs, and resume by using the same two functions.
  • Reset() erases the plotter and makes it fresh for using again.
  • The CompressedMode property allows you to view the entire plot in the graph area without any scrolling.
  • NextChannel() and PreviousChannel() allow you to surf channels.
  • A channel can be enabled or disabled. You cannot see the output of a disabled channel.
  • If you are not satisfied with four channels, you can add more channels by easily changing the source code. The upper limit is based on how satisfied you are with the performance. So, you could possibly set up 8 channels and observe the data bus of an 8-bit microprocessor.


I would like to thank my wife Shubha, for providing me with some cool ideas with respect to usability, and for lots of other small things. Also, thanks to some of my friends in my current and previous companies, with whom I discuss a lot about software.


Hope you find this library useful and that you enjoy using it. Please send your criticisms, bugs, ideas for new features, and suggestions to I would be especially happy with any ideas adhering to the "Keep It Simple" principle.


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

Anup. V
Software Developer (Senior)
United States United States
No Biography provided

Comments and Discussions

QuestionChanging X-Axis legend Pin
Paul G. Scannell11-Feb-21 8:58
MemberPaul G. Scannell11-Feb-21 8:58 Pin
Solomon Samuel16-Nov-16 15:02
professionalSolomon Samuel16-Nov-16 15:02 
GeneralMy vote of 4 Pin
kangmingxuan1-Oct-14 3:39
Memberkangmingxuan1-Oct-14 3:39 
QuestionThe compiled demo looks cool but unable to run the src in vs 2008 Pin
Member 83787699-Sep-12 1:43
MemberMember 83787699-Sep-12 1:43 
SuggestionPlotter library Pin
Raghu Devisetti26-Aug-12 2:50
MemberRaghu Devisetti26-Aug-12 2:50 
QuestionGreat job Pin
Siva k Venkadesan26-Oct-11 7:12
MemberSiva k Venkadesan26-Oct-11 7:12 
Questionspeed question Pin
GabeA9-Aug-11 8:44
MemberGabeA9-Aug-11 8:44 
Generalgreat plotter and a question Pin
Member 773407527-Mar-11 18:47
MemberMember 773407527-Mar-11 18:47 
Questionplotter axis line Pin
BillC732-Feb-11 17:48
MemberBillC732-Feb-11 17:48 
GeneralLicense Pin
Fandi Gunawan29-Oct-09 16:57
MemberFandi Gunawan29-Oct-09 16:57 
QuestionIt freezes when i move my window ? Pin
LTIDK6-Sep-09 15:27
MemberLTIDK6-Sep-09 15:27 
Questionvisual basic 2008 and exporting plotter data Pin
Ario Fitrianto24-Jun-09 23:39
MemberArio Fitrianto24-Jun-09 23:39 
GeneralZooming Pin
mazhengm227-Mar-09 6:27
Membermazhengm227-Mar-09 6:27 
GeneralNice control but I'm seeing a display problem with the buttons Pin
mschuckmann3-Feb-09 13:07
Membermschuckmann3-Feb-09 13:07 
GeneralHi I want to add more channels Pin
himanshu110122-Jan-09 22:49
Memberhimanshu110122-Jan-09 22:49 
GeneralResizing problem Pin
Fouinard13-Oct-08 7:44
MemberFouinard13-Oct-08 7:44 
QuestionSetting Plotter Y Range? Pin
Member 54067798-Aug-08 5:22
MemberMember 54067798-Aug-08 5:22 
AnswerRe: Setting Plotter Y Range? Pin
Lukgaucho7720-May-09 3:11
MemberLukgaucho7720-May-09 3:11 
GeneralCursor values in stop mode Pin
LOSMI30-Jan-08 7:58
MemberLOSMI30-Jan-08 7:58 
GeneralPlotter data control Pin
jknickel6-Nov-07 3:19
professionaljknickel6-Nov-07 3:19 
Questionhow to import data from excel to this graphs? Pin
mmshah413-Oct-07 17:13
Membermmshah413-Oct-07 17:13 
QuestionStand-alone real-time plotter? Pin
gragus13-Sep-07 18:36
Membergragus13-Sep-07 18:36 
GeneralVariable plotrate problem Pin
bombompb2-Aug-07 4:04
Memberbombompb2-Aug-07 4:04 
GeneralRe: Variable plotrate problem Pin
bombompb2-Aug-07 22:12
Memberbombompb2-Aug-07 22:12 
QuestionStacked Bars? Pin
lessms20-Jul-07 6:04
Memberlessms20-Jul-07 6:04 

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

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