Click here to Skip to main content
Click here to Skip to main content

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

, 29 Nov 2006
Rate this:
Please Sign up or sign in to vote.
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

Introduction

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.

Usage

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.

Acknowledgements

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.

Conclusion

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

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

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

Comments and Discussions

 
QuestionThe compiled demo looks cool but unable to run the src in vs 2008 PinmemberMember 83787699-Sep-12 1:43 
SuggestionPlotter library PinmemberRaghu Devisetti26-Aug-12 2:50 
QuestionGreat job PinmemberSiva k Vengadesan26-Oct-11 7:12 
Questionspeed question PinmemberGabeA9-Aug-11 8:44 
Generalgreat plotter and a question PinmemberMember 773407527-Mar-11 18:47 
Questionplotter axis line PinmemberBillC732-Feb-11 17:48 
GeneralLicense PinmemberFandi Gunawan29-Oct-09 16:57 
QuestionIt freezes when i move my window ? PinmemberLTIDK6-Sep-09 15:27 
using the plotter to plot values from a file. If i move the window during plotting, then the update of the plotarea & form halts ?
 
Also during plotting it seems that updating of other gui controls ex a listbox doesnt seem to work very well.
 
Any inputs ? thanks.
Questionvisual basic 2008 and exporting plotter data PinmemberArio Fitrianto24-Jun-09 23:39 
GeneralZooming Pinmembermazhengm227-Mar-09 6:27 
GeneralNice control but I'm seeing a display problem with the buttons Pinmembermschuckmann3-Feb-09 13:07 
GeneralHi I want to add more channels Pinmemberhimanshu110122-Jan-09 22:49 
GeneralResizing problem PinmemberFouinard13-Oct-08 7:44 
QuestionSetting Plotter Y Range? PinmemberMember 54067798-Aug-08 5:22 
AnswerRe: Setting Plotter Y Range? PinmemberLukgaucho7720-May-09 3:11 
GeneralCursor values in stop mode PinmemberLOSMI30-Jan-08 7:58 
GeneralPlotter data control Pinmemberjknickel6-Nov-07 3:19 
Questionhow to import data from excel to this graphs? Pinmembermmshah413-Oct-07 17:13 
QuestionStand-alone real-time plotter? Pinmembergragus13-Sep-07 18:36 
GeneralVariable plotrate problem Pinmemberbombompb2-Aug-07 4:04 
GeneralRe: Variable plotrate problem Pinmemberbombompb2-Aug-07 22:12 
QuestionStacked Bars? Pinmemberlessms20-Jul-07 6:04 
GeneralA couple of fixes PinmemberMichael Moore21-Jun-07 14:35 
QuestionUsing free? Pinmemberhansipet20-Jun-07 2:13 
QuestionLogarithmic PinmemberXsiXmaX19-Feb-07 2:54 

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.

| Advertise | Privacy | Mobile
Web03 | 2.8.140721.1 | Last Updated 29 Nov 2006
Article Copyright 2006 by Anup. V
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid