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



Example: The following example creates date time 100Percent stacked line 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.*;
import java.util.Calendar;
 
 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 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 date time x axis
        DateTimeXAxis xAxis = new DateTimeXAxis();
        
        //Create a percentage y axis
        PercentageYAxis yAxis = new PercentageYAxis();
        
        // Create positions
        Calendar p0=Calendar.getInstance();
        p0.set(2007,0,1);
        Calendar p1=Calendar.getInstance();
        p1.set(2007,1,1);
        Calendar p2=Calendar.getInstance();
        p2.set(2007,2,1);
        Calendar p3=Calendar.getInstance();
        p3.set(2007,3,1);
        
        // Create a date time 100Percent stacked line series element and add values to it
        DateTime100PercentStackedLineSeriesElement seriesElement1 = new DateTime100PercentStackedLineSeriesElement("Website A");
        seriesElement1.getValues().add(new DateTime100PercentStackedLineValue(5,   p0));
        seriesElement1.getValues().add(new DateTime100PercentStackedLineValue(7,    p1));
        seriesElement1.getValues().add(new DateTime100PercentStackedLineValue(9,    p2));
        seriesElement1.getValues().add(new DateTime100PercentStackedLineValue(6,    p3));
        DateTime100PercentStackedLineSeriesElement seriesElement2 = new DateTime100PercentStackedLineSeriesElement("Website B");
        seriesElement2.getValues().add(new DateTime100PercentStackedLineValue(4,   p0));
        seriesElement2.getValues().add(new DateTime100PercentStackedLineValue(2,    p1));
        seriesElement2.getValues().add(new DateTime100PercentStackedLineValue(5,    p2));
        seriesElement2.getValues().add(new DateTime100PercentStackedLineValue(8,    p3));
        DateTime100PercentStackedLineSeriesElement seriesElement3 = new DateTime100PercentStackedLineSeriesElement("Website C");
        seriesElement3.getValues().add(new DateTime100PercentStackedLineValue(2,   p0));
        seriesElement3.getValues().add(new DateTime100PercentStackedLineValue(4,    p1));
        seriesElement3.getValues().add(new DateTime100PercentStackedLineValue(6,    p2));
        seriesElement3.getValues().add(new DateTime100PercentStackedLineValue(9,    p3));
        
        // Create a date time 100Percent stacked line series and add date time 100Percent  stacked line series elements to it
        DateTime100PercentStackedLineSeries stackedLineSeries1 = new DateTime100PercentStackedLineSeries(xAxis, yAxis);
        stackedLineSeries1.add(seriesElement1);
        stackedLineSeries1.add(seriesElement2);
        stackedLineSeries1.add(seriesElement3);
        
        // add date time line series to the plot area
        plotArea.getSeries().add(stackedLineSeries1);
        
        // set label list format for the axislabels
        stackedLineSeries1.getXAxis().setLabelFormat("MMM");
        
        // add the chart to the page
        page.getElements().add(chart);
        
        // Save the PDF
        document.draw("[PhysicalPath]/MyDocument.pdf");
       }
 }