Private Sub MakePieChart(ByVal g As Graphics, ByVal values() As Double, ByVal colors As Color())
' draw the chart as line segments
Dim x As Int32 = 0
Dim y As Int32 = 0
Dim intSweep As Int32
Dim intAngle As Int32 = 0
Dim pieRectangle As Rectangle
pieRectangle = New Rectangle(x, y, 147, 147)
' draw the arcs
For index As Int32 = 0 To values.Length() - 1
' sweep of segment will be its ratio to the total and remembering the whole circle
' has 360 degrees.
intSweep = CType((values(index) / sumOfPoints * 360), Int32)
g.FillPie(New SolidBrush(colors(index)), pieRectangle, intAngle, intSweep)
intAngle += intSweep
Next
End Sub