Example: The following example craetes a pie series element and creates a pie chart to it .
import com.cete.dynamicpdf.Document; import com.cete.dynamicpdf.Page; import com.cete.dynamicpdf.PageOrientation; import com.cete.dynamicpdf.PageSize; import com.cete.dynamicpdf.pageelements.charting.Chart; import com.cete.dynamicpdf.pageelements.charting.PlotArea; import com.cete.dynamicpdf.pageelements.charting.ScalarDataLabel; import com.cete.dynamicpdf.pageelements.charting.Title; import com.cete.dynamicpdf.pageelements.charting.series.PieSeries; public class MyClass { public static void main(String args[]){ // Create a PDF Document Document document = new Document(); // Create a Page and add it to the document Page page = new Page(PageSize.A4, PageOrientation.LANDSCAPE); document.getPages().add(page); // Create a chart Chart chart = new Chart(0, 0, 400, 200); //Get the default plot area from the chart PlotArea plotArea = chart.getPrimaryPlotArea(); // Create header titles and add it to the chart Title title1 = new Title("Website Visitors"); Title title2 = new Title("Year - 2007"); chart.getHeaderTitles().add(title1); chart.getHeaderTitles().add(title2); // Create a scalar datalabel ScalarDataLabel da = new ScalarDataLabel(true, false, false); // Create a pieseries and add datalabel to the series PieSeries pieSeries = new PieSeries(); pieSeries.setDataLabel(da); // Add the elements to the plotarea plotArea.getSeries().add(pieSeries); pieSeries.getElements().add(27, "Website A"); pieSeries.getElements().add(19, "Website B"); pieSeries.getElements().add(21, "Website C"); // Add the chart to page and add the page to document page.getElements().add(chart); document.getPages().add(page); // Draw the document document.draw("[PhysicalPath]/MyDocument.pdf"); } }