com.cete.dynamicpdf.pageelements.charting.values
Class IndexedStackedAreaValue



Example: The following example creates indexed 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.*;
import com.cete.dynamicpdf.pageelements.charting.series.*;
import com.cete.dynamicpdf.pageelements.charting.values.*;
import com.cete.dynamicpdf.pageelements.charting.axes.*;

 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 x axis
        IndexedXAxis xAxis = new IndexedXAxis();
        
        // adding AxisLabels to the 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 numeric y axis
        NumericYAxis yAxis = new NumericYAxis();
        
        // Create a indexed stacked area series element and add values to it
        IndexedStackedAreaSeriesElement seriesElement1 = new IndexedStackedAreaSeriesElement("Website A");
        seriesElement1.getValues().add(new IndexedStackedAreaValue(5, 0));
        seriesElement1.getValues().add(new IndexedStackedAreaValue(7, 1));
        seriesElement1.getValues().add(new IndexedStackedAreaValue(9, 2));
        seriesElement1.getValues().add(new IndexedStackedAreaValue(6, 3));
        IndexedStackedAreaSeriesElement seriesElement2 = new IndexedStackedAreaSeriesElement("Website B");
        seriesElement2.getValues().add(new IndexedStackedAreaValue(4, 0));
        seriesElement2.getValues().add(new IndexedStackedAreaValue(2, 1));
        seriesElement2.getValues().add(new IndexedStackedAreaValue(5, 2));
        seriesElement2.getValues().add(new IndexedStackedAreaValue(8, 3));
        IndexedStackedAreaSeriesElement seriesElement3 = new IndexedStackedAreaSeriesElement("Website C");
        seriesElement3.getValues().add(new IndexedStackedAreaValue(2, 0));
        seriesElement3.getValues().add(new IndexedStackedAreaValue(4, 1));
        seriesElement3.getValues().add(new IndexedStackedAreaValue(6, 2));
        seriesElement3.getValues().add(new IndexedStackedAreaValue(9, 3));
        
        // Create a indexed stacked area series and add indexed stacked area series elements to it
        IndexedStackedAreaSeries stackedAreaSeries1 = new IndexedStackedAreaSeries(xAxis, yAxis);
        stackedAreaSeries1.add(seriesElement1);
        stackedAreaSeries1.add(seriesElement2);
        stackedAreaSeries1.add(seriesElement3);
        
        // add indexed stacked area series to the plot area
        plotArea.getSeries().add(stackedAreaSeries1);
        
        // Create a title and add it to the yaxis
        Title lTitle = new Title("Visitors (in millions)");
        stackedAreaSeries1.getYAxis().getTitles().add(lTitle);
        
        // add the chart to the page
        page.getElements().add(chart);
        

        // Save the PDF
        document.draw("[PhysicalPath]/MyDocument.pdf");
       }
 }