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.
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
StackedBarGraph, and a
Plotter option in the toolbox.
Using the Stacked Bar Graph
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
plotter1.PlotRate = 200;
- Go back to the Form Design view and drag and drop a
Button1) onto the form.
- Double click
Button1. This will place a
Button1_Click() function in your C# file.
- Add the following code in the
Random r = new Random ( (int) DateTime.Now.Ticks);
plotter1.Channels.CurrentValue = r.Next (0, 100);
plotter1.Channels.CurrentValue = r.Next (0, 5);
- 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
- 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
- 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.
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.
CompressedMode property allows you to view the entire plot in the graph area without any scrolling.
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 firstname.lastname@example.org. I would be especially happy with any ideas adhering to the "Keep It Simple" principle.