This short tutorial describes how to create a pie chart in PowerPoint using Java. All the necessary details like environment configuration, detailed procedure, and a runnable sample code are available in this article. It enables you to not only make a pie chart in PowerPoint using Java but also guides you to generate other types of charts as well and save them to any of the desired formats like PPTX, PPT, etc.
Steps to Create a Pie Chart in PowerPoint using Java
- Establish the development environment to add Aspose.Slides from the Maven repository
- Create a new Presentation object
- Get the first slide
- Get the shapes collection
- Add a pie chart by defining its position and size
- Set the property to show data label values on the chart
- Save the presentation on the disk
These steps provide a systematic approach to create pie chart in PowerPoint using Java with the help of identification of required classes and methods. You can create a pie chart with the default settings just using a couple of lines of code however, you may create other types of charts as well using the ChartType enumerator that contains options like ClusteredCylinder, Cylinder3D, Cone3D, PieOfPie, PercentsStackedHorizontalCone, ScatterWithSmoothLines, etc. to list a very few.
Code to Add Pie Chart to PowerPoint using Java
This sample code demonstrates how to make a chart in PowerPoint using Java by showing the process to make a pie chart. Using the IChart class, you can set chart axes, data, title, legend, plot area, rotation, back wall, side wall, style, etc. The resultant presentation can be saved as PPTX, PPT, PDF, PPSX, PPTM, HTML, GIF, and many other formats as well.
This tutorial has taught us how to make a pie chart in PowerPoint using Java. However, if you want to learn the process to secure a PowerPoint presentation, refer to the article on how to secure PowerPoint presentation using Java.