今天来简单介绍下这个chartControl1控件的用法。
private void initChart() { try { //清空图例 chartControl1.Series.Clear(); //清空标题 chartControl1.Titles.Clear(); //添加标题 chartControl1.Titles.Add(new ChartTitle() { Text = "What Fuck" + "历史事件统计图" }); //chartControl的标题 double zc = 26.33d; //这里zc,fzc 可以从数据库取数据。 double fzc = 73.67d;
Series series1 = new Series("历史事件正常率(单位:%)", DevExpress.XtraCharts.ViewType.Pie); //设置图形
//显示历史事件正常比例 series1.Points.Add(new SeriesPoint("正常", zc)); series1.Points.Add(new SeriesPoint("不正常", fzc)); chartControl1.Series.Add(series1); //设置显示正常和不正常 series1.PointOptions.PointView = PointView.ArgumentAndValues; series1.PointOptions.ValueNumericOptions.Format = NumericFormat.Percent; series1.PointOptions.ValueNumericOptions.Precision = 0; ((PieSeriesLabel)series1.Label).ResolveOverlappingMode = ResolveOverlappingMode.Default; } catch (Exception ex) { MessageBox.Show("异常信息:" + ex); } finally { } }
<img data-cke-saved-src="https://img-blog.csdn.net/20170815143109110?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcXFfMjMxMjY1ODE=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" src="https://img-blog.csdn.net/20170815143109110?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvcXFfMjMxMjY1ODE=/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />