In This Article

Chart Basics

This topic discusses some of the basic concepts for using Charts.

Primary vs. Secondary Axis

The XYChart control supports two axes, X and Y. The X axis runs horizontally along the control, and the Y axis runs vertically. All series default to rendering horizontally, which means that Y is the primary axis and X is the secondary axis.

Certain series types, such as Bar, support vertical orientations as well as the default horizontal orientation. With vertically oriented series, X is the primary axis and Y is the secondary axis.

See the Chart Types topic for additional information.

Screenshot

Horizontal Bar Chart

Screenshot

Vertical Bar Chart

Adding a Series

Each series is represented by an individual .NET type. For instance, a Line series is implemented by the LineSeries class.

Add any series you would like to display to the XYChart.Series collection. The chart will automatically scale the X and Y axes to fit the data of each series properly, however you can also specify axes and control how they are displayed. See Axes for more details.

See the Chart Types topic for a list of the available chart types.

Specifying Items

Each series is bound to its own data source, which is indicated by the ItemsSource property. The XPath and YPath will determine the property path used for values on the X and Y axes.

When XPath and YPath are not specified, then the respective X and Y values will instead be the items in the ItemsSource collection.

When X or Y axes values resolve to a quantifiable or numeric data type, such as Double, Decimal, Int32 or DateTime, then the respective axis should match the data type. If axes are not specified, they will be set automatically.

When X or Y axes values resolve to a complex object or reference type, such as String or a user-provided type, then the respective axis should be XYGroupedAxis. By default, these type of values will be grouped based on object equality. Grouping can be determined based on custom criteria by specifying XYGroupedAxis.GroupingFunc.

See the Specifying Items topic for additional information.