【问题标题】:devexpress pie chart showing percentage of values显示值百分比的 devexpress 饼图
【发布时间】:2013-08-03 09:21:51
【问题描述】:

我正在使用 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)。

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

【问题讨论】:

    标签: c# asp.net devexpress


    【解决方案1】:

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

    // 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);
    

    【讨论】:

    • 非常感谢 :),我不知道我需要设置 series.Label 的属性才能更改切片上显示的文本。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-07-24
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多