c# - devexpress 饼图显示值的百分比

标签 c# asp.net devexpress

我正在使用 devexpress 饼图。有 2 个切片,值为 8 和 12(总共 20 个)。 当我使用下面的代码时,切片上显示的值是 0/40/6,而我需要的值是 40%60%

((PiePointOptions)series.LegendPointOptions).PointView = PointView.Values;
((PiePointOptions)series.LegendPointOptions).PercentOptions.ValueAsPercent = false;

设置 ValueAsPercent = true 将值更改为 01 只会让事情变得更糟!!!并在切片上显示相同的比例(0/40/6)。

如何显示每个切片的百分比?

最佳答案

下面是一个简单的例子,看看是否有帮助

// Create an empty chart.
        ChartControl pieChart = new ChartControl();

        // Create a pie series and add it to the chart.
        Series series1 = new Series("Pie Series", ViewType.Pie);
        pieChart.Series.Add(series1);

        // Add points to it.
        series1.Points.Add(new SeriesPoint("A", new double[] { 0.3 }));
        series1.Points.Add(new SeriesPoint("B", new double[] { 5 }));
        series1.Points.Add(new SeriesPoint("C", new double[] { 9 }));
        series1.Points.Add(new SeriesPoint("D", new double[] { 12 }));

        // Make the series point labels display both arguments and values.
        ((PiePointOptions)series1.Label.PointOptions).PointView = PointView.ArgumentAndValues;

        // Make the series points' values to be displayed as percents.
        ((PiePointOptions)series1.Label.PointOptions).PercentOptions.ValueAsPercent = true;
        ((PiePointOptions)series1.Label.PointOptions).ValueNumericOptions.Format = NumericFormat.Percent;
        ((PiePointOptions)series1.Label.PointOptions).ValueNumericOptions.Precision = 0;

        // Add the chart to the form.
        pieChart.Dock = DockStyle.Fill;
        this.Controls.Add(pieChart);

关于c# - devexpress 饼图显示值的百分比,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18031309/

相关文章:

c# - 如何在文本框中设置固定行距?

asp.net - 如果未传递参数,如何避免vb.net中的请求查询字符串异常

asp.net - ASP.NET MVC 3 中每用户缓存的 "Safe handle has been closed"

jquery - Javascript 错误被标签推到右边

c# - DevExpress GridControl BestFit |自动调整模式?

c# - DevExpress RepositoryItemComboBox 无法显示组合框列表数据

c# - 如何在不修改网页浏览器控件中的文档的情况下注入(inject)并执行javascript函数?

C# 将 System.ConsoleColor 转换为 System.Drawing.Color

asp.net-mvc - DevExpress MVC GridView - 如何获取单元格单击事件

c# - 在 .NET 中使用正则表达式从字符串中提取标记