.NET pie chart: how to add text to slices and rotate chart
- by Sajee
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();
}