Asp.net mvc 3 使用ASP.NET MVC3从数据库中获取动态数据的图形图表

Asp.net mvc 3 使用ASP.NET MVC3从数据库中获取动态数据的图形图表,asp.net-mvc-3,graphael,Asp.net Mvc 3,Graphael,我想了解如何从数据库中获取数据,并在图表中显示这些数据 我在ASP.NET MVC3中工作,我真的不知道如何让这些东西工作。 非常感谢您的帮助。太好了,我解决了这个问题! 我认为这对其他人也很有用: 这是控制器代码: public ActionResult ActionName() { List<String> data = new List<String>(); data.Add("legend0_4")

我想了解如何从数据库中获取数据,并在图表中显示这些数据
我在ASP.NET MVC3中工作,我真的不知道如何让这些东西工作。

非常感谢您的帮助。

太好了,我解决了这个问题! 我认为这对其他人也很有用:

这是控制器代码:

 public ActionResult ActionName()
        {
            List<String> data = new List<String>();
            data.Add("legend0_4");
            data.Add("legend1_5");
            data.Add("legend2_8");
            data.Add("legend3_12");
            data.Add("legend4_8");

            return Json(data, JsonRequestBehavior.AllowGet);
        }
}))

// # Init
var levels = [], values = [];


for (var id in data) {
    var compo = data[id].split("_");
    levels.push("%%.%% " + compo[0]);
    values.push(parseInt(compo[1]));
}

var r = Raphael("accountCharts"),
            pie = r.piechart(320, 240, 100, values, { legend: levels, legendpos: "west", href: ["http://raphaeljs.com", "http://g.raphaeljs.com"] });

r.text(320, 100, "Interactive Pie Chart").attr({ font: "20px sans-serif" });
pie.hover(function () {
    this.sector.stop();
    this.sector.scale(1.1, 1.1, this.cx, this.cy);

    if (this.label) {
        this.label[0].stop();
        this.label[0].attr({ r: 7.5 });
        this.label[1].attr({ "font-weight": 800 });
    }
}, function () {
    this.sector.animate({ transform: 's1 1 ' + this.cx + ' ' + this.cy }, 500, "bounce");

    if (this.label) {
        this.label[0].animate({ r: 5 }, 500, "bounce");
        this.label[1].attr({ "font-weight": 400 });
    }
});