Example: The following example creates date time area series chart and creates numeric yaxis.
import com.cete.dynamicpdf.Document; import com.cete.dynamicpdf.Page; import com.cete.dynamicpdf.pageelements.charting.*; import com.cete.dynamicpdf.pageelements.charting.axes.*; import com.cete.dynamicpdf.pageelements.charting.series.*; import java.util.Calendar; 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(); 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 DateTime xAxis DateTimeXAxis xAxis = new DateTimeXAxis(); // Create a numeric yAxis and add labels to it NumericYAxis yAxis = new NumericYAxis(); yAxis.getLabels().add(new NumericYAxisLabel("0", 0)); yAxis.getLabels().add(new NumericYAxisLabel("1", 1)); yAxis.getLabels().add(new NumericYAxisLabel("2", 2)); yAxis.getLabels().add(new NumericYAxisLabel("3", 3)); yAxis.getLabels().add(new NumericYAxisLabel("4", 4)); yAxis.getLabels().add(new NumericYAxisLabel("5", 5)); yAxis.getLabels().add(new NumericYAxisLabel("6", 6)); yAxis.getLabels().add(new NumericYAxisLabel("7", 7)); yAxis.getLabels().add(new NumericYAxisLabel("8", 8)); yAxis.getLabels().add(new NumericYAxisLabel("9", 9)); // Create positions Calendar p0=Calendar.getInstance(); p0.set(2007,1,1); Calendar p1=Calendar.getInstance(); p1.set(2007,2,1); Calendar p2=Calendar.getInstance(); p2.set(2007,3,1); Calendar p3=Calendar.getInstance(); p3.set(2007,4,1); // Create a date time area series and add values to it DateTimeAreaSeries areaSeries1 = new DateTimeAreaSeries("Website A", xAxis, yAxis); areaSeries1.getValues().add(5, p0); areaSeries1.getValues().add(7, p1); areaSeries1.getValues().add(9, p2); areaSeries1.getValues().add(6, p3); DateTimeAreaSeries areaSeries2 = new DateTimeAreaSeries("Website B", xAxis, yAxis); areaSeries2.getValues().add(4, p0); areaSeries2.getValues().add(2, p1); areaSeries2.getValues().add(5, p2); areaSeries2.getValues().add(8, p3); DateTimeAreaSeries areaSeries3 = new DateTimeAreaSeries("Website C", xAxis, yAxis); areaSeries3.getValues().add(2, p0); areaSeries3.getValues().add(4, p1); areaSeries3.getValues().add(6, p2); areaSeries3.getValues().add(9, p3); // Add area series to the plot area plotArea.getSeries().add(areaSeries1); plotArea.getSeries().add(areaSeries2); plotArea.getSeries().add(areaSeries3); // Create a title and add it to the YAxis Title title3 = new Title("Viewers (in millions)"); yAxis.getTitles().add(title3); // Set label list format for the axislabels areaSeries1.getXAxis().setLabelFormat("MMM"); // Add the chart to the page page.getElements().add(chart); // Save the PDF document.draw("[PhysicalPath]/MyDocument.pdf" ); } }