您的位置:首页 > 编程语言 > C#

Winfrom Chart饼状图的使用

2015-02-11 17:28 375 查看
应用

using System.Windows.Forms.DataVisualization.Charting;

            

Title title1 = new Title();

            title1.Text = "总合格率(%)";

            title1.ForeColor = Color.Blue;

            this.chart1.Titles.Add(title1);

            this.chart1.Series.Clear();

            Series series1 = new Series();

            series1.ChartType = SeriesChartType.Pie;

            this.chart1.Series.Add(series1);

            int[] percents = new int[3] { 20, 30, 50 };

            string[] pointsText = new string[3] { "紧急", "严重", "普通" };

            Color[] myColor = new Color[3] { Color.FromArgb(0, 183, 238),

                                              Color.FromArgb(250, 205, 137),

                                                Color.FromArgb(255, 124, 255)};

            DataPoint[] AllPoints = new DataPoint[3];

            for (int i = 0; i < AllPoints.Length; i++)

            {

                AllPoints[i] = new DataPoint(i + 1, percents[i]);

                AllPoints[i].LegendText = "紧急";

                AllPoints[i].Color = myColor[i];

                AllPoints[i].ToolTip = percents[i].ToString() + "%";

                AllPoints[i].Label = percents[i].ToString() + "%";

                AllPoints[i].LabelForeColor = Color.Black;

                this.chart1.Series[0].Points.Add(AllPoints[i]);

            }            

            this.chart1.ChartAreas[0].Area3DStyle.Enable3D = true;

            this.chart1.Series[0]["PieLabelStyle"] = "Outside"; 

            this.chart1.EndInit();
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  C# Winfrom Chart