This project is inspired by "Simple Performance Chart" by eclipse2k1.
There are a few reasons for this project and article. The original article provides support for only one time serie and I required a few. Secondly, I found a number of limitations in the original control which I decided to fix and improve.
The original article is well-written and covers the basics quite well, so I won't go into much detail, but run over the improvements and enhancements introduced.
The list of improvements is as follows:
- The chart contains a collection of time series. Each individual serie can be independently configured from the rest
- Re-worked chart's and serie's styles
- Enhanced support for
ToolStripPerformanceChart control that can be dropped onto a
Time Series Collection
First of all, I introduced time series. Each serie has a
SerieStyle property that defines the serie's appearance. The style specifies whether the average value and its line are visible to the user, as well as defines colors and line style for the serie and the average value lines.
Once the time serie object was all done, I created a collection of the series. However, due to a number of limitations (one of which is the absence of events) I could not use standard
List<T> as a base class for the collection. Some time back, I wrote my own library which defines a
ListWithEvents<T> class and which was used for my
public class SerieCollection : ListWithEvents<Serie>
protected override void OnItemAdded(ListItemEventArgs e)
this[e.ItemIndex].ValueAdded += new EventHandler(
this[e.ItemIndex].ValueModified += new EventHandler(
private void serieCollection_ValueAddedModified(object sender,
Serie serie = sender as Serie;
if (serie == null)
int index = this.IndexOf(serie);
if (index < 0)
I have also needed to override the
OnItemAdded() method where a new serie gets wired to the
ValueModified events. I do not wire to any other events because it is rather unlikely that a value would be removed from a time serie. However, if you find that in your case it is required, just add more event subscriptions here.
Using the Code
Using the control should be straightforward: reference the library (or drop it on your toolbox) and then add the control to your form. All of the properties exposed through the property grid should be sufficient to set the control. The time series management is made easy with the help of the "Collection Editor UI:"
It is also easy to manipulate the control programmatically. To add a new serie:
Serie serie1 = new Serie();
serie1.SerieStyle.SerieLine.Color = System.Drawing.Color.RoyalBlue;
serie1.SerieStyle.DrawAverageLine = true;
serie1.SerieStyle.DrawAverageValue = true;
serie1.SerieStyle.AverageLine.Color = System.Drawing.Color.RoyalBlue;
serie1.SerieStyle.FormatAverageValue = "N2";
serie1.SerieStyle.FormatMaxMinValues = "N0";
Now add a new value to the serie:
Should you use the control in a synchronised manner and have
PerformanceChart.TimeMode set to anything but
Disabled, to add a new value to the serie you would use the following code:
I thought it may be useful to have a small version of the performance chart just to provide the user with some feedback on running processes. The
ToolStripPerformanceChart control is perfectly suited for this role.
It was surprisingly easy to create this control. All I had to do was to inherit from
ToolStripControlHost and override a few properties:
public partial class ToolStripPerformanceChart : ToolStripControlHost
protected override Padding DefaultMargin
if ((base.Owner != null) && (base.Owner is StatusStrip))
return new Padding(1, 3, 1, 3);
return new Padding(1, 2, 1, 1);
protected override Size DefaultSize
return new Size(16, 16);
public override Size GetPreferredSize(Size constrainingSize)
Size preferredSize = base.GetPreferredSize(constrainingSize);
if (preferredSize.Width < this.DefaultSize.Width)
preferredSize.Width = this.DefaultSize.Width;
if (preferredSize.Height < this.DefaultSize.Height)
preferredSize.Height = this.DefaultSize.Height;
Using this control is just as easy as using the
PerformanceChart control. Use the designer or alternatively, should you wish to do it programmatically, create a serie and add it to the collection of series:
- 2007-08-20: Update to version 188.8.131.52
- 2007-08-06: Initial post, version 184.108.40.206
"Thank you" goes to eclipse2k1 for the original work.