Home > .NET Framework 3.5, C#, Chart Control, Visual Studio, Visual Studio 2008 > Free Chart Control for Framework 3.5 from Microsoft

Free Chart Control for Framework 3.5 from Microsoft

December 20th, 2008

Finally, Microsoft has relased his own chart control. In fact, it is more truth if we say Microsoft bought Dundas firm’s chart controls. But, as a result, Microsoft has a chart control that can integrates his own developer suites. Now, we can say the nightmare of looking for free chart controls or using Excel chart controls via COM has just finished.

I had been using Corlos Aguilar Mare’s chart controls in my ASP.NET projects because of being free. Now, I feel that I have to thank to Carlos. ;)

I will give some basic knowledge about this control in this essay and complete this essay with a sample .

You can download this free chart control from this link. If you want to glance at some samples you can also reach them with this link.

Microsoft presents his chart controls in two different dll groups. The first dll group is for window applications and the second is for the web applications which will be implemented with ASP.NET. Install the first executable file called ‘MSChart.exe’ that I have referenced in first link. Later on installing, you will see 4 dll files under “…\Program Files\Microsoft Chart Controls\Assemblies” path. These dll files are:

  • System.Web.DataVisualization.Design.dll
  • System.Web.DataVisualization.dll
  • System.Windows.Forms.DataVisualization.Design.dll
  • System.Windows.Forms.DataVisualization.dll

As I mentioned just before, there are 2 dlls for windows applications and 2 dlls for web applications and therefore, there are 2 dll groups totally. The dll files that start with ‘System.Web’ is for web group and the dll files start with ‘System.Windows’ is for windows group.

You can drag and drop these dlls into toolbox of Visual Studio or you can install another add on that is developed for Visual Studio 2008. You can download this add on via this link. When you downloaded and installed, you will see a control named ‘Chart’ underlying ‘Data’ tab of toolbox. An important point, it is not possible to use the chart control of add on without installing MSChart.exe file. But, this add on is not absolutely required. If you install MSChart.exe and if you drag and drop the dll files that I have mentioned above into toolbox is an another solution to use chart control.

Before stepping to my sample, let’s look at the examples of ‘WebSamples’ that I have mentioned above.

chart1

chart2

chart3

They are so beatiful, aren’t? You can find more examples in ‘WebSamples’.

Let’s step to my sample. This sample will be a plain sample. I intend to analyze detailed examinations in my next essays.

Simple Chart Application

I have created this web application with Visual Studio 2008. I dragged and dropped chart control from toolbox into Default.aspx. And I changed html code of chart control. Let’s look at the html code of Default.aspx file.


<asp:CHART ID=”Chart1″ runat=”server” BackColor=”243, 223, 193″

BackGradientStyle=”TopBottom” BorderColor=”#B54001″ BorderDashStyle=”Solid”

BorderWidth=”2px” Height=”296px”

ImageLocation=”~/TempImages/ChartPic_#SEQ(300,3)” Width=”590px”>

<legends>

<asp:Legend BackColor=”Transparent” Enabled=”False”

Font=”Trebuchet MS, 8.25pt, style=Bold” IsTextAutoFit=”False” Name=”Default”>

</asp:Legend>

</legends>

<borderskin SkinStyle=”Emboss” />

<chartareas>

<asp:ChartArea BackColor=”OldLace” BackGradientStyle=”TopBottom”

BackSecondaryColor=”White” BorderColor=”64, 64, 64, 64″ BorderDashStyle=”Solid”

Name=”ChartArea1″ ShadowColor=”Transparent”>

<area3dstyle Inclination=”40″ IsClustered=”False” IsRightAngleAxes=”False”

LightStyle=”Realistic” Perspective=”9″ Rotation=”25″ WallWidth=”3″ />

<axisy LineColor=”64, 64, 64, 64″>

<LabelStyle Font=”Trebuchet MS, 8.25pt, style=Bold” />

<MajorGrid LineColor=”64, 64, 64, 64″ />

</axisy>

<axisx LineColor=”64, 64, 64, 64″>

<LabelStyle Font=”Trebuchet MS, 8.25pt, style=Bold” />

<MajorGrid LineColor=”64, 64, 64, 64″ />

</axisx>

</asp:ChartArea>

</chartareas>

</asp:CHART>

Then, I changed the Page_Load method as below.

protected void Page_Load(object sender, EventArgs e)
{

Chart1.Series.Add(”Product X”);
Chart1.Series["Product X"].ChartType = SeriesChartType.Line;
Chart1.Series["Product X"].BorderWidth = 2;

Chart1.Series["Product X"].Points.AddXY(”January”, 50);
Chart1.Series["Product X"].Points.AddXY(”February”, 35);
Chart1.Series["Product X"].Points.AddXY(”March”, 30);
Chart1.Series["Product X"].Points.AddXY(”April”, 60);
Chart1.Series["Product X"].Points.AddXY(”May”, 40);
Chart1.Series["Product X"].Points.AddXY(”June”, 72);

Chart1.Series.Add(”Product Y”);
Chart1.Series["Product Y"].ChartType = SeriesChartType.Line;
Chart1.Series["Product Y"].BorderWidth = 2;

Chart1.Series["Product Y"].Points.AddXY(”January”, 40);
Chart1.Series["Product Y"].Points.AddXY(”February”, 55);
Chart1.Series["Product Y"].Points.AddXY(”March”, 90);
Chart1.Series["Product Y"].Points.AddXY(”April”, 47);
Chart1.Series["Product Y"].Points.AddXY(”May”, 80);
Chart1.Series["Product Y"].Points.AddXY(”June”, 60);

Chart1.Legends[0].Enabled = true;

}

Let’s mention about the mission of this application. The type of chart control is LineChart type. There are two products called ‘Product X’ and ‘Product Y’. This chart shows the sales amount of these products. After run this application, the screen shot will be as below.

sonuc

You can comment or contact me for your questions or comments.

.NET Framework 3.5, C#, Chart Control, Visual Studio, Visual Studio 2008

  1. Ersan Uygur
    December 22nd, 2008 at 00:09 | #1

    güzel bir paylaşım olmuş. emeğiniz için teşekkürler.

  2. özge
    December 23rd, 2008 at 09:28 | #2

    Anlaşılır ve hoş bir uygulama örneği. Elinize sağlık.

  3. vi
    December 25th, 2008 at 12:12 | #3

    teşekkürler, işe yaradı doğrusu :)

  4. orlando
    March 1st, 2009 at 16:23 | #4

    MsChart control needs a full trust level access on the web server which is not provided by my hosting service, ¿is there a way to reduce the trust level required?

  5. March 2nd, 2009 at 22:21 | #5

    Hi Orlando,

    Full trust to where? Maybe it’s creating some files under project of web server. Can you send detailed information?

  1. No trackbacks yet.