using ZedGraph;
private void Form1_Load(object sender, EventArgs e)
{
CreatePie(mypie);
}
public void CreatePie(ZedGraphControl zgc)
{
GraphPane myPane = zgc.GraphPane;
myPane.Title.Text = "2020区域销售情况\n($M)";
myPane.Title.FontSpec.IsItalic = true;
myPane.Title.FontSpec.Size = 24f;
myPane.Title.FontSpec.Family = "Times New Roman";
myPane.Fill = new Fill(Color.White, Color.Goldenrod, 45.0f);
myPane.Chart.Fill.Type = FillType.None;
myPane.Legend.Position = LegendPos.Float;
myPane.Legend.Location = new Location(0.95f, 0.15f, CoordType.PaneFraction, AlignH.Right, AlignV.Top);
myPane.Legend.FontSpec.Size = 10f;
myPane.Legend.IsHStack = false;
PieItem segment1 = myPane.AddPieSlice(20, Color.Navy, Color.White, 45f, 0, "North");
PieItem segment3 = myPane.AddPieSlice(30, Color.Purple, Color.White, 45f, .0, "East");
PieItem segment4 = myPane.AddPieSlice(10.21, Color.LimeGreen, Color.White, 45f, 0, "West");
PieItem segment2 = myPane.AddPieSlice(40, Color.SandyBrown, Color.White, 45f, 0.2, "South");
PieItem segment6 = myPane.AddPieSlice(250, Color.Red, Color.White, 45f, 0, "Europe");
PieItem segment7 = myPane.AddPieSlice(1500, Color.Blue, Color.White, 45f, 0.2, "Pac Rim");
PieItem segment8 = myPane.AddPieSlice(400, Color.Green, Color.White, 45f, 0, "South America");
PieItem segment9 = myPane.AddPieSlice(50, Color.Yellow, Color.White, 45f, 0.2, "Africa");
segment2.LabelDetail.FontSpec.FontColor = Color.Red;
CurveList curves = myPane.CurveList;
double total = 0;
for (int x = 0; x < curves.Count; x++)
total += ((PieItem)curves[x]).Value;
TextObj text = new TextObj("Total 2004 Sales\n" + "$" + total.ToString() + "M", 0.18F, 0.40F, CoordType.PaneFraction);
text.Location.AlignH = AlignH.Center;
text.Location.AlignV = AlignV.Bottom;
text.FontSpec.Border.IsVisible = false;
text.FontSpec.Fill = new Fill(Color.White, Color.FromArgb(255, 100, 100), 45F);
text.FontSpec.StringAlignment = StringAlignment.Center;
myPane.GraphObjList.Add(text);
TextObj text2 = new TextObj(text);
text2.FontSpec.Fill = new Fill(Color.Black);
text2.Location.X += 0.008f;
text2.Location.Y += 0.01f;
myPane.GraphObjList.Add(text2);
zgc.AxisChange();
}