We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Java aspose-slides-16 按扇区着色的设置方法在哪里

请问这个属性在哪里设置?谢谢
按扇区着色.gif (37.2 KB)

@cpych,

我已经观察了您的要求,并建议您尝试使用以下示例代码来实现目的。

public static void TestPie()
 {
     // Instantiate Presentation class that represents PPTX file
     Presentation presentation = new Presentation();

     // Access first slide
     ISlide slides = presentation.getSlides().get_Item(0);

     // Add chart with default data
     IChart chart = slides.getShapes().addChart(ChartType.Pie, 100, 100, 400, 400);

     // Setting chart Title
     chart.getChartTitle().addTextFrameForOverriding("Sample Title");
     chart.getChartTitle().getTextFrameForOverriding().getTextFrameFormat().setCenterText (NullableBool.True);
     chart.getChartTitle().setHeight(20);
     chart.hasTitle();

     // Set first series to Show Values
     chart.getChartData().getSeries().get_Item(0).getLabels().getDefaultDataLabelFormat().setShowValue(true);

     // Setting the index of chart data sheet
     int defaultWorksheetIndex = 0;

     // Getting the chart data worksheet
     IChartDataWorkbook fact = chart.getChartData().getChartDataWorkbook();

     // Delete default generated series and categories
     chart.getChartData().getSeries().clear();
     chart.getChartData().getCategories().clear();

     // Adding new categories
     chart.getChartData().getCategories().add(fact.getCell(0, 1, 0, "First Qtr"));
     chart.getChartData().getCategories().add(fact.getCell(0, 2, 0, "2nd Qtr"));
     chart.getChartData().getCategories().add(fact.getCell(0, 3, 0, "3rd Qtr"));

     // Adding new series
     IChartSeries series = chart.getChartData().getSeries().add(fact.getCell(0, 0, 1, "Series 1"), chart.getType());

     // Now populating series data
     series.getDataPoints().addDataPointForPieSeries(fact.getCell(defaultWorksheetIndex, 1, 1, 20));
     series.getDataPoints().addDataPointForPieSeries(fact.getCell(defaultWorksheetIndex, 2, 1, 50));
     series.getDataPoints().addDataPointForPieSeries(fact.getCell(defaultWorksheetIndex, 3, 1, 30));

     series.getParentSeriesGroup().setColorVaried(true);

     presentation.save("C:\\Aspose Data\\Pie.pptx", SaveFormat.Pptx);
 }

Thanks alot!