A while ago, I stumbled over an article written by Andelko Pavelic. I looked into the code and found it to be an interesting approach. But I needed something more stable, accurate and flexible - and I needed better looks. So I took the base idea and wrote my own version, the
TrackerControl 2.0. Although almost nothing is left of Andelko's initial code, credits belong to him for providing the initial idea.
Using the Code
There is a bunch of additional features and properties added to the original control.
First of all, the coloring of the drawn graph is extended to optionally use a linear color gradient:
To make it more plastic, the area underneath the graph can be colorized:
The grid can be adjusted in mesh size and optionally horizontal and/or vertical grid lines can be blanked:
The wider the control, the more values are represented by the graph. I found it helpful in some cases to visualize the average as a horizontal bar:
The average bar's color can also be set to a linear gradient, other than the one of the graph.
There are some features that can hardly be shown with still pictures, such as:
GridMovement.MoveWithGraph and GridMovement.Fixed
The grid can progressively move with the graph or stay fixed in the background.
This is the classic mode, known from the Windows Task Manager.
While still in line with values between Minimum and Maximum and colorizing the graph according to these fixed bounds, the vertical zoom level is continuously adjusted to the highest displayed value. That gives more granularity during periods of low values at a constant control height. The distance between the horizontal grid lines is adjusted as well (if shown), according to the zoom level.
Sometimes the exact Maximum isn't known and it would be laborious to manually adjust the controls Maximum in your code during runtime. This setting does exactly that, correcting the Control's internal maximum continuously to the highest shown value. In difference to
GraphSizeMode.Zoom, the graph's color gradient is fully utilized. The Maximum value in
AutoAdjustMaximum acts as the initial internal maximum and also as the internal lower bound for its auto adjustment.
TrackerRefreshInDesignMode, TrackerRefreshInRuntimeMode and TrackerRefreshStartOnFirstValue
These settings do exactly as the names imply: The first one eventually saves you from headache caused by watching moving grid lines while designing the form and the second is useful to halt and resume the
TrackerControl during runtime. The third prevents the Control from refreshing until it gets the first value to be drawn.
Depending on the area of application, sometimes the start value of the graph needs to be other than 0.
Flushes the internal value buffer and clears the graph.
Points of Interest
Combining the settings help to customize visualization. They can also be changed during runtime, allowing interesting visual effects.
Keep in mind that there is no error handling implemented. Eventually, you need to do this yourself according to your application's exception handling strategy.
- 6th June, 2010: Initial post