Example: The following example creates a date time 100 percent stacked bar chart and creates a date time yaxis label in the 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 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 percentage xAxis PercentageXAxis xAxis = new PercentageXAxis(); // Create date time yAxis DateTimeYAxis yAxis = new DateTimeYAxis(); // Create positions Calendar p0=Calendar.getInstance(); p0.set(2006,0,1); Calendar p1=Calendar.getInstance(); p1.set(2006,1,1); Calendar p2=Calendar.getInstance(); p2.set(2006,2,1); Calendar p3=Calendar.getInstance(); p3.set(2006,3,1); // Create yAxisLabels and add values to it yAxis.getLabels().add(new DateTimeYAxisLabel("Jan", p0 )); yAxis.getLabels().add(new DateTimeYAxisLabel("Feb", p1)); yAxis.getLabels().add(new DateTimeYAxisLabel("Mar", p2)); yAxis.getLabels().add(new DateTimeYAxisLabel("Apr", p3)); // Create a date time 100 percent stacked bar series element and add values to it DateTime100PercentStackedBarSeriesElement seriesElement1 = new DateTime100PercentStackedBarSeriesElement("Website A"); seriesElement1.getValues().add(5, p0); seriesElement1.getValues().add(7, p1); seriesElement1.getValues().add(9, p2); seriesElement1.getValues().add(6, p3); DateTime100PercentStackedBarSeriesElement seriesElement2 = new DateTime100PercentStackedBarSeriesElement("Website B"); seriesElement2.getValues().add(4, p0); seriesElement2.getValues().add(2, p1); seriesElement2.getValues().add(5, p2); seriesElement2.getValues().add(8, p3); DateTime100PercentStackedBarSeriesElement seriesElement3 = new DateTime100PercentStackedBarSeriesElement("Website C"); seriesElement3.getValues().add(2, p0); seriesElement3.getValues().add(4, p1); seriesElement3.getValues().add(6, p2); seriesElement3.getValues().add(9, p3); // Create a date time 100 percent stacked bar series and add date time 100 percent stacked bar series elements to it DateTime100PercentStackedBarSeries stackedBarSeries1 = new DateTime100PercentStackedBarSeries(xAxis, yAxis); stackedBarSeries1.add(seriesElement1); stackedBarSeries1.add(seriesElement2); stackedBarSeries1.add(seriesElement3); // Add date time 100 percent stacked bar series to the plot area plotArea.getSeries().add(stackedBarSeries1); // Create a title and add it to the x axis Title title3 = new Title("Viewers"); stackedBarSeries1.getXAxis().getTitles().add(title3); // Add the chart to the page page.getElements().add(chart); // Save the PDF document.draw("[PhysicalPath]/MyDocument.pdf" ); } }