Example: The following example creates date time 100Percent stacked area series chart and adds values to it.
import com.cete.dynamicpdf.Document; import com.cete.dynamicpdf.Page; import com.cete.dynamicpdf.pageelements.charting.Chart; import com.cete.dynamicpdf.pageelements.charting.PlotArea; import com.cete.dynamicpdf.pageelements.charting.Title; import com.cete.dynamicpdf.pageelements.charting.series.DateTime100PercentStackedAreaSeries; import com.cete.dynamicpdf.pageelements.charting.series.DateTime100PercentStackedAreaSeriesElement; import com.cete.dynamicpdf.pageelements.charting.values.DateTime100PercentStackedAreaValue; import java.util.Calendar; 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 positions Calendar p0=Calendar.getInstance(); p0.set(2007,0,1); Calendar p1=Calendar.getInstance(); p1.set(2007,1,1); Calendar p2=Calendar.getInstance(); p2.set(2007,2,1); Calendar p3=Calendar.getInstance(); p3.set(2007,3,1); // Create date time 100Percent stacked area series element and add values to it DateTime100PercentStackedAreaSeriesElement areaSeries1 = new DateTime100PercentStackedAreaSeriesElement("Website A"); areaSeries1.getValues().add(new DateTime100PercentStackedAreaValue(5, p0)); areaSeries1.getValues().add(new DateTime100PercentStackedAreaValue(7, p1)); areaSeries1.getValues().add(new DateTime100PercentStackedAreaValue(9, p2)); areaSeries1.getValues().add(new DateTime100PercentStackedAreaValue(6, p3)); DateTime100PercentStackedAreaSeriesElement areaSeries2 = new DateTime100PercentStackedAreaSeriesElement("Website B"); areaSeries2.getValues().add(new DateTime100PercentStackedAreaValue(4, p0)); areaSeries2.getValues().add(new DateTime100PercentStackedAreaValue(2, p1)); areaSeries2.getValues().add(new DateTime100PercentStackedAreaValue(5, p2)); areaSeries2.getValues().add(new DateTime100PercentStackedAreaValue(8, p3)); DateTime100PercentStackedAreaSeriesElement areaSeries3 = new DateTime100PercentStackedAreaSeriesElement("Website C"); areaSeries3.getValues().add(new DateTime100PercentStackedAreaValue(2, p0)); areaSeries3.getValues().add(new DateTime100PercentStackedAreaValue(4, p1)); areaSeries3.getValues().add(new DateTime100PercentStackedAreaValue(6, p2)); areaSeries3.getValues().add(new DateTime100PercentStackedAreaValue(9, p3)); // Create a date time 100Percent stacked area series and add date time 100Percent stacked area series elements to it DateTime100PercentStackedAreaSeries stackedAreaSeries1 = new DateTime100PercentStackedAreaSeries(); stackedAreaSeries1.add(areaSeries1); stackedAreaSeries1.add(areaSeries2); stackedAreaSeries1.add(areaSeries3); // add date time 100Percent stacked area series to the plot area plotArea.getSeries().add(stackedAreaSeries1); // set label list format for the axislabels stackedAreaSeries1.getXAxis().setLabelFormat("MMM"); // add the chart to the page page.getElements().add(chart); // Save the PDF document.draw("[Physicalpath]/MyDocument.pdf"); } }