The chart control can be bound to any custom data source and supports several data types.
Supported Quantifiable Axis Types
The chart control supports a fixed set of quantifiable data types along each axis.
The supported data types include:
Byte
DateTime
Decimal
Double
Int16
Int32
Int64
Float
SByte
UInt16
UInt32
UInt64
When the X or Y axis values are of these data types, then the values can be mapped on an axis according to their relative position within the axis Minimum
and Maximum
values.
Other Axis Types
For all other types of data, including complex objects and String
, they will be mapped using XYGrouped
When using XYGrouped
Setting ItemsSource
Each series in a chart control can be bound to a separate data source, or to different properties on the same data source. The ItemsIEnumerable
.
In this case, the XPath and/or YPath properties must be set to the name of a property on the objects in the collection.
Tip
You can traverse complex hierarchies to get to the value you need by using a property path that is delimited by a period (.
). For example, you can set XPath or YPath to something like "MyProperty.MyOtherProperty.MyDoubleValue"
, similar to how binding paths work in XAML.
For example, consider the following custom object:
We can specify that the Y values should be pulled from the Amount
property by setting YPath to "Amount"
. If we want to use the index in the collection as our X values, then we do not need to set XPath.
If instead we want the X values to be pulled from the Date
property, then we would need to set XPath to "Date"
.