2010-10-28 45 views
4

我需要創造一種具有與不同的半徑切片餅圖 - 類似於:任何支持具有不同切片半徑的餅圖的ASP.NET MVC友好圖表控件?

http://www.andypope.info/charts/pieradius.htm

我也想疊加第二個系列,作爲一條線。

解決方案需要ASP.NET MVC友好 - 我需要能夠將「向下鑽取」鏈接與切片相關聯。

如果沒有現成的解決方案,是否可以自定義Microsoft Chart Controls餅圖到這種程度?或者這太定製了,我最終會花費更多的時間來對付現有的代碼,而不是寫自己的代碼?

回答

0

您是否試過在http://plugins.jquery.com/project/gchart?它應該是MVC友好的,考慮到它的jQuery。我不確定它是否能夠做到你想要的,但它可能值得一看。

+0

是,我看在此,謝謝。但它似乎沒有我需要的。 – dommer 2010-10-30 14:15:50

0

你看過highcharts嗎?您可以創建具有變化半徑的餅圖(demo),也可以在其上覆蓋一行(demo)。雖然我不確定您是否可以完全複製您提到的那種圖表,但您始終可以向開發人員提出請求。他在獲取新功能方面速度非常快。

1

jqPlot非常出色。我們花了不到一個小時纔得到漂亮的圖表。這是一個純粹的js實現。他們在所有瀏覽器甚至手機上工作。

http://www.jqplot.com/

0

這可能會幫助你 **控制器***

using System; 
    using System.Collections.Generic; 
    using System.Linq; 
    using System.Web; 
    using System.Web.Mvc; 
    using MvcApp.Models; 
    using System.Web.Helpers; 

    namespace MvcApp.Controllers 
    { 
    public class HomeController : Controller 
    { 
     public ActionResult Index() 
     { 
      ViewBag.Message = "Welcome to ASP.NET MVC!"; 

      return View(); 
     } 

     public ActionResult About() 
     { 
      return View(); 
     } 
     public ActionResult ChartDispaly() 
     { 
      ChartImage(); 
      return View(); 
     } 
     public void ChartImage() { 
     IEnumerable<Product> productList = new List<Product> { 
     new Product {Name = "Kayak", Category = "Watersports", Price = 275m}, 
     new Product {Name = "Lifejacket", Category = "Watersports", Price = 48.95m}, 
     new Product {Name = "Soccer ball", Category = "Football", Price = 19.50m}, 
     new Product {Name = "Corner flags", Category = "Football", Price = 34.95m}, 
     new Product {Name = "Stadium", Category = "Football", Price = 150m}, 
     new Product {Name = "Thinking cap", Category = "Chess", Price = 16m} 
     }; 
     Chart chart = new Chart(400, 200, 
     @"<Chart BackColor=""Gray"" BackSecondaryColor=""WhiteSmoke"" 
     BackGradientStyle=""DiagonalRight"" AntiAliasing=""All"" 
     BorderlineDashStyle = ""Solid"" BorderlineColor = ""Gray""> 
     <BorderSkin SkinStyle = ""Emboss"" /> 
     <ChartAreas> 
      <ChartArea Name=""Default"" _Template_=""All"" BackColor=""Wheat"" 
     BackSecondaryColor=""White"" BorderColor=""64, 64, 64, 64"" 
     BorderDashStyle=""Solid"" ShadowColor=""Transparent""> 
     </ChartArea> 
     </ChartAreas> 
     </Chart>"); 
     chart.AddSeries(
     chartType: "Pie", 
     yValues: productList.Select(e => e.Price).ToArray(), 
     xValue: productList.Select(e => e.Name).ToArray()  
     ); 
     chart.Write(); 
    } 

    } 
    } 

*型號* ****

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Web; 

namespace MvcApp.Models 
{ 
public class Product 
{ 
    public string Name { get; set; } 
    public string Category { get; set; } 
    public decimal Price { get; set; } 
    } 
}