RTSwimmer
New member
Is it possible to find the center of the outside edge on a pie slice?
At the moment i have a static label showing the values in the key but i would like to get the values next to the corisponding slice.
Like this: http://www.chestysoft.com/images/pieexample.gif
Here is my code which creates a pie chart with 3 sections
pie1, pie2 & pie3's values get sent from a main form.
Can anyone help?
Cheers RTSwimmer
At the moment i have a static label showing the values in the key but i would like to get the values next to the corisponding slice.
Like this: http://www.chestysoft.com/images/pieexample.gif
Here is my code which creates a pie chart with 3 sections
pie1, pie2 & pie3's values get sent from a main form.
VB.NET:
formGraphics = Me.CreateGraphics()
Dim curPos As Integer = -90 '12 O'clock
Dim curRect As New System.Drawing.Rectangle(20, 20, 200, 200) 'position of circle
Dim piePen As New System.Drawing.Pen(System.Drawing.Color.Black)
Dim pieBrush As New System.Drawing.SolidBrush(System.Drawing.Color.Blue)
Dim thisForm As System.Windows.Forms.Form = frmPieChart.ActiveForm
Dim pieFill As New System.Drawing.SolidBrush(Color.Magenta) 'first pie
Dim figValue As New System.Drawing.Point
Dim total As Double = pie1 + pie2 + pie3 'Total of all values
Dim pie1size As Double = pie1 / total * 360
Dim pie2Size As Double = pie2 / total * 360
Dim pie3Size As Double = pie3 / total * 360
Dim pie1Perc As Double = pie1 / total * 100
Dim pie2Perc As Double = pie2 / total * 100
Dim pie3Perc As Double = pie3 / total * 100
'slice 1
lblFig1Val.Text = FormatNumber(pie1Perc, 0) & "%"
formGraphics.FillPie(pieFill, curRect, curPos, pie1size)
formGraphics.DrawPie(piePen, curRect, curPos, pie1size)
'slice 2
lblFig2Val.Text = FormatNumber(pie2Perc, 0) & "%"
pieFill.Color = Color.Lime 'reset colour
formGraphics.FillPie(pieFill, curRect, curPos + pie1size, pie2Size)
formGraphics.DrawPie(piePen, curRect, curPos + pie1size, pie2Size)
'slice 3
lblFig3Val.Text = FormatNumber(pie3Perc, 0) & "%" 'outputs the value of stack 1
pieFill.Color = Color.Blue 'reset colour
formGraphics.FillPie(pieFill, curRect, curPos + pie1size + pie2Size, pie3Size)
formGraphics.DrawPie(piePen, curRect, curPos + pie1size + pie2Size, pie3Size)
'tidy up
piePen.Dispose()
pieFill.Dispose()
Cheers RTSwimmer