开发者

Any ASP.NET MVC-friendly chart controls that support pie charts with different slice radii?

I need to create a sort of pie chart that has slices with differing radii - similar to:

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

I also want to over开发者_Python百科lay a second series on it, as a line.

The solution needs to be ASP.NET MVC-friendly - and I need to be able to associate "drill down" links with the slices.

If there's no off-the-shelf solution, is it going to be possible to customize the Microsoft Chart Controls pie chart to this extent? Or is this just too much customization and I'd end up spending more time fighting the existing code than writing my own?


jqPlot is excellent. It took us less than an hour to get beautiful charts up and running. This is a pure js implementation. They worked in all browsers and even on mobile phones.

http://www.jqplot.com/


Have you tried looking at http://plugins.jquery.com/project/gchart? It should be MVC friendly, considering it's jquery. I'm not sure if it will be able to do exactly what you want, but it might be worth a look.


Have you taken a look at highcharts. You can create pie charts with varing radius (demo )and also overlay a line on top of it (demo). Though, I am not sure if you can exactly replicate the kind of chart you have mentioned, you can always put a request to the developer. He is quite fast in getting new features out.


Webmatrix has built in chart support.

I don't know if it supports pie charts with different slice radi. I am using WebGrid (also from Webmatrix) in my current asp.net mvc project and it is working out quite well.

Here are some useful links:

how-webmatrix-razor-asp-net-web-pages-and-mvc-fit-together

Displaying data in a pie chart


This may help you ** Controller***

    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();
   }

    }
   }

* Model *****

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; }
  }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