在asp.net mvc上應用新ASP.NET圖表控制項

來源:互聯網
上載者:User

微軟去年11月發布了一個很酷的新ASP.NET伺服器控制項,<asp:chart />,可以免費用在ASP.NET 3.5中,而且還可以用在asp.net mvc。可以看新ASP.NET圖表控制項<asp:chart runat="server"/>。

相關資源的下載連結:

  • Download the free Microsoft Chart Controls
  • Download the VS 2008 Tool Support for the Chart Controls
  • Download the Microsoft Chart Controls Samples
  • Download the Microsoft Chart Controls Documentation

    這位台胞的兩篇相當不錯的文章

    Microsoft Chart Controls 心得(1)

    Microsoft Chart Controls 心得(2) - 如何透過圖表傳值

    園子裡的相關文章:

    ASP.NET圖表控制項

    我今天才知道ASP.NET圖表控制項發布了,附一個線上文檔

  • .NET MSChart應用的一個簡單例子

  • 告別.NET產生報表統計圖的煩惱

  • 在這裡有一篇文章簡短介紹了Combining ASP.NET MVC and ASP.NET Charting Controls.

    編輯Web.Config
    將控制項的命名空間加到 (path: "<system.web><pages><controls>") :

    <add tagPrefix="asp" namespace="System.Web.UI.DataVisualization.Charting" assembly="System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
    添加一個 httpHandler ("<httpHandlers>"下面) :
     <add path="ChartImg.axd" verb="GET,HEAD" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
    將chart 控制項添加到view
    <p><%System.Web.UI.DataVisualization.Charting.Chart Chart2 = new System.Web.UI.DataVisualization.Charting.Chart();Chart2.Width = 412;Chart2.Height = 296;Chart2.RenderType = RenderType.ImageTag;Chart2.Palette = ChartColorPalette.BrightPastel;Title t = new Title("No Code Behind Page", Docking.Top, new System.Drawing.Font("Trebuchet MS", 14, System.Drawing.FontStyle.Bold), System.Drawing.Color.FromArgb(26, 59, 105));Chart2.Titles.Add(t);Chart2.ChartAreas.Add("Series 1");// create a couple of seriesChart2.Series.Add("Series 1");Chart2.Series.Add("Series 2");// add points to series 1foreach (int value in (List<int>)ViewData["Chart"]){Chart2.Series["Series 1"].Points.AddY(value);}// add points to series 2foreach (int value in (List<int>)ViewData["Chart"]){Chart2.Series["Series 2"].Points.AddY(value + 1);}Chart2.BorderSkin.SkinStyle = BorderSkinStyle.Emboss;Chart2.BorderColor = System.Drawing.Color.FromArgb(26, 59, 105);Chart2.BorderlineDashStyle = ChartDashStyle.Solid;Chart2.BorderWidth = 2;Chart2.Legends.Add("Legend1");// Render chart controlChart2.Page = this;HtmlTextWriter writer = new HtmlTextWriter(Page.Response.Output);Chart2.RenderControl(writer);%></p>
    效果如下:
     
    本文代碼基於asp.net mvc rc版本:MVCCharting 
    Streaming Chart Images as FileResult from MVC Controllers : http://www.codeproject.com/KB/aspnet/MvcChartControlFileResult.aspx
    用 ASP.NET 和 LINQ 圖表的終極 ASP.NET :http://msdn.microsoft.com/zh-cn/magazine/dd453008.aspx
  • 相關文章

    聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.