@Thilakbabu,
Please try using the following code example:
Presentation presentation = new Presentation();
presentation.getSlideSize().setSize(SlideSizeType.Widescreen, SlideSizeScaleType.DoNotScale);
// Create a slide to add the chart
ISlide slide = presentation.getSlides().get_Item(0);
// Add a Bubble chart to the slide
IChart chart = slide.getShapes().addChart(ChartType.Bubble, 150, 70, 650, 400);
chart.setTitle(false);
chart.getLineFormat().getFillFormat().setFillType(FillType.Solid);
chart.getLineFormat().getFillFormat().getSolidFillColor().setColor(Color.BLACK);
chart.getPlotArea().getFormat().getLine().getFillFormat().setFillType(FillType.Solid);
chart.getPlotArea().getFormat().getLine().getFillFormat().getSolidFillColor().setColor(Color.BLACK);
chart.getLegend().getTextFormat().getPortionFormat().setFontHeight(12);
chart.getLegend().getTextFormat().getPortionFormat().setLatinFont(new FontData("Aptos"));
// Get the chart's data sheet
IChartDataWorkbook workbook = chart.getChartData().getChartDataWorkbook();
// Clear the default data
chart.getChartData().getSeries().clear();
// Create the first (and only) series for the chart
// Series X-Values Y-Values Size
// Product A -8.88 0 100
// Product B -6.884 0.916 42.719
// Product C -2.184 0.117 1.702
// Product D -8.309 0.003 0.423
// Product E -15.216 -0.023 0.309
// Product F -74.517 -0.002 0
//getCell(int worksheetIndex, int row, int column, Object value)
IChartSeries seriesA = chart.getChartData().getSeries().add(workbook.getCell(0, 0, 0, "Product A"), ChartType.Bubble);
IChartDataPoint dpA = seriesA.getDataPoints().addDataPointForBubbleSeries(
workbook.getCell(0, 0, 1, -8.88),
workbook.getCell(0, 0, 2, 0),
workbook.getCell(0, 0, 3, 100));
seriesA.getFormat().getFill().setFillType(FillType.Solid);
seriesA.getFormat().getFill().getSolidFillColor().setColor(new Color(233, 113, 50));
IChartSeries seriesB = chart.getChartData().getSeries().add(workbook.getCell(0, 2, 0, "Product B"), ChartType.Bubble);
IChartDataPoint dpB = seriesB.getDataPoints().addDataPointForBubbleSeries(
workbook.getCell(0, 2, 1, -6.884),
workbook.getCell(0, 2, 2, 0.916),
workbook.getCell(0, 2, 3, 42.719));
seriesB.getFormat().getFill().setFillType(FillType.Solid);
seriesB.getFormat().getFill().getSolidFillColor().setColor(new Color(78, 167, 46));
IChartSeries seriesC = chart.getChartData().getSeries().add(workbook.getCell(0, 3, 0, "Product C"), ChartType.Bubble);
IChartDataPoint dpC = seriesC.getDataPoints().addDataPointForBubbleSeries(
workbook.getCell(0, 3, 1, -2.184),
workbook.getCell(0, 3, 2, 0.117),
workbook.getCell(0, 3, 3, 1.702));
seriesC.getFormat().getFill().setFillType(FillType.Solid);
seriesC.getFormat().getFill().getSolidFillColor().setColor(new Color(25, 107, 36));
IChartSeries seriesD = chart.getChartData().getSeries().add(workbook.getCell(0, 4, 0, "Product D"), ChartType.Bubble);
IChartDataPoint dpD = seriesD.getDataPoints().addDataPointForBubbleSeries(
workbook.getCell(0, 4, 1, -8.309),
workbook.getCell(0, 4, 2, 0.003),
workbook.getCell(0, 4, 3, 0.423));
seriesD.getFormat().getFill().setFillType(FillType.Solid);
seriesD.getFormat().getFill().getSolidFillColor().setColor(new Color(15, 158, 213));
IChartSeries seriesE = chart.getChartData().getSeries().add(workbook.getCell(0, 5, 0, "Product E"), ChartType.Bubble);
IChartDataPoint dpE = seriesE.getDataPoints().addDataPointForBubbleSeries(
workbook.getCell(0, 5, 1, -15.216),
workbook.getCell(0, 5, 2, -0.023),
workbook.getCell(0, 5, 3, 0.309));
seriesE.getFormat().getFill().setFillType(FillType.Solid);
seriesE.getFormat().getFill().getSolidFillColor().setColor(new Color(160, 43, 147));
IChartSeries seriesF = chart.getChartData().getSeries().add(workbook.getCell(0, 6, 0, "Product F"), ChartType.Bubble);
IChartDataPoint dpF = seriesF.getDataPoints().addDataPointForBubbleSeries(
workbook.getCell(0, 6, 1, -74.517),
workbook.getCell(0, 6, 2, -0.0),
workbook.getCell(0, 6, 3, 0));
seriesF.getFormat().getFill().setFillType(FillType.Solid);
seriesF.getFormat().getFill().getSolidFillColor().setColor(new Color(21, 93, 130));
for (int i = 1; i < 7; i++) {
setPercentFormat(workbook, i);
setNumberFormat(workbook, i);
}
IChartLinesFormat gridLineFormat = chart.getAxes().getVerticalAxis().getMajorGridLinesFormat();
gridLineFormat.getLine().getFillFormat().setFillType(FillType.NoFill);
IAxis verticalAxis = chart.getAxes().getVerticalAxis();
verticalAxis.getFormat().getLine().setWidth(2);
verticalAxis.setCrossType(CrossesType.Custom);
verticalAxis.setCrossAt(0.0f);
verticalAxis.setTickLabelPosition(1);
verticalAxis.setMajorTickMark(TickMarkType.None);
verticalAxis.setCategoryAxisType(0);
verticalAxis.setNumberFormat("0.0");
verticalAxis.setAutomaticMinValue(true);
verticalAxis.setAutomaticMaxValue(true);
verticalAxis.getTextFormat().getPortionFormat().setFontHeight(12);
verticalAxis.getTextFormat().getPortionFormat().setLatinFont(new FontData("Aptos"));
IAxis horizontalAxis = chart.getAxes().getHorizontalAxis();
horizontalAxis.getFormat().getLine().setWidth(2);
horizontalAxis.setCrossType(CrossesType.Custom);
horizontalAxis.setCrossAt(0.0f);
horizontalAxis.setTickLabelPosition(1);
horizontalAxis.setMajorTickMark(TickMarkType.None);
horizontalAxis.setCategoryAxisType(3);
horizontalAxis.setNumberFormat("#,##0.0\\%");
horizontalAxis.setAutomaticMinValue(true);
horizontalAxis.setAutomaticMaxValue(true);
horizontalAxis.setAutomaticMajorUnit(true);
horizontalAxis.setAutomaticMinorUnit(true);
horizontalAxis.getTextFormat().getPortionFormat().setFontHeight(12);
horizontalAxis.getTextFormat().getPortionFormat().setLatinFont(new FontData("Aptos"));
// Save the presentation to a file
try {
presentation.save("output.pptx", SaveFormat.Pptx);
System.out.println("Presentation created successfully!");
} catch (Exception e) {
System.out.println("Error saving presentation: " + e.getMessage());
}
private static void setNumberFormat(IChartDataWorkbook workbook, int i) {
workbook.getCell(0, "C" + i).setCustomNumberFormat("0.0");
}
private static void setPercentFormat(IChartDataWorkbook workbook, int i) {
workbook.getCell(0, "B" + i).setCustomNumberFormat("#,##0.0\\%");
workbook.getCell(0, "D" + i).setCustomNumberFormat("#,##0.0\\%");
}
If you want the same “automatic” chart behavior in the case of Axis, you must set all styles of Axis elements. For example, you should set the size and font:
horizontalAxis.getTextFormat().getPortionFormat().setFontHeight(12);
horizontalAxis.getTextFormat().getPortionFormat().setLatinFont(new FontData("Aptos"));

output.zip (30.1 KB)