Hi Admin,
We are going to purchase a license of Aspose.Slides for Java. But before we will do that, I nee you to help me on something.
I have a code that will modify the data of a pie chart. But I cant set colors to pie chart sector. Please give me the full code in java to do this. I have 7 sectors in a pie chart each is in different color.
Please reply asap because this is urgent.
Thanks,
Jonah
Hi Jonah,
Hi,
No, I already browse the documentation but I count find a full code of what I need. Please give me a full code as it will really solve my problem.
Thanks!
Hi Jonah,
Thanks so much… I will use that and see how it works.
Hi,
I got it working now.
Another issue is that how can I format the piechart label to currency in $X,XXX… Please help.
Thanks,
Jonah
Hi Jonah,
I have tried to understand the requirement shared by you. Can you please share the requirement in the form of sample presentation or snapshot so that I may help you further. Please visit this documentation link whereby I have shared the sample application to format chart. I have also shared the example to set the number format as well. I am hopeful that the shared link will be helpful to you.
Many Thanks,
Hi,
The documentation doesnt solve my problem. I need to formal a pie chart label in currency. Please give me the full code to do that.
Thanks,
Jonah
Hi Jonah,
public static void addPieChart(){//Instantiate PresentationEx class that represents PPTX filePresentationEx pres = new PresentationEx();//Access first slideSlideEx sld = pres.getSlides().get_Item(0);// Add chart with default dataChartEx chart = sld.getShapes().addChart(ChartTypeEx.Pie, 100, 100, 400, 400);//Setting chart Titlechart.getChartTitle().getText().setText( “Sample Title”);chart.getChartTitle().getText().setCenterText(true);chart.getChartTitle().setHeight(20);chart.hasTitle(true);//Set first series to Show Valueschart.getChartData().getSeries().get_Item(0).getLabels().setShowValue(true);//Setting the index of chart data sheetint defaultWorksheetIndex = 0;//Getting the chart data worksheetChartDataCellFactory fact = chart.getChartData().getChartDataCellFactory();//Delete default generated series and categorieschart.getChartData().getSeries().clear();chart.getChartData().getCategories().clear();//Adding new categorieschart.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 seriesint Id=chart.getChartData().getSeries().add(fact.getCell(0, 0, 1, “Series 1”), chart.getType());//Accessing added seriesChartSeriesEx series = chart.getChartData().getSeries().get_Item(Id);//Now populating series dataseries.getValues().add(fact.getCell(defaultWorksheetIndex, 1, 1, 20));series.getValues().add(fact.getCell(defaultWorksheetIndex, 2, 1, 50));series.getValues().add(fact.getCell(defaultWorksheetIndex, 3, 1, 30));//Adding new points and setting sector colorseries.isColorVaried(true);ChartPointEx point = new ChartPointEx(series);point.setIndex(0);point.getFormat().getFill().setFillType(FillTypeEx.Solid);point.getFormat().getFill().getSolidFillColor().setPresetColor(com.aspose.slides.PresetColorEx.Cyan);//Setting Sector borderpoint.getFormat().getLine().getFillFormat().setFillType(FillTypeEx.Solid);point.getFormat().getLine().getFillFormat().getSolidFillColor().setPresetColor(com.aspose.slides.PresetColorEx.Gray);point.getFormat().getLine().setWidth(3.0);point.getFormat().getLine().setStyle(LineStyleEx.ThinThick);point.getFormat().getLine().setDashStyle(LineDashStyleEx.DashDot);ChartPointEx point1 = new ChartPointEx(series);point1.setIndex(1);point1.getFormat().getFill().setFillType(FillTypeEx.Solid);point1.getFormat().getFill().getSolidFillColor().setPresetColor(com.aspose.slides.PresetColorEx.Brown);//Setting Sector borderpoint1.getFormat().getLine().getFillFormat().getSolidFillColor().setPresetColor(com.aspose.slides.PresetColorEx.Blue);point1.getFormat().getLine().setWidth( 3.0);point1.getFormat().getLine().setStyle (LineStyleEx.Single);point1.getFormat().getLine().setDashStyle(LineDashStyleEx.LargeDashDot);ChartPointEx point2 = new ChartPointEx(series);point2.setIndex(2);point2.getFormat().getFill().setFillType(FillTypeEx.Solid);point2.getFormat().getFill().getSolidFillColor().setPresetColor(com.aspose.slides.PresetColorEx.Coral);//Setting Sector borderpoint2.getFormat().getLine().getFillFormat().setFillType(FillTypeEx.Solid);point2.getFormat().getLine().getFillFormat().getSolidFillColor().setPresetColor(com.aspose.slides.PresetColorEx.Red);point2.getFormat().getLine().setWidth(2.0);point2.getFormat().getLine().setStyle(LineStyleEx.ThinThin);point2.getFormat().getLine().setDashStyle(LineDashStyleEx.LargeDashDotDot);//Adding Series Pointsseries.getPoints().add(point);series.getPoints().add(point1);series.getPoints().add(point2);series.getLabels().setLinkedSource(false);series.getLabels().setShowCategoryName(false);series.getLabels().setShowSeriesName(false);series.getLabels().setShowPercentage(false);series.getLabels().setShowValue(true);series.getLabels().setNumberFormat("$#,##0.00");series.getLabels().setLinkedSource(false);//Showing Leader Lines for Chartseries.getLabels().setShowLeaderLines(true);//Setting Rotation Angle for Pie Chart Sectorschart.getChartData().getSeries().get_Item(0).setFirstSliceAngle(180);// Save presentation with chartpres.write(“D:\Aspose Data\AsposeChart.pptx”);}
Hi,
Please help me on how to change the color of piechart label to white.
Thanks!
Hi Jonah,
series.getLabels().getFormat().getFill().setFillType(FillTypeEx.Solid);series.getLabels().getFormat().getFill().getSolidFillColor().setColor(Color.WHITE);
Hi,
This doesnt solve the problem. It change the background color of the text not the font color. All I need is a code to change the font color.
Thanks!
Hi Jonah,
series.getLabels().getTextProperties().getParagraphs().get_Item(0).getParagraphFormat().getDefaultPortionFormat().getFillFormat().setFillType(FillTypeEx.Solid);series.getLabels().getTextProperties().getParagraphs().get_Item(0).getParagraphFormat().getDefaultPortionFormat().getFillFormat().getSolidFillColor().setColor(Color.WHITE);