com.cete.dynamicpdf.pageelements.charting
Class ScalarDataLabel



Example: The following example creates a pie chart with the scalar data label.

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, 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 scalar datalabel
           ScalarDataLabel da = new ScalarDataLabel(true, false, false);
        
           // Create a pieseries and add datalabel to the series
           PieSeries pieSeries = new PieSeries();
           pieSeries.setDataLabel(da);
        
           // Add the elements to the plotarea
           plotArea.getSeries().add(pieSeries);
           pieSeries.getElements().add(27, "Website A");
           pieSeries.getElements().add(19, "Website B");
           pieSeries.getElements().add(21, "Website C");
        
           // Add the chart to the page 
           page.getElements().add(chart);
 
           // Save the PDF
           document.draw("[PhysicalPath]/MyDocument.pdf" );
       }
 }