zedGraph画饼图

来源:互联网 发布:凹凸视频大软件 编辑:程序博客网 时间:2024/04/30 04:08
public void CreateChart(ZedGraphControl zgc)        {            GraphPane myPane = zgc.GraphPane;            // 设置图表的标题和标题的样式            myPane.Title.Text = "2004 ZedGraph Sales by Region\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);            // 设置图表的颜色填充,如果设置为FillType.None,则填充色和背景色相同            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;            /*            * 设置饼图的各个部分            * AddPieSlice方法的参数是 value值, 颜色,渐变色,渐变大小,离开中心点的距离,名称            */            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(50, 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");            zgc.AxisChange();        }

0 0
原创粉丝点击