Example: The following example creates a XYScatterSeries chart and adds XYSCatterValues to it.
import com.cete.dynamicpdf.Document;
import com.cete.dynamicpdf.Page;
import com.cete.dynamicpdf.RgbColor;
import com.cete.dynamicpdf.pageelements.charting.*;
import com.cete.dynamicpdf.pageelements.charting.axes.*;
import com.cete.dynamicpdf.pageelements.charting.series.*;
import com.cete.dynamicpdf.pageelements.charting.values.*;
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, 450, 230);
// Get the default plot area from the chart
PlotArea plotArea = chart.getPrimaryPlotArea();
// Create a Header title and add it to the chart
Title tTitle = new Title("Player Height and Weight");
chart.getHeaderTitles().add(tTitle);
// Create xyScatter series and add values to it
XYScatterSeries xyScatterSeries1 = new XYScatterSeries("Team A");
xyScatterSeries1.getValues().add(new XYScatterValue(112, 55));
xyScatterSeries1.getValues().add(new XYScatterValue(125, 60));
xyScatterSeries1.getValues().add(new XYScatterValue(138, 68));
xyScatterSeries1.getValues().add(new XYScatterValue(150, 73));
xyScatterSeries1.getValues().add(new XYScatterValue(172, 82));
XYScatterSeries xyScatterSeries2 = new XYScatterSeries("Team B");
xyScatterSeries2.getValues().add(new XYScatterValue(110, 54));
xyScatterSeries2.getValues().add(new XYScatterValue(128, 62));
xyScatterSeries2.getValues().add(new XYScatterValue(140, 70));
xyScatterSeries2.getValues().add(new XYScatterValue(155, 75));
xyScatterSeries2.getValues().add(new XYScatterValue(170, 80));
// Add xyScatter series to the plot Area
plotArea.getSeries().add(xyScatterSeries1);
plotArea.getSeries().add(xyScatterSeries2);
// Create axis titles and add it to the axis
Title title1 = new Title("Height (Inches)");
Title title2 = new Title("Weight (Pounds)");
xyScatterSeries1.getYAxis().getTitles().add(title1);
xyScatterSeries1.getXAxis().getTitles().add(title2);
// Add the chart to the page
page.getElements().add(chart);
// Save the PDF
document.draw("[PhysicalPath]/MyDocument.pdf" );
}
}