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



Example: The following example creates and indexed area value 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);
        
        // Create a plot area
        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 xAxis
        IndexedXAxis xAxis = new IndexedXAxis();
        
        // Create a numeric yAxis
        NumericYAxis yAxis = new NumericYAxis();
        
        // Create a indexed area series and add values to it
        IndexedAreaSeries areaSeries1 = new IndexedAreaSeries("Website A", xAxis, yAxis);
        areaSeries1.getValues().add(new IndexedAreaValue(5, 0));
        areaSeries1.getValues().add(new IndexedAreaValue(7, 1));
        areaSeries1.getValues().add(new IndexedAreaValue(9, 2));
        areaSeries1.getValues().add(new IndexedAreaValue(6, 3));
        IndexedAreaSeries areaSeries2 = new IndexedAreaSeries("Website B", xAxis, yAxis);
        areaSeries2.getValues().add(new IndexedAreaValue(4, 0));
        areaSeries2.getValues().add(new IndexedAreaValue(2, 1));
        areaSeries2.getValues().add(new IndexedAreaValue(5, 2));
        areaSeries2.getValues().add(new IndexedAreaValue(8, 3));
        IndexedAreaSeries areaSeries3 = new IndexedAreaSeries("Website C", xAxis, yAxis);
        areaSeries3.getValues().add(new IndexedAreaValue(2, 0));
        areaSeries3.getValues().add(new IndexedAreaValue(4, 1));
        areaSeries3.getValues().add(new IndexedAreaValue(6, 2));
        areaSeries3.getValues().add(new IndexedAreaValue(9, 3));
        
        // add indexed area series to the plot area
        plotArea.getSeries().add(areaSeries1);
        plotArea.getSeries().add(areaSeries2);
        plotArea.getSeries().add(areaSeries3);
        
        // Create a Y Axis title and add it to the YAxis
        Title lTitle = new Title("Visitors (in millions)");
        yAxis.getTitles().add(lTitle);
        
        // adding AxisLabels to the XAxis
        areaSeries1.getXAxis().getLabels().add(new IndexedXAxisLabel("Q1", 0));
        areaSeries1.getXAxis().getLabels().add(new IndexedXAxisLabel("Q2", 1));
        areaSeries1.getXAxis().getLabels().add(new IndexedXAxisLabel("Q3", 2));
        areaSeries1.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");
       }
 }