2012-05-06 6 views

答えて

1

素晴らしい私は問題を解決しました! 私はそれがあまりにも他の誰かのために役に立つかもしれないと思う:

ここでは、コントローラのコードです:

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

ここで、それはまた、円グラフを作成アヤックス側である:

jQuery.getJSONを( "/コントローラ名/アクション名"、関数(データ){

// # 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 }); 
    } 
}); 

});

関連する問題