In this article we are going to see how to use the new charting control with Visual Studio 2010. Chart controls are introduced with Visual Studio 2008 as a patch in Service Pack 1. Chart controls provide a rich user interface for showing the numbers in a very graphical format that most end users are eager to see. Prior to chart controls, developers needed to use third party tools, some open source libraries or use HTML and GDI+ to draw some graphical image as a chart for the end users which requires more user code and time consuming.
Microsoft as introduced this control with a strong awareness of the present scenario of showing the data in an image rather than a grid view or some data viewer controls. The Chart control was introduced in late September 2009 as a separate service pack 1 with Visual Studio 2008. In Visual Studio 2010, Microsoft provided the control in-built which makes it much easier for developers to use the control. This control can be used in both Windows and web applications to show the rich user data in a good graphical format.
The Chart control offers a wide variety of choices to choose the best format required by the end users to view the data. Some of the types of charts available with the control are as follows: PIE Chart, LINE Chart, BAR Chart, BUBBLE Chart, PYRAMID Chart etc. Microsoft has provided around 35 distinct chart types in the latest version of Visual Studio. Also the control provides most of the features required to make the chart more attractive, like providing lines, labels, trend lines etc. The control's API provides an option to make the sorting filter, grouping, searching, merging, splitting and exporting to the required format making the control more robust for the developers to use it for most requirements.
In this article we will see about using the Chart control in both Visual Studio 2008 and Visual Studio 2010 versions starting from the beginner to the experts. Also we will see some good examples of using this control in a Web application and a Windows application to see how flexible the control is used. Microsoft has not provided any Wizard to customize the data chart by giving the data source, customizing the size, look and color of the data, all these things need to be handled by the developer to bind and use the required data format as such.
Since Microsoft provides this chart as a free control along with the Visual Studio, developers have no need to think much about the third parties or the open source tools for charting with the application which gives an advantage to go over this control and use it wherever required. Here we will see how to download, install and use this control in both Visual Studio 2008 and Visual Studio 2010 versions. Since Visual Studio 2008 requires a separate download, we will see the steps of where to download and install the application so that the control will be available in the tool box of the VS 2008 version.
Downloading & Installing for Visual Studio 2008:
The Microsoft Chart control was released as a standalone application with the Visual Studio 2008 Service Pack 1. In order to use this control in VS 2008 version we need to download the control and the libraries from the Microsoft URL (See following for the list of downloads with URL).
Microsoft Chart Control
(Check the following for the download and installation instructions.)
Microsoft Visual Studio 2008 Chart Controls Add on
The Microsoft Visual Studio 2008 Chart Controls Add-on helps to add the control to the toolbox and gives the intellisense support for the chart application.
Microsoft Chart Control Samples - http://archive.msdn.microsoft.com/mschart
The Microsoft Chart control samples are a number of samples on both Windows and web applications that provide a very good start for the beginners to start and use the control.
TheMicrosoft Chart control is the mandatory download remaining 2 things are for our reference purpose which helps to build a very good chart application. Once you downloaded these software from the links provided we need to install and set up the development environment in order to start developing a charting application. We will see in detail how to install and configure the above 3 downloads one by one.
Microsoft Chart Control - Installation:
Click on the link above to open the window as shown in the following screen. Click on download (Mschart.exe) and save it to your local machine.
Now double-click on the Mschart.exe file to install the application. When we install this exe the binaries will be placed in the Global Assembly Cache (GAC) and also will be placed in the ProgramFiles\Microsoft Chart Controls\Assemblies. Since the files are placed in the GAC we can use it globally without placing the DLLs in each and every BIN folder. When we publish the project in the server there will be no need to install the exe; instead we can use the binaries moved to the publish bin folder.
Once you double-click the Mschart.exe it will open the window as shown below. It shows that we need the prerequisite of .Net Framework 3.5 with SP1. Click Next to proceed further.
Click on the license agreement to proceed further as shown in screen below.
The installation process will start and components will be installed one by one and we will see the progress as shown in the screen below.
Once the installation is completed we will see the final message as shown below which indicates that the software has been installed successfully.
We can find the Chart control in the toolbox as shown in the screen below.
Now we are ready with the development environment where we have the chart control installed and tested completely. These are the above steps we need to follow for setting up a development environment for using the Chart Control with Visual Studio 2008 version. As I said earlier since Visual Studio 2010 version includes this control we have no need to follow the above steps for the Visual Studio 2010 version. Now we will see some samples of using the different charts available.

