Example: The following example creates a indexed column series chart and adds values to it.
import com.cete.dynamicpdf.Document;
import com.cete.dynamicpdf.Page;
import com.cete.dynamicpdf.pageelements.charting.*;
import com.cete.dynamicpdf.pageelements.charting.series.*;
import com.cete.dynamicpdf.pageelements.charting.values.*;
import com.cete.dynamicpdf.pageelements.charting.axes.*;
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, 230);
// 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 indexed column series and add values to it
IndexedColumnSeries columnSeries1 = new IndexedColumnSeries("Website A");
columnSeries1.getValues().add(new IndexedColumnValue(5, 0));
columnSeries1.getValues().add(new IndexedColumnValue(7, 1));
columnSeries1.getValues().add(new IndexedColumnValue(9, 2));
columnSeries1.getValues().add(new IndexedColumnValue(6, 3));
IndexedColumnSeries columnSeries2 = new IndexedColumnSeries("Website B");
columnSeries2.getValues().add(new IndexedColumnValue(4, 0));
columnSeries2.getValues().add(new IndexedColumnValue(2, 1));
columnSeries2.getValues().add(new IndexedColumnValue(5, 2));
columnSeries2.getValues().add(new IndexedColumnValue(8, 3));
IndexedColumnSeries columnSeries3 = new IndexedColumnSeries("Website C");
columnSeries3.getValues().add(new IndexedColumnValue(2, 0));
columnSeries3.getValues().add(new IndexedColumnValue(4, 1));
columnSeries3.getValues().add(new IndexedColumnValue(6, 2));
columnSeries3.getValues().add(new IndexedColumnValue(8, 3));
// add indexed column series to the plot area
plotArea.getSeries().add(columnSeries1);
plotArea.getSeries().add(columnSeries2);
plotArea.getSeries().add(columnSeries3);
// Create a title and add it to the yaxis
Title lTitle = new Title("Visitors (in millions)");
columnSeries1.getYAxis().getTitles().add(lTitle);
// adding AxisLabels to the XAxis
columnSeries1.getXAxis().getLabels().add(new IndexedXAxisLabel("Q1", 0));
columnSeries1.getXAxis().getLabels().add(new IndexedXAxisLabel("Q2", 1));
columnSeries1.getXAxis().getLabels().add(new IndexedXAxisLabel("Q3", 2));
columnSeries1.getXAxis().getLabels().add(new IndexedXAxisLabel("Q4", 3));
// add the chart to the page
page.getElements().add(chart);
// Save the PDF
document.draw("[PhysicalPath]/MyDocument.pdf" );
}
}