VS2010與.NET4系列 15.內置的圖表控件

今天介紹 .NET 4 中爲 ASP.NET 和 Windows Forms 新增的內置圖表控件支持。

ASP.NET 和 Windows Forms 的圖表控件

在14個月以前,我在一篇博客日誌上撰寫了關於微軟正在爲 ASP.NET 3.5 和 Windows Forms 3.5 製作可用的免費圖表控件下載

你可以下載並在你的 Web 和 客戶端應用程序中使用這些運行時控件。你還可以爲它們下載VS2008 工具化支持。它們提供了一套豐富的圖表能力,很容易使用。要獲得所有使用它們的直觀感覺,我推薦 ASP.NET 和 Windows Forms 案例項目下載,它提供了超過200個案例。下面是來自 ASP.NET 案例應用程序中一些餅圖和圈餅圖的圖表控件示例的截圖:

image

內置於 .NET 4 的圖表控件

在 .NET 3.5 中你不得不單獨下載圖表控件並加入到應用程序中。在 .NET 4 中這些控件現在已經內置在 ASP.NET 4 和 Windows Forms 4 中,這意味着你能夠立即利用它們(不用單獨下載或註冊了)。

在 ASP.NET 應用程序內部你會在工具箱的“數據”選項卡發現一個新的內置的 <asp:chart> 控件:

image

你可以使用這個控件,而不必註冊任何配置文件條目。圖表控件全部的配置現在都預先註冊在ASP.NET 4 中了(這意味着不用在應用程序的 Web.config 文件中添加了)。這使得能夠保持非常乾淨而且最小化的 Web.config 文件。

學習關於 <asp:chart> 控件的更多知識

Scott Mitchell 已經在 www.4guysfromrolla.com 撰寫了一系列很棒的文章,講解如何利用 <asp:chart> 控件:

  1. Getting Started - walks through getting started using the Chart Controls, from version requirements to downloading and installing the Chart Controls, to displaying a simple chart in an ASP.NET page.
  2. Plotting Chart Data - examines the multitude of ways by which data can be plotted on a chart, from databinding to manually adding the points one at a time.
  3. Rendering the Chart - the Chart Controls offer a variety of ways to render the chart data into an image. This article explores these options.
  4. Sorting and Filtering Chart Data - this article shows how to programmatically sort and filter the chart's data prior to display.
  5. Programmatically Generating Chart Images - learn how to programmatically create and alter the chart image file.
  6. Creating Drill Down Reports - see how to build drill down reports using the Chart control.
  7. Adding Statistical Formulas - learn how to add statistical formulas, such as mean, median, variance, and forecasts, to your charts.
  8. Enhancing Charts With Ajax - improve the user experience for dynamic and interactive charts using Ajax.
  9. Serializing Chart Data - see how to persist a chart's data and appearance to a persistent store.

他的文章是使用 .NET 3.5 和單獨下載的 ASP.NET 圖表控件撰寫的,但是全部的概念和語法都和 ASP.NET 4 完全相同。

Michael Ceranski 也指定了博客日誌演示了如何在 ASP.NET MVC 應用程序中使用 ASP.NET Chart 控件。我希望將來很快有人能創建一些良好的 ASP.NET MVC Html.Chart() 輔助方法來使它更容易做到。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章