Hi There.
Hoping to get some help getting Pie chart slices to rotate clockwise. The default display of a Pie chart is pretty non-standard - it has the first slice starting 90 degrees clockwise from top and the slices rotate counterclockwise. I figured out how to move the first series to start at the top of the pie, but getting the order to go clockwise is a little tricker.
The problem with inverting the series order is it also inverts the legend. I need the pie chart to both flow clockwise and the legend order to basically be sorted alphabetically.
Note that ideally the default pie parameters sould be set to what Users normally see when they look at a pie chart, e.g. slices start at the top, rotate clockwise and legend is sorted in slice order. Baring that, if a function could be added to allow specifying clockwise vs. counterclockwise, that would also work.
One other comment - it's a bear figuring out how to put labels on a pie chart. I found several examples, but still have not got it to work yet. This is another pretty standard thing to do with pie charts.
Thanks!Joe Anders
Hello Joe,
We are working on the clockwise rotation of pie slice issue.
However, as far as labels are concerned we can add labels to a pie chart in the following manner:
BEGIN CODE
DataView data = _dataSet.Tables["Products"].DefaultView;
data.Sort = "UnitPrice";
data.RowFilter = "CategoryID = 1"; // beverages
// configure chart
c1Chart1.Reset();
c1Chart1.BackColor = Color.White;
c1Chart1.ChartArea.Style.Font = new Font("Tahoma", 8);
c1Chart1.ChartGroups[0].ChartType = Chart2DTypeEnum.Pie;
// get series collection (pies have one series per slice)
ChartDataSeriesCollection dscoll = c1Chart1.ChartGroups[0].ChartData.SeriesList;
dscoll.Clear();
// populate the series
for (int i = 0; i < data.Count; i++)
{
ChartDataSeries series = dscoll.AddNewSeries();
series.PointData.Length = 1;
series.Y[0] = data[i]["UnitPrice"];
series.Label = string.Format("{0} ({1:c})",
data[i]["ProductName"], data[i]["UnitPrice"]);
}
// show pie legend
c1Chart1.Legend.Visible = true;
c1Chart1.Legend.Text = "Product Unit Prices";
// hide legend, configure labels
c1Chart1.Legend.Visible = false;
Style s = c1Chart1.ChartLabels.DefaultLabelStyle;
s.Font = new Font("Tahoma", 7);
s.BackColor = SystemColors.Info;
s.Opaque = true;
s.Border.BorderStyle = BorderStyleEnum.Solid;
// attach labels to each slice
C1.Win.C1Chart.Label lbl = c1Chart1.ChartLabels.LabelsCollection.AddNewLabel();
lbl.Text = string.Format("{0} ({1:c})",
lbl.Compass = LabelCompassEnum.Radial;
lbl.Offset = 20;
lbl.Connected = true;
lbl.Visible = true;
lbl.AttachMethod = AttachMethodEnum.DataIndex;
AttachMethodData am = lbl.AttachMethodData;
am.GroupIndex = 0;
am.SeriesIndex = i;
am.PointIndex = 0;
END CODE
Hope this helps.
Regards,
John Adams
<anders22> wrote in message news:211885@10.0.1.98... Hi There. Hoping to get some help getting Pie chart slices to rotate clockwise. The default display of a Pie chart is pretty non-standard - it has the first slice starting 90 degrees clockwise from top and the slices rotate counterclockwise. I figured out how to move the first series to start at the top of the pie, but getting the order to go clockwise is a little tricker. The problem with inverting the series order is it also inverts the legend. I need the pie chart to both flow clockwise and the legend order to basically be sorted alphabetically. Note that ideally the default pie parameters sould be set to what Users normally see when they look at a pie chart, e.g. slices start at the top, rotate clockwise and legend is sorted in slice order. Baring that, if a function could be added to allow specifying clockwise vs. counterclockwise, that would also work. One other comment - it's a bear figuring out how to put labels on a pie chart. I found several examples, but still have not got it to work yet. This is another pretty standard thing to do with pie charts. Thanks!Joe Anders http://helpcentral.componentone.com/cs/forums/p/77443/211885.aspx#211885
<C1_JohnAd> wrote in message news:212068@10.0.1.98... Hello Joe, We are working on the clockwise rotation of pie slice issue. However, as far as labels are concerned we can add labels to a pie chart in the following manner: BEGIN CODE DataView data = _dataSet.Tables["Products"].DefaultView; data.Sort = "UnitPrice"; data.RowFilter = "CategoryID = 1"; // beverages // configure chart c1Chart1.Reset(); c1Chart1.BackColor = Color.White; c1Chart1.ChartArea.Style.Font = new Font("Tahoma", 8); c1Chart1.ChartGroups[0].ChartType = Chart2DTypeEnum.Pie; // get series collection (pies have one series per slice) ChartDataSeriesCollection dscoll = c1Chart1.ChartGroups[0].ChartData.SeriesList; dscoll.Clear(); // populate the series for (int i = 0; i < data.Count; i++) { ChartDataSeries series = dscoll.AddNewSeries(); series.PointData.Length = 1; series.Y[0] = data[i]["UnitPrice"]; series.Label = string.Format("{0} ({1:c})", data[i]["ProductName"], data[i]["UnitPrice"]); } // show pie legend c1Chart1.Legend.Visible = true; c1Chart1.Legend.Text = "Product Unit Prices"; // hide legend, configure labels c1Chart1.Legend.Visible = false; Style s = c1Chart1.ChartLabels.DefaultLabelStyle; s.Font = new Font("Tahoma", 7); s.BackColor = SystemColors.Info; s.Opaque = true; s.Border.BorderStyle = BorderStyleEnum.Solid; // attach labels to each slice for (int i = 0; i < data.Count; i++) { C1.Win.C1Chart.Label lbl = c1Chart1.ChartLabels.LabelsCollection.AddNewLabel(); lbl.Text = string.Format("{0} ({1:c})", data[i]["ProductName"], data[i]["UnitPrice"]); lbl.Compass = LabelCompassEnum.Radial; lbl.Offset = 20; lbl.Connected = true; lbl.Visible = true; lbl.AttachMethod = AttachMethodEnum.DataIndex; AttachMethodData am = lbl.AttachMethodData; am.GroupIndex = 0; am.SeriesIndex = i; am.PointIndex = 0; } END CODE Hope this helps. Regards, John Adams <anders22> wrote in message news:211885@10.0.1.98... Hi There. Hoping to get some help getting Pie chart slices to rotate clockwise. The default display of a Pie chart is pretty non-standard - it has the first slice starting 90 degrees clockwise from top and the slices rotate counterclockwise. I figured out how to move the first series to start at the top of the pie, but getting the order to go clockwise is a little tricker. The problem with inverting the series order is it also inverts the legend. I need the pie chart to both flow clockwise and the legend order to basically be sorted alphabetically. Note that ideally the default pie parameters sould be set to what Users normally see when they look at a pie chart, e.g. slices start at the top, rotate clockwise and legend is sorted in slice order. Baring that, if a function could be added to allow specifying clockwise vs. counterclockwise, that would also work. One other comment - it's a bear figuring out how to put labels on a pie chart. I found several examples, but still have not got it to work yet. This is another pretty standard thing to do with pie charts. Thanks!Joe Anders http://helpcentral.componentone.com/cs/forums/p/77443/211885.aspx#211885 http://helpcentral.componentone.com/cs/forums/p/77443/212068.aspx#212068