Example: The following example creates indexed stacked line series elements and creates indexed stacked line series chart 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.axes.IndexedXAxis; import com.cete.dynamicpdf.pageelements.charting.axes.IndexedXAxisLabel; import com.cete.dynamicpdf.pageelements.charting.axes.NumericYAxis; import com.cete.dynamicpdf.pageelements.charting.series.IndexedStackedLineSeries; import com.cete.dynamicpdf.pageelements.charting.series.IndexedStackedLineSeriesElement; 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); // Add a plot Area to 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 x axis IndexedXAxis xAxis = new IndexedXAxis(); // Create a numeric y axis NumericYAxis yAxis = new NumericYAxis(); // Create indexed axis labels and add those to indexed xAxis xAxis.getLabels().add(new IndexedXAxisLabel("Q1", 0)); xAxis.getLabels().add(new IndexedXAxisLabel("Q2", 1)); xAxis.getLabels().add(new IndexedXAxisLabel("Q3", 2)); xAxis.getLabels().add(new IndexedXAxisLabel("Q4", 3)); // Create a indexed stacked line series element and add values to it IndexedStackedLineSeriesElement seriesElement1 = new IndexedStackedLineSeriesElement("Website A"); seriesElement1.getValues().add(new float[] { 5, 7, 9, 6 }); IndexedStackedLineSeriesElement seriesElement2 = new IndexedStackedLineSeriesElement("Website B"); seriesElement2.getValues().add(new float[] { 4, 2, 5, 8 }); IndexedStackedLineSeriesElement seriesElement3 = new IndexedStackedLineSeriesElement("Website C"); seriesElement3.getValues().add(new float[] { 2, 4, 6, 9 }); // Create a indexed stacked line series and add indexed stacked line series elements to it IndexedStackedLineSeries stackedLineSeries1 = new IndexedStackedLineSeries(xAxis, yAxis); stackedLineSeries1.add(seriesElement1); stackedLineSeries1.add(seriesElement2); stackedLineSeries1.add(seriesElement3); // Add indexed stacked line series to the plot line plotArea.getSeries().add(stackedLineSeries1); // Create a title and add it to the YAxis Title bTitle = new Title("Visitors (in millions)"); plotArea.getYAxes().getYAxis(0).getTitles().add(bTitle); // Add the chart to the page page.getElements().add(chart); // Save the PDF document.draw("[PhysicalPath]/MyDocument.pdf"); } }