2013-08-03 379 views
4

我正在使用devexpress餅圖。有2片,值8和12(總共20)。 當我使用下面的代碼時,切片上顯示的值爲0/40/6,而我需要的值爲40%60%devexpress餅圖顯示值的百分比

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

設置ValueAsPercent = true不僅使得通過改變值01更糟糕的事情!並在切片上顯示相同的比例(0/40/6)。

如何顯示每個片的百分比?

回答

4

下面是一個簡單的例子,看看是否有幫助

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

感謝很多:),我不知道我需要設置,以改變切片顯示文本series.Label'的'屬性。 – Yalda

相關問題