.NET pie chart: how to add text to slices and rotate chart
Posted
by Sajee
on Stack Overflow
See other posts from Stack Overflow
or by Sajee
Published on 2009-06-22T23:28:21Z
Indexed on
2010/06/13
22:02 UTC
Read the original article
Hit count: 316
The code below creates a 24 slice pie chart. How do I:
- Add text labels to each slice a la "Wheel of Fortune".
Rotate the pie chart? I want it to spin like "Wheel of Fortune".
private void DrawPieChart() { Graphics g = this.CreateGraphics(); g.Clear(this.BackColor); Rectangle rect = new Rectangle(0, 0, 300, 300); float angle = 0; Random random = new Random(); int sectors = 24; int sweep = 360 / sectors;
}for(int i=0; i<24;i++) { Color clr = Color.FromArgb(random.Next(0, 255),random.Next(0, 255), random.Next(0, 255)); g.FillPie(new SolidBrush(clr), rect, angle, sweep); angle += sweep; } g.Dispose();
© Stack Overflow or respective owner