C# 显示值百分比的devexpress饼图
我正在使用一个devexpress饼图。共有2个切片,值分别为8和12(总共20个切片)。 当我使用下面的代码时,切片上显示的值是C# 显示值百分比的devexpress饼图,c#,asp.net,devexpress,C#,Asp.net,Devexpress,我正在使用一个devexpress饼图。共有2个切片,值分别为8和12(总共20个切片)。 当我使用下面的代码时,切片上显示的值是0/4和0/6,而我需要值是40%和60% ((PiePointOptions)series.LegendPointOptions).PointView = PointView.Values; ((PiePointOptions)series.LegendPointOptions).PercentOptions.ValueAsPercent = false; 设置V
0/4
和0/6
,而我需要值是40%
和60%
((PiePointOptions)series.LegendPointOptions).PointView = PointView.Values;
((PiePointOptions)series.LegendPointOptions).PercentOptions.ValueAsPercent = false;
设置ValueAsPercent=true
只会通过将值更改为0
和1
,使事情变得更糟!!!并在切片上显示相同的比例(0/4
和0/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);
非常感谢:),我不知道我需要设置series.Label的属性才能更改切片上显示的文本。