Thank you Klaus. The code below is the relevant sub which will slot straight into Erel's Charts package. I have set some typical values for the pie and used the "If initialised" to change a value to show the problem on the legend.
Many thanks for your help.
Charles
Sub btnCreatePie_Click
Dim p As Panel
Dim chartnum As Int
Dim Chartname As String
If pnlPie.IsInitialized = False Then
p.Initialize("")
pnlPie.Initialize("pnlPie")
p.AddView(pnlPie, 0, 0, 100%x, 100%y - 100dip)
chartnum = TabHost1.TabCount - 6
chartname = "Chart " & chartnum
TabHost1.AddTab2(chartname, p)
piepool = 200000 'poolwaste
Else
piepool = 250000
End If
Dim PD As PieData
'piepool = poolwaste
'If chkcover.Checked Then
'piecover = 0
'Else
'piecover = coversaving
'End If
piepump = 50000 '(pumpsaving + smallpumpsaving)
piepipe = 20000 'annualpipeloss
pieboiler = 0
pieahu = 30000 '(supplysaving + extractsaving)
pietotal = (piepool + piecover + piepipe + pieboiler + pieahu + piepump)
PD.Initialize
PD.Target = pnlPie 'Set the target view
'Add the items. The last parameter is the color. Passing 0 will make it a random color
Charts.AddPieItem(pd, "Pool hall ventilation " & Round2((100*(piepool/pietotal)),1) & " %", piepool, Colors.Blue)
Charts.AddPieItem(pd, "Pool cover " & Round2((100*(piecover/pietotal)),1) & " %",piecover, Colors.DarkGray)
Charts.AddPieItem(pd, "Pumps " & Round2((100*(piepump/pietotal)),1) & " %", piepump, Colors.Green)
Charts.AddPieItem(pd, "Pipes " & Round2((100*(piepipe/pietotal)),1) & " %", piepipe, Colors.Red)
Charts.AddPieItem(pd, "AHU's " & Round2((100*(pieahu/pietotal)),1) & " %", pieahu, Colors.Magenta)
PD.GapDegrees = 20 'Total size of gaps between slices. Set to 0 for no gaps.
PD.LegendBackColor = Colors.ARGB(50, 100, 100, 100) 'The background color of the legend bitmap.
Dim legend As Bitmap
'This call draws the pie.
'PD - The pie data
'Colors.Gray - The view's background color
'True - Create a legend bitmap.
legend = Charts.DrawPie(PD, Colors.White, True)
Dim ImageView1 As ImageView
ImageView1.Initialize("")
ImageView1.SetBackgroundImage(legend)
pnlPie.AddView(ImageView1, 10dip, 10dip, legend.Width, legend.Height)
TabHost1.CurrentTab = (TabHost1.CurrentTab + Chartnum + 1)
End Sub