Click here to Skip to main content
13,863,067 members
Click here to Skip to main content
Add your own
alternative version


112 bookmarked
Posted 11 Jul 2005
Licenced MIT

Cristi Potlog's Chart Control for .NET

, 25 Jul 2005
Rate this:
Please Sign up or sign in to vote.
This article introduces a sample chart control for Windows Forms.

ChartControl Sample Image.


There are a few samples of chart controls out there and a myriad of commercial chart controls. It seems that there is a large market and a strong need for such controls.

I will introduce here a sample chart control just for the sake of making an example. I can't guarantee, though, that it would fit any real world application requirements.


The sample chart uses basic .NET drawing libraries, and there are no third party components. I will illustrate first a basic time-series line chart.

Using the code

To use the control, you need to add a reference to the compiled ChartControl.dll or you can use the source directly by adding the library to your solution. This should provide more flexibility and you can also change the code to fit your particular needs.

The control should appear on the toolbox now (the sample images assume that you are using source code reference):

ChartControl on the toolbox.

You can create a new form on your application project and place a chart control on the form. Set the Dock property to DockStyle.Fill and you will have something like this:

ChartControl with no settings and data.

You can start making changes to the default chart's properties to improve the visual effects of the chart:

ChartControl properties settings.

For a complete list of the settings, you can view the sample project. Then you can have something like what you see in the image at the top of the article.

Chart control details

The chart control is designed from a series of helper classes that hold specific information about how the control should be displayed. You'll notice that these classes are nested within each other so we can have a coherent model for the chart's components.

ChartTitleSettings class

Represents the display setting for a title of the chart control. Through its properties you can change the appearance of the title, both color and font, and also the text that will be displayed.

This class is used to represent the title of the chart, the title of the axis of the chart, and the title of the series.

ChartLabelsSettings class

Represents the display setting for labels of the chart control. The difference between a label and a title is that in a label you cannot control the text that is displayed. A label has, also, the possibility to rotate the text that it displays. You can choose not to display the label by setting the Visible property to False. You can obtain the same effect on a title by setting its title to an empty string.

This class is used to represent the labels that appear next to the chart's series values and the chart's axis pointers.

ChartLineSettings class

Represents the display setting for a line of the chart control. Through its properties you can set the color, weight and dash style of the line, as well as the fact that the line is visible or not.

This class is used to represent the lines of the chart's grid, axis, series and values projections, as well as the border lines of the chart's legend.

ChartGridSettings class

Represents the display setting for the grid of the chart control. You can set the settings of the grid line through a property of type ChartLineSettings. You can also specify the density of the grid by setting the XAxisStyle and YAxisStyle properties.

ChartMarkSettings class

Represents the display setting for a value mark of the chart control. You can change the appearance of the marks of the chart series value by setting fill color and border color and by selecting the shape of the mark from a list of predefined values:

/// <summary>
/// Specifies the shapes of the value series marks for the chart control.
/// </summary>
public enum ChartMarkShapes

ChartProjectionsSettings class

Represents the display setting for the projections of the chart control. A projection is a line drawn from the value mark to the time axis to pin point the exact time frame of the value. It consists of a line and a label close to the axis that indicates the time.

You can control the appearance of the line and of the label through properties of type ChartLineSettings and ChartLabelSettings. You can specify if the projection should be displayed or not by setting the boolean Visible property.

ChartSeriesSettings class

Represents the setting for the time series of the chart control. This is a complex class compared with previous ones. You can control the settings of the series including the values to be displayed.

ChartLegendSettings class

Represents the display setting for the legend of the chart control. Through this class' properties, you can specify whether the legend will appear or not, the position at which it will be displayed, and the appearance of the border line of the legend.

Possible values for Position are:

/// <summary>
/// Specifies the position at which the legend will be displayed on the chart control.
/// </summary>
public enum ChartMarkShapes

ChartTimeScaleSettings class

Represents the setting for the time axis scale of the chart control. It provides properties to control the limits of the time scale.

ChartValueScaleSettings class

Represents the setting for the values axis scale of the chart control. It provides properties to control the limits of the value scale.

ChartTimeAxisSettings and ChartValueAxisSettings class

ChartTimeAxisSettings represents the display setting for the time axis of the chart control.

ChartValueAxisSettings represents the display setting for the value axis of the chart control.

Both these classes are derived from ChartAxisSettingsBase abstract class which provides the basic elements of the axis such as title, label, line and tick styles. Each class adds a Scale property of ChartTimeScaleSettings type and ChartValueScaleSettings type, respectively.

