I'm using a devexpress pie chart. There are 2 slices, with values 8 and 12 (out of a total of 20). when I use the code below, the values shown on slices are 0/4
and 0/6
, while I need the values to be 40%
and 60%
.
((PiePointOptions)series.LegendPointOptions).PointView = PointView.Values;
((PiePointOptions)series.LegendPointOptions).PercentOptions.ValueAsPercent = false;
Setting ValueAsPercent = true
only makes things worse by changing the values to 0
and 1
!!! And showing the same proportions ( 0/4
and 0/6
) on the slices.
How do I show percentage of each slice??
Here is a simple example see if it helps
// 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);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.