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



Example: The following example creates a date time column series 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 java.util.Calendar;

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, 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 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 column series and add values to it
        DateTimeColumnSeries columnSeries1 = new DateTimeColumnSeries("Website A");
        columnSeries1.getValues().add(new DateTimeColumnValue(5, p0));
        columnSeries1.getValues().add(new DateTimeColumnValue(7, p1));
        columnSeries1.getValues().add(new DateTimeColumnValue(4, p2));
        columnSeries1.getValues().add(new DateTimeColumnValue(3, p3));
        DateTimeColumnSeries columnSeries2 = new DateTimeColumnSeries("Website B");
        columnSeries2.getValues().add(new DateTimeColumnValue(4, p0));
        columnSeries2.getValues().add(new DateTimeColumnValue(2, p1));
        columnSeries2.getValues().add(new DateTimeColumnValue(5, p2));
        columnSeries2.getValues().add(new DateTimeColumnValue(8, p3));
        DateTimeColumnSeries columnSeries3 = new DateTimeColumnSeries("Website C");
        columnSeries3.getValues().add(new DateTimeColumnValue(2, p0));
        columnSeries3.getValues().add(new DateTimeColumnValue(4, p1));
        columnSeries3.getValues().add(new DateTimeColumnValue(6, p2));
        columnSeries3.getValues().add(new DateTimeColumnValue(9, p3));
        
        // Add date time 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 title3 = new Title("Viewers (in millions)");
        columnSeries1.getYAxis().getTitles().add(title3);
        
        // set label list format for the axislabels
        columnSeries1.getXAxis().setLabelFormat("MMM");
        
        // Add the chart to the page
        page.getElements().add(chart);


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