Using Microsoft's Chart Controls In An ASP.NET Application: Using the Chart Controls with ASP.NET MVC | CodeGuru

Using Microsoft’s Chart Controls In An ASP.NET Application: Using the Chart Controls with ASP.NET MVC

The Microsoft Chart controls are a series of classes in the System.Web.UI.DataVisualization.Charting namespace that allow web developers to ability to add charts to their ASP.NET applications. The most pertinent charting-related class is the Chart class, which contains information about the chart’s appearance, series, charting areas, and so forth. In most of the demos and code […]

Written By
CodeGuru Staff
CodeGuru Staff
Sep 22, 2010
2 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

The Microsoft Chart controls are a series of classes in the System.Web.UI.DataVisualization.Charting namespace that allow web
developers to ability to add charts to their ASP.NET applications. The most pertinent charting-related class is the Chart class,
which contains information about the chart’s appearance, series, charting areas, and so forth. In most of the demos and code
samples we’ve explored thus far, we’ve used the Chart class as a Web control, adding the declarative markup to our
ASP.NET page, setting a few properties and, occasionally, writing a few lines of code. When used as a Web control, the Chart class
both creates the chart (as an image) and then renders an element that points to the generated chart image.

Using the Chart Web control is a standard practice in a WebForms application, but it is not suggested when building an ASP.NET MVC
application. (While it is possible to add Web controls – including the Chat Web control – to the views of an ASP.NET MVC
application, it is generally frowned upon.) So, if we can’t use the Chart Web control in an ASP.NET MVC application, how do we
display a chart? In addition to being used as a Web control, the Chart class can also be used programmatically. It is quite
possible to create a new Chart object, set some properties, plot the data points, and then generate the chart image. In fact, we
looked at using this technique in an earlier installment, Programmatically Generating Chart Images, in which we saw (among other
things) how to generate chart images programmatically and add them as attachments in an email message.

This article explores how to display charts in an ASP.NET MVC application. To read the entire article, Using Microsoft’s Chart Controls In An ASP.NET Application: Using the Chart Controls with ASP.NET MVC, click here.

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.