[DevExpress]ChartControl之饼状图百分比演示

关键代码:

using System;
using System.Data;
using System.Windows.Forms;
using DevExpress.XtraCharts;

namespace DevExpressChart
{
    public partial class winPieSeriesView : Form
    {
        public winPieSeriesView()
        {
            InitializeComponent();
        }
        private DataTable CreateChartData()
        {
            DataTable table = new DataTable("Table1");
            table.Columns.Add("Name", typeof(String));
            table.Columns.Add("Value", typeof(Int32));
            table.Rows.Add(new object[] { "A", 10 });
            table.Rows.Add(new object[] { "B", 20 });
            table.Rows.Add(new object[] { "C", 40 });
            table.Rows.Add(new object[] { "D", 20 });
            table.Rows.Add(new object[] { "E", 30 });
            return table;
        }
        private void winPieSeriesView_Load(object sender, EventArgs e)
        {
            BuilderDevChart();
        }
        private void BuilderDevChart()
        {
            Series _pieSeries = new Series("测试", ViewType.Pie);
            _pieSeries.ValueDataMembers[0] = "Value";
            _pieSeries.ArgumentDataMember = "Name";
            _pieSeries.DataSource = CreateChartData();
            chartControl1.Series.Add(_pieSeries);
            //----------------------------------------
            _pieSeries.LegendPointOptions.PointView = PointView.ArgumentAndValues;
            _pieSeries.SetPiePercentage();
        }
    }
}

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }---------------------------------------------------------------------------------------------

        /// <summary>
        /// 饼状Series设置成百分比显示
        /// </summary>
        /// <param name="series">Series</param>
        public static void SetPiePercentage(this Series series)
        {
            if (series.View is PieSeriesView)
            {
                ((PiePointOptions)series.PointOptions).PercentOptions.ValueAsPercent = true;
                ((PiePointOptions)series.PointOptions).ValueNumericOptions.Format = NumericFormat.Percent;
                ((PiePointOptions)series.PointOptions).ValueNumericOptions.Precision = 0;
            }
        }

运行效果:

希望有所帮助!谢谢!

.csharpcode, .csharpcode pre
{
font-size: small;
color: black;
font-family: consolas, "Courier New", courier, monospace;
background-color: #ffffff;
/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt
{
background-color: #f4f4f4;
width: 100%;
margin: 0em;
}
.csharpcode .lnum { color: #606060; }

时间: 2024-08-29 11:00:28

[DevExpress]ChartControl之饼状图百分比演示的相关文章

android圆饼状图中怎么设置百分比

============问题描述============ 我希望设置成能显示百分数的,如下图 这是我画饼状图的方法,我想给我一点思路 public void drawArc(RectF oval, float startAngle, float sweepAngle, boolean useCenter, Paint paint) ============解决方案1============ http://www.2cto.com/kf/201402/278932.html ===========

[DevExpress]饼状图突出(Explode)设置

关键代码: /// <summary> /// 饼状图突出设置 /// </summary> /// <param name="chart">ChartControl</param> /// <param name="pieSeries">Series[仅仅适用于PieSeriesView]</param> /// <param name="explodeMode"&g

[DevExpress]设置饼状图的Lable位置

关键代码: /// <summary> /// 设置饼状图的Lable位置 /// </summary> /// <param name="series">Series</param> /// <param name="lablePosition">PieSeriesLabelPosition枚举</param> public static void SetLablePosition(this

js饼状图(带百分比)功能实现,新人必懂

1 <!DOCTYPE html> 2 <html> 3 <head> 4 <meta charset="utf-8" /> 5 <title></title> 6 <script src="../../js/my/highcharts.js"></script> 7 <script src="../../css2/jquery-1.10.2.min.js

iOS:使用贝塞尔曲线绘制图表(折线图、柱状图、饼状图)

1.介绍: UIBezierPath :画贝塞尔曲线的path类 UIBezierPath定义 : 贝赛尔曲线的每一个顶点都有两个控制点,用于控制在该顶点两侧的曲线的弧度. 曲线的定义有四个点:起始点.终止点(也称锚点)以及两个相互分离的中间点. 滑动两个中间点,贝塞尔曲线的形状会发生变化. UIBezierPath :对象是CGPathRef数据类型的封装,可以方便的让我们画出 矩形 . 椭圆 或者 直线和曲线的组合形状 初始化方法: + (instancetype)bezierPath; /

用CAShapeLayer实现一个简单的饼状图(PieView)

自己写了一个简单的PieView,demo在这里:https://github.com/Phelthas/LXMPieView 效果如图: 参考了https://github.com/kevinzhow/PNChart  和 https://github.com/xyfeng/XYPieChart 的代码 实现方法: 绘制饼状图所需的值只有各个扇形对应的值及对应的颜色,但可能会有很多附加的元素需要显示(比如字体颜色,字体大小等), 所以将每个扇形所需的数据封装为一个model对象,方便以后扩展.

JFreeChart框架中生成饼状图上怎样显示数据 [问题点数:40分,结帖人GreenLawn]

我用JFreeChart框架生成饼状图,但想把数据信息在饼图上显示,是在饼图内部(即圆内)显示!怎样实现啊?? 去掉lablepieplot.setLabelGenerator(null);去掉线pieplot.setLabelLinksVisible(false); 饼图标签显示百分比方法PiePlot pp = (PiePlot)chart.getPlot();pp.setLabelGenerator(new StandardPieSectionLabelGenerator("{2}&quo

Android开源图表之树状图和饼状图的官方示例的整理

最近由于工作需要,所以就在github上搜了下关于chart的三方框架 官方地址https://github.com/PhilJay/MPAndroidChart 由于工作需要我这里整理了一份Eclipse版本的类库.(有需要要的留下邮箱) 这就是Code中的效果(树状图) 1 public class BarChartActivity extends Activity implements OnChartValueSelectedListener{ 2 3 private BarChart m

iOS 饼状图

首先先看一下效果: 一.创建饼状图对象   创建饼状图对象用到类是PieChartView.h, 代码如下: self.pieChartView = [[PieChartView alloc] init]; self.pieChartView.backgroundColor = BgColor; [self.view addSubview:self.pieChartView]; [self.pieChartView mas_makeConstraints:^(MASConstraintMaker