I'm new to C# but I've been practicing with making charts and graphs. I made a pie chart for a prior program and I pretty much just copied and pasted the format into my new program, however it doesn't work. Here's the function that sets up the Pie Chart. I probably did something stupid and haven't realized it. lol
public void setup_pieChart()
{
float total_count = 0;
for (int k = 0; k < referrals.Count(); k++)
{
total_count += referrals[k].count;
}
if (total_count > 0)
{
Array.Sort(referrals);
// ----------------------- CREATE PIE CHART ---------------------//
Graphics g = this.CreateGraphics();
Pen pen = new Pen(Color.Black, 2);
Rectangle rec = new Rectangle(referralBox.Location.X + referralBox.Size.Width + 10, 25, 200, 200);
g.Clear(Color.White);
float degreeSum = 0;
for (int k = 0; k < referrals.Count(); k++)
{
referrals[k].degrees = (referrals[k].count / total_count) * 360;
g.DrawPie(pen, rec, degreeSum, referrals[k].degrees);
g.FillPie(new SolidBrush(referrals[k].color), rec, degreeSum, referrals[k].degrees);
degreeSum += referrals[k].degrees;
Console.WriteLine("count " + referrals[k].count);
Console.WriteLine("degree " + referrals[k].degrees);
Console.WriteLine("color " + referrals[k].color.ToString());
}
}
}