1
votes

I have a pie chart and I want to "explode" a highlighted slice.

Using the following:

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

However, I get an "Index out of range" error when it hits the line:

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

The examples I have seen have discretely plotted DataPoints, so I don't know if this is the issue.

1

1 Answers

3
votes

I'm an idiot.

            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 - because I have now bound the data to the Chart.