ceTe Software Help Library for Java August - 2020
DynamicPDF Generator for Java / Programming with Generator for Java / Charts / Chart Types / XYScatter Chart
In This Topic
    XYScatter Chart
    In This Topic

    Different symbols are used to display information in XYScatter charts. They are similar to Line charts but differ in the XAxis. It uses numeric axes for both the XAxis and the YAxis, whereas in Line Charts the XAxis is not numeric. Lines are not displayed in XYScatter charts unless the property LineDisplay is set to true.

                                 Figure 1 - An example XYScatter Chart

    [Java]
        // 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, 200);
        // Add a plot Area to 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 a xyScatter series and add values to it
        XYScatterSeries xyScatterSeries1 = new XYScatterSeries("Team A");
        xyScatterSeries1.getValues().add(112, 55);
        xyScatterSeries1.getValues().add(125, 60);
        xyScatterSeries1.getValues().add(138, 68);
        xyScatterSeries1.getValues().add(150, 73);
        xyScatterSeries1.getValues().add(172, 82);
        XYScatterSeries xyScatterSeries2 = new XYScatterSeries("Team B");
        xyScatterSeries2.getValues().add(110,54);
        xyScatterSeries2.getValues().add(128, 62);
        xyScatterSeries2.getValues().add(140, 70);
        xyScatterSeries2.getValues().add(155, 75);
        xyScatterSeries2.getValues().add(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");
    
    See Also