效果图一、
public partial class Form3 : Form
{
public Form3()
{
InitializeComponent();
} private void Form3_Load(object sender, EventArgs e)
{
// Create an empty chart.
ChartControl PieChart3D = new ChartControl(); // Create a pie series.
Series series1 = new Series("Pie Series 1", ViewType.Pie3D); //// Populate the series with points.
//series1.Points.Add(new SeriesPoint("Russia", 17.0752));
//series1.Points.Add(new SeriesPoint("Canada", 9.98467));
//series1.Points.Add(new SeriesPoint("USA", 9.63142));
//series1.Points.Add(new SeriesPoint("China", 9.59696));
//series1.Points.Add(new SeriesPoint("Brazil", 8.511965));
//series1.Points.Add(new SeriesPoint("Australia", 7.68685));
//series1.Points.Add(new SeriesPoint("India", 3.28759));
//series1.Points.Add(new SeriesPoint("Others", 81.2)); DataTable dt = new DataTable();
dt.Columns.Add("X轴", Type.GetType("System.String"));
dt.Columns.Add("线①", Type.GetType("System.Int32"));
dt.Columns.Add("线②", Type.GetType("System.Int32"));
dt.Columns.Add("线③", Type.GetType("System.Int32"));
dt.Columns.Add("线④", Type.GetType("System.Int32")); for (int i = ; i < ; i++)
{
Random rd = new Random();
DataRow dr = dt.NewRow();
dr["X轴"] = ("类别" + i.ToString());
dr["线①"] = rd.Next(i * , (i + ) * ); ;
dr["线②"] = rd.Next(i * , (i + ) * );
dr["线③"] = rd.Next(i * , (i + ) * );
dr["线④"] = rd.Next(i * , (i + ) * );
dt.Rows.Add(dr);
}
series1.DataSource = dt;
series1.ArgumentDataMember = "X轴"; //设置公共的X轴值(刻度)
series1.ValueScaleType = ScaleType.Numerical;
//设置 单个Series2 Y轴的(值)
series1.ValueDataMembers.AddRange(new string[] { "线①" }); // Add the series to the chart.
PieChart3D.Series.Add(series1);
//series1.LegendPointOptions.PointView = PointView.ArgumentAndValues;//格式:【类别:百分比】
series1.LegendPointOptions.PointView = PointView.Argument;//格式:【类别】
//series1.LegendPointOptions.PointView = PointView.Values;//格式:【百分比】
//series1.LegendPointOptions.PointView = PointView.SeriesName;//显示series1的Name
//series1.LegendPointOptions.PointView = PointView.Undefined;//显示效果:【百分比】
// Adjust the value numeric options of the series.
//series1.Label.TextPattern = "{VP:P0}"; PieChart3D.Legend.Visible = true; //设置 右边 标注框是否显示
PieChart3D.Legend.TextVisible = true; //设置标注框是否显示 每项目的数值 // Adjust the view-type-specific options of the series.
((Pie3DSeriesView)series1.View).Depth = ;//设置饼的厚度
((Pie3DSeriesView)series1.View).ExplodedPoints.Add(series1.Points[]); //选中一个需要突出的项目
((Pie3DSeriesView)series1.View).ExplodedDistancePercentage = ;//将其中一个项目(SeriesPoint)推出来的距离 // Access the diagram's options.
((SimpleDiagram3D)PieChart3D.Diagram).RotationType = RotationType.UseAngles;
((SimpleDiagram3D)PieChart3D.Diagram).RotationAngleX = -;//设置平面的倾斜度 // Add a title to the chart and hide the legend.
ChartTitle chartTitle1 = new ChartTitle();
chartTitle1.Text = "3D Pie Chart";//设置标题
PieChart3D.Titles.Add(chartTitle1);//添加标题
//PieChart3D.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False; // Add the chart to the form.
PieChart3D.Dock = DockStyle.Fill;
this.Controls.Add(PieChart3D); }
}
效果图二、
public partial class Form3 : Form
{
public Form3()
{
InitializeComponent();
} private void Form3_Load(object sender, EventArgs e)
{
// Create an empty chart.
ChartControl PieChart3D = new ChartControl(); // Create a pie series.
Series series1 = new Series("Pie Series 1", ViewType.Pie3D); // Populate the series with points.
series1.Points.Add(new SeriesPoint("Russia", 17.0752));
series1.Points.Add(new SeriesPoint("Canada", 9.98467));
series1.Points.Add(new SeriesPoint("USA", 9.63142));
series1.Points.Add(new SeriesPoint("China", 9.59696));
series1.Points.Add(new SeriesPoint("Brazil", 8.511965));
series1.Points.Add(new SeriesPoint("Australia", 7.68685));
series1.Points.Add(new SeriesPoint("India", 3.28759));
series1.Points.Add(new SeriesPoint("Others", 81.2)); //DataTable dt = new DataTable();
//dt.Columns.Add("X轴", Type.GetType("System.String"));
//dt.Columns.Add("线①", Type.GetType("System.Int32"));
//dt.Columns.Add("线②", Type.GetType("System.Int32"));
//dt.Columns.Add("线③", Type.GetType("System.Int32"));
//dt.Columns.Add("线④", Type.GetType("System.Int32")); //for (int i = 0; i < 10; i++)
//{
// Random rd = new Random();
// DataRow dr = dt.NewRow();
// dr["X轴"] = ("类别" + i.ToString());
// dr["线①"] = rd.Next(i * 10, (i + 1) * 10); ;
// dr["线②"] = rd.Next(i * 10, (i + 1) * 10);
// dr["线③"] = rd.Next(i * 10, (i + 1) * 10);
// dr["线④"] = rd.Next(i * 10, (i + 1) * 10);
// dt.Rows.Add(dr);
//}
//series1.DataSource = dt;
//series1.ArgumentDataMember = "X轴"; //设置公共的X轴值(刻度)
//series1.ValueScaleType = ScaleType.Numerical;
////设置 单个Series2 Y轴的(值)
//series1.ValueDataMembers.AddRange(new string[] { "线①" }); // Add the series to the chart.
PieChart3D.Series.Add(series1);
series1.LegendPointOptions.PointView = PointView.ArgumentAndValues;//格式:【类别:百分比】
//series1.LegendPointOptions.PointView = PointView.Argument;//格式:【类别】
//series1.LegendPointOptions.PointView = PointView.Values;//格式:【百分比】
//series1.LegendPointOptions.PointView = PointView.SeriesName;//显示series1的Name
//series1.LegendPointOptions.PointView = PointView.Undefined;//显示效果:【百分比】
// Adjust the value numeric options of the series.
//series1.Label.TextPattern = "{VP:P0}"; PieChart3D.Legend.Visible = true; //设置 右边 标注框是否显示
PieChart3D.Legend.TextVisible = true; //设置标注框是否显示 每项目的数值 // Adjust the view-type-specific options of the series.
((Pie3DSeriesView)series1.View).Depth = ;//设置饼的厚度
((Pie3DSeriesView)series1.View).ExplodedPoints.Add(series1.Points[]); //选中一个需要突出的项目
((Pie3DSeriesView)series1.View).ExplodedDistancePercentage = ;//将其中一个项目(SeriesPoint)推出来的距离 // Access the diagram's options.
((SimpleDiagram3D)PieChart3D.Diagram).RotationType = RotationType.UseAngles;
((SimpleDiagram3D)PieChart3D.Diagram).RotationAngleX = -;//设置平面的倾斜度 // Add a title to the chart and hide the legend.
ChartTitle chartTitle1 = new ChartTitle();
chartTitle1.Text = "3D Pie 测试效果图2";//设置标题
PieChart3D.Titles.Add(chartTitle1);//添加标题
//PieChart3D.Legend.Visibility = DevExpress.Utils.DefaultBoolean.False; // Add the chart to the form.
PieChart3D.Dock = DockStyle.Fill;
this.Controls.Add(PieChart3D); }
}