com.cete.dynamicpdf.pageelements.charting.axes
Class XAxisTickMarks



Example: The following example creates a indexed bar series chart and creates a tickmark to xaxis.

import com.cete.dynamicpdf.*;
import com.cete.dynamicpdf.pageelements.charting.*;
import com.cete.dynamicpdf.pageelements.charting.axes.*;
import com.cete.dynamicpdf.pageelements.charting.series.*;

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);
        
        // 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 y axis
        IndexedYAxis yAxis = new IndexedYAxis();
        
        // Create a numeric x axis and add tickmarks
        NumericXAxis xAxis = new NumericXAxis();
        XAxisTickMarks xTicks = new XAxisTickMarks();
        xAxis.setMajorTickMarks( xTicks);
        
        // Create a indexed bar series and add values to it
        IndexedBarSeries barSeries1 = new IndexedBarSeries("Website A", xAxis, yAxis);
        barSeries1.getValues().add(new float[] { 5, 7, 9, 6 });
        IndexedBarSeries barSeries2 = new IndexedBarSeries("Website B", xAxis, yAxis);
        barSeries2.getValues().add(new float[] { 4, 2, 5, 8 });
        IndexedBarSeries barSeries3 = new IndexedBarSeries("Website C", xAxis, yAxis);
        barSeries3.getValues().add(new float[] { 2, 4, 6, 9 });
        
        // Add indexed bar series to the plot area
        plotArea.getSeries().add(barSeries1);
        plotArea.getSeries().add(barSeries2);
        plotArea.getSeries().add(barSeries3);
        
        // Create a footer title and add it to the chart
        Title title3 = new Title("Visitors (in millions)");
        chart.getFooterTitles().add(title3);
        
        // Adding AxisLabels to the YAxis
        barSeries1.getYAxis().getLabels().add(new IndexedYAxisLabel("Q1", 0));
        barSeries1.getYAxis().getLabels().add(new IndexedYAxisLabel("Q2", 1));
        barSeries1.getYAxis().getLabels().add(new IndexedYAxisLabel("Q3", 2));
        barSeries1.getYAxis().getLabels().add(new IndexedYAxisLabel("Q4", 3));
        
        // Add the chart to the page
        page.getElements().add(chart);

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