Update (Jan 2008): I have uploaded a newer version of the histogram control. The only difference is the addition of a Creative Commons Attribution 3.0 Unported license (meaning you can do pretty much whatever you like, as long as you give credit where credit is due). The new version with the licensing information is available here: histogram-1.1.zip. There are no other changes to the code itself.
I was looking for a good histogram control (like the Task Manager’s CPU history graph) but I never really found one. I just wanted something simple, which let me add multiple values to the histogram.
This is the result: I made my own :)
You can download the source for the control and a sample project (which just uses a couple of performance counters to simulate the Task Manager CPU history graph) here: histogram.zip
This control is very simple. Basically, just add it to your form and use the AddHistogram
method to add your histograms. You have to supply a delegate to sample your histogram at each update. The delegate has the following form:
delegate double SampleHistogram();
Anyway, enjoy the control, and if you have any problems, feel free to leave a comment!
Note: The control was written with .NET 2.0, and I do use a couple of 2.0-only contructs. It shouldn’t be too difficult to back-port it to .NET 1.x if you needed, though.