XYScatter Chart

Scatter charts are similar to line charts but differ in the x-axis. Different symbols are also used to display information in scatter charts. Scatter charts use numeric axes for both the x-axis and y-axis, whereas in line charts the x-axis is not numeric. Lines are not displayed in scatter charts unless the property LineDisplay is set to True.

Figure 1. An example XYScatter Chart

XYScatterSeries

To create a scatter chart, use an XYScatterSeries. Use this class to configure your chart. An XYScatterSeries uses a NumericXAxis and NumericYAxis.

Properties

Property Description
Color Gets or sets the Color object to use for the color of the series. (Inherited from LegendXYSeries)
DataLabel Gets or sets the XYScatterDataLabel of the XYScatter series. This is the default data label for the series.
DrawBehindAxis Gets or sets the position of the Series either below or above the axis. By default it is true. (Inherited from SeriesBase)
Legend Gets or sets the Legend object of the PlotAreaElement. (Inherited from PlotAreaElement)
LegendLabel Gets the LegendLabel object to use for the series. (Inherited from LegendXYSeries)
LineCap Gets or sets the LineCap.
LineDisplay Gets or sets the LineDisplay.
LineJoin Gets or sets the LineJoin.
LineStyle Gets or sets the LineStyle.
Marker Gets or sets the Marker.
Name Gets the name of the series. (Inherited from LegendXYSeries)
PlotArea Gets the PlotArea object of the PlotAreaElement. (Inherited from PlotAreaElement)
Values Gets the XYScatterValueList.
Width Gets or sets the LineWidth of the XYScatterSeries.
XAxis Gets the NumericXAxis of the series.
XValueFormat Gets or sets the XValueFormatString .
YAxis Gets the NumericYAxis of the series.
YValueFormat Gets or sets the YValueFormatString of the XYScatterSeries.

Example

The following example illustrates creating an xy scatter chart using an XYScatterSeries.

// Create a PDF Document
Document document = new Document();
// Create a Page and add it to the document
Page page = new Page();
document.Pages.Add(page);

// Create a chart
Chart chart = new Chart(0, 0, 450, 200);
// Add a plot Area to the chart
PlotArea plotArea = chart.PrimaryPlotArea;

// Create a Header title and add it to the chart
Title tTitle = new Title("Player Height and Weight");
chart.HeaderTitles.Add(tTitle);

// Create a xyScatter series and add values to it
XYScatterSeries xyScatterSeries1 = new XYScatterSeries("Team A");
xyScatterSeries1.Values.Add(112, 110);
xyScatterSeries1.Values.Add(125, 120);
xyScatterSeries1.Values.Add(138, 136);
xyScatterSeries1.Values.Add(150, 146);
xyScatterSeries1.Values.Add(172, 164);
XYScatterSeries xyScatterSeries2 = new XYScatterSeries("Team B");
xyScatterSeries2.Values.Add(110, 108);
xyScatterSeries2.Values.Add(128, 124);
xyScatterSeries2.Values.Add(140, 140);
xyScatterSeries2.Values.Add(155, 150);
xyScatterSeries2.Values.Add(170, 160);

// Add xyScatter series to the plot Area
plotArea.Series.Add(xyScatterSeries1);
plotArea.Series.Add(xyScatterSeries2);           

// Create axis titles and add it to the axis
Title title1 = new Title("Height (Inches)");
Title title2 = new Title("Weight (Pounds)");
xyScatterSeries1.YAxis.Titles.Add(title1);
xyScatterSeries1.XAxis.Titles.Add(title2);

// Add the chart to the page
page.Elements.Add(chart);
// Save the PDF
document.Draw(pdfFilePath);        
' Create a PDF Document
Dim MyDocument As New Document()
' Create a Page and add it to the document
Dim MyPage As New Page()
MyDocument.Pages.Add(MyPage)

' Create a chart
Dim MyChart As New Chart(0, 0, 450, 200)
' Add a plot Area to the chart
Dim MyPlotArea As PlotArea = MyChart.PrimaryPlotArea

' Create a Header title and add it to the chart
Dim MytTitle As New Title("Player Height and Weight")
MyChart.HeaderTitles.Add(MytTitle)

' Create a xyScatter series and add values to it
Dim MyXYScatterSeries1 As New XYScatterSeries("Team A")
MyXYScatterSeries1.Values.Add(112, 110)
MyXYScatterSeries1.Values.Add(125, 120)
MyXYScatterSeries1.Values.Add(138, 136)
MyXYScatterSeries1.Values.Add(150, 146)
MyXYScatterSeries1.Values.Add(172, 164)
Dim MyXYScatterSeries2 As New XYScatterSeries("Team B")
MyXYScatterSeries2.Values.Add(110, 108)
MyXYScatterSeries2.Values.Add(128, 124)
MyXYScatterSeries2.Values.Add(140, 140)
MyXYScatterSeries2.Values.Add(155, 150)
MyXYScatterSeries2.Values.Add(170, 160)

' Add xyScatter series to the plot Area
MyPlotArea.Series.Add(MyXYScatterSeries1)
MyPlotArea.Series.Add(MyXYScatterSeries2)

' Create axis titles and add it to the axis
Dim Mytitle1 As New Title("Height (Inches)")
Dim Mytitle2 As New Title("Weight (Pounds)")
MyXYScatterSeries1.YAxis.Titles.Add(Mytitle1)
MyXYScatterSeries1.XAxis.Titles.Add(Mytitle2)

' Add the chart to the page
MyPage.Elements.Add(MyChart)
' Save the PDF
MyDocument.Draw(pdfFilePath)

For a complete example, refer to the XYScatterSeries API documentation.

In this topic