ashok pagidipallisPosted Sep 25, 2014, 1:33 AM
i have one problem.every time series add datapoints but requriement not adding datapoint on series. if (dt.Rows.Count > 0) { for (int i = 1; i < dt.Columns.Count; i++) { for (int j = 0; j < dt.Rows.Count; j++) { // Series series = new Series(); if (chart1.Series.Where(x => x.Name == dt.Rows[j][i].ToString()).Count() > 0) { } else { Series series = new Series(dt.Rows[j][i].ToString()); //series.Name = " "; foreach (Series seriess in chart1.Series) { if (dt.Rows[i][i].ToString() == seriess.Name) { seriess.Points.AddXY(Convert.ToDateTime(dt.Rows[j][0]).ToString(), Convert.ToDouble(dt.Rows[j][i])); } //chart1.Series.Add(seriess); } chart1.Series.Add(series); chart1.Series[i].ChartType = System.Windows.Forms.DataVisualization.Charting.SeriesChartType.Line; //chart1.Series[i].XValueMember = "DateTime"; //chart1.Series[i].YValueMembers = chanelselected; } } }
Soni SamuelPosted Jul 3, 2012, 2:23 AM
I am trying to use a network path for the images as I have a WebFarm which is loadBalanced using CISCO ACE appliance. The reason I am using a network shared folder is that at times the Chart does not show the PNG images. The problem with displaying the PNG images in the Web Farm comes when I had initially the web.config setting as shown below. <add key="ChartImageHandler" value="storage=file;timeout=10;dir=c:\TempImageFiles\;" /> So I used the network Shared path as per (blogs.msdn.com/.../managing-chart-generated-images-with-chart-image-handler.aspx) , where I have FULL Permissions on EVERYONE, NETWORK Service. Below is my current setting for the Network shared folder path and I keep getting this error: Invalid temp directory in chart handler configuration <add key="ChartImageHandler" value="storage=file;timeout=10;dir=\\servername\TempImageFiles\;" /> Can someone help. Rgds,
Anshul GuptaPosted Mar 6, 2012, 1:42 AM
i will try today ...
janaki janakiPosted Dec 22, 2011, 5:26 AM
hi i have one problem with asp.net chart control tootip that is if less number of coloumns are there it showing correctely but if more number of coloumns are there like 15 it will not show correctely, means if data is more than 30 characters to any coloumn it will cutting last coloumn please help its very urgent for me string lToolTipTxt = "Project\t\t\t: " + ProjetcData.Rows[i][PPM_PROJECT] + Environment.NewLine +"Description\t\t: " + ProjetcData.Rows[i][PPM_DESCRIPTION] + Environment.NewLine +"Strategic Value\t\t: " + ProjetcData.Rows[i][PPM_STRATEGICVALUE] + " %" + Environment.NewLine +"NPV\t\t\t: " + ProjetcData.Rows[i][PPM_BUBBLESIZE] + Environment.NewLine +"Budget\t\t\t: " + (ProjetcData.Rows[i][PPM_BUDGET].ToString()) + Environment.NewLine +"Risk Rating\t\t: " + ProjetcData.Rows[i][PPM_RISKTYPE] + Environment.NewLine +"Requestor(s)\t\t: " + ProjetcData.Rows[i][PPM_REQUESTOR] + Environment.NewLine +"Approver(s)\t\t: " + ProjetcData.Rows[i][PPM_APPROVER] + Environment.NewLine +"Manager\t\t: " + ProjetcData.Rows[i][PPM_SPONSOR] + Environment.NewLine +"Sponsor(s)\t\t: " + ProjetcData.Rows[i][PPM_PLANSTART] + Environment.NewLine +"Planned Start\t\t: " + ProjetcData.Rows[i][PPM_PLANEND] + Environment.NewLine +"Planned End\t\t: " + ProjetcData.Rows[i][PPM_PLANEFFORT] + Environment.NewLine +"Planned Effort\t\t: " + ProjetcData.Rows[i][PPM_PROJECTCATEGORY] + Environment.NewLine +"Category\t\t: " + ProjetcData.Rows[i][PPM_PROJECTTYPE] + Environment.NewLine +"Type\t\t\t: " + ProjetcData.Rows[i][PPM_PROJECTCATEGORY] + Environment.NewLine +"Requesting Organization\t: " + ProjetcData.Rows[i][PPM_REQORG] + Environment.NewLine +"Sponsoring Organizaion\t: " + ProjetcData.Rows[i][PPM_SPONORG] + Environment.NewLine + Environment.NewLine + Environment.NewLine + Environment.NewLine; datapoint.tootip=lToolTipTxt; if i give like this it will show above issue
Angelina ErinPosted Jul 26, 2011, 12:19 AM
Good One
Mercy DecostaPosted Jul 26, 2011, 12:12 AM
I am going to try this today. Thank you for sharing nice article.
Dinesh BeniwalPosted Jul 25, 2011, 3:49 AM
Step by step explanation, thanks