C1 Community
ComponentOne Community is a free source for developers and help authors to collaborate and communicate.

Display Pie Chart Clockwise?

rated by 0 users
This post has 2 Replies | 0 Followers

Not Ranked
Posts 9
anders22 Posted: Sat, Nov 29 2008 7:21 PM

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

Top 10 Contributor
Posts 1,090

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

Top 10 Contributor
Posts 1,090
C1_JohnAd replied on Wed, Dec 10 2008 2:50 AM
Hello Joe,
 
The Pie slice rotation issue has been escalated to concerned department as a feature request for future version of C1WebChart.
You may refer to the following reference ID  #18715
 
Regards,
John Adams
<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

Page 1 of 1 (3 items) | RSS
Contact ComponentOne: 1.800.858.2739 ©1987-2010 ComponentOne LLC All Rights Reserved.