ChartSeriesValue and ChartSeriesValueCollection classes

ChartSeriesValue represents a value from the time series of the chart control. This class has two properties Date and Value that specify the data that should appear on the chart representing a certain value at a specific point in time.

ChartSeriesValueCollection represents a collection of values from the time series of the chart control.

Implementation notes class

This is to be considered work in progress. This is not the final nor the complete version of the control. I released the code so that I can get some feedback from you in order to add more features to it as well as to refine the design, especially the event model design.

Future directions

  • Multiple series support.
  • Designer support through custom editors.
  • More chart types support (e.g., bar chart, pie chart).


  • July 11th 2005. Initial release.
  • July 22nd 2005. Article contents update.


This article, along with any associated source code and files, is licensed under The MIT License


About the Author

Cristi Potlog
Software Developer
Romania Romania
No Biography provided

You may also be interested in...


Comments and Discussions

GeneralAdding a Third Y Axis Pin
Member 31521618-Mar-12 6:50
memberMember 31521618-Mar-12 6:50 
GeneralNew Version Pin
Akramany29-Jul-09 3:50
memberAkramany29-Jul-09 3:50 
Generalnice effort but... Pin
cinamon14-Jun-09 12:15
membercinamon14-Jun-09 12:15 
GeneralChartTimeUnits Pin
Omar.Pessoa27-Apr-09 11:34
memberOmar.Pessoa27-Apr-09 11:34 
GeneralNew version Pin
Rovira25-Sep-07 23:42
memberRovira25-Sep-07 23:42 
GeneralRe: New version Pin
Cristi Potlog7-Oct-07 12:32
memberCristi Potlog7-Oct-07 12:32 
GeneralRe: New version Pin
dchris_med12-Feb-09 22:15
memberdchris_med12-Feb-09 22:15 
AnswerRe: New version Pin
Cristi Potlog13-Feb-09 23:16
memberCristi Potlog13-Feb-09 23:16 
QuestionDouble Values on X-Axis? Pin
Titty16-Mar-07 1:25
memberTitty16-Mar-07 1:25 
GeneralAnother free chart Pin
Zvikabh6-Feb-07 5:06
memberZvikabh6-Feb-07 5:06 
GeneralJFreeChart Pin
phirzel25-Jan-07 23:47
memberphirzel25-Jan-07 23:47 
Questionis it possible? Pin
ssouki23-Nov-06 1:14
memberssouki23-Nov-06 1:14 
QuestionHow to make a curve Pin
Bugsaway9-Aug-06 11:51
memberBugsaway9-Aug-06 11:51 
AnswerRe: How to make a curve Pin
Cristi Potlog14-Aug-06 11:30
memberCristi Potlog14-Aug-06 11:30 
GeneralGreat Chart but... Pin
Andyc7616-Mar-06 2:09
memberAndyc7616-Mar-06 2:09 
AnswerRe: Great Chart but... Pin
Cristi Potlog16-Mar-06 4:07
memberCristi Potlog16-Mar-06 4:07 
GeneralRe: Great Chart but... Pin
Dave Lenz15-May-06 18:46
memberDave Lenz15-May-06 18:46 
Generaltime scale / multiple series Pin
Cole Cranford31-Jan-06 13:29
memberCole Cranford31-Jan-06 13:29 
GeneralSelect parts of chart with mouse Pin
wizdd10-Jan-06 6:52
memberwizdd10-Jan-06 6:52 
AnswerRe: Select parts of chart with mouse Pin
Cristi Potlog10-Jan-06 22:17
memberCristi Potlog10-Jan-06 22:17 
General"Measure" events Pin
wizdd10-Jan-06 6:45
memberwizdd10-Jan-06 6:45 
GeneralRe: "Measure" events Pin
Cristi Potlog10-Jan-06 22:12
memberCristi Potlog10-Jan-06 22:12 
GeneralIs the hour Pin
negralina525-Aug-05 23:02
membernegralina525-Aug-05 23:02 
GeneralImpovement Pin
negralina525-Aug-05 22:22
membernegralina525-Aug-05 22:22 
AnswerRe: Impovement Pin
Cristi Potlog28-Aug-05 22:11
memberCristi Potlog28-Aug-05 22:11 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web04 | 2.8.190214.1 | Last Updated 25 Jul 2005
Article Copyright 2005 by Cristi Potlog
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid