MS Chart Control Exploded Pie不会

时间:2011-02-21 21:32:20

标签: asp.net charts

我有一个饼图,我想“爆炸”一个突出显示的切片。

使用以下内容:

var qCounts = (from request in qCategory 
   group request by new { request.Category, request.Subcategory } into g 
             orderby g.Count() descending
                select new { 
                    g.Key.Category, 
                    g.Key.Subcategory,
                    CategoryCouplet = g.Key.Category + " - " + g.Key.Subcategory,
                             Count = g.Count() }).Take(10);

 mscPain.DataSource = qCounts;
 mscPain.Series["Pain Areas"].XValueMember = "CategoryCouplet";
 mscPain.Series["Pain Areas"].YValueMembers = "Count";
 mscPain.Series["Pain Areas"]["PieLabelStyle"] = "Disabled";
 mscPain.Series["Pain Areas"].Points[0]["Exploded"] = "True";
 mscPain.DataBind();

但是,当它到达该行时,我会收到“Index out of range”错误:

mscPain.Series["Pain Areas"].Points[0]["Exploded"] = "True";

我见过的例子已经离散地绘制了DataPoints,所以我不知道这是不是问题。

1 个答案:

答案 0 :(得分:3)

我是个白痴。

            mscPain.DataSource = qCounts;
            mscPain.Series["Pain Areas"].XValueMember = "CategoryCouplet";
            mscPain.Series["Pain Areas"].YValueMembers = "Count";
            mscPain.Series["Pain Areas"]["PieLabelStyle"] = "Disabled";

            mscPain.DataBind();
            mscPain.Series["Pain Areas"].Points[0]["Exploded"] = "True";

Works - 因为我现在已将数据绑定到图表。