Skip to main content

Diagram.SeriesItemsSource Property

Gets or sets the collection of objects used to generate series.

Namespace: DevExpress.Xpf.Charts

Assembly: DevExpress.Xpf.Charts.v24.1.dll

NuGet Package: DevExpress.Wpf.Charts

Declaration

[DXDesignerSerializableProperty]
public IEnumerable SeriesItemsSource { get; set; }

Property Value

Type Description
IEnumerable

A collection that is used to generate the series of the Chart. The default is null (Nothing in Visual Basic).

Remarks

You can use one of the following approaches to create series in the single chart:

Example

The Chart Control can generate its child elements from their ViewModels. This is useful when the application uses the MVVM architecture and the Chart should contain several chart elements that are bound to data. You can bind the element’s ItemsSource to the View Model’s property to generate a chart element collection from a chart’s View Model. Then specify the element’s ItemTemplate or ItemTemplateSelector to bind the element’s properties to the element view model’s properties. For example, you can bind a chart’s legend collection to the view model’s legend collection using the ChartControlBase.LegendItemsSource and configure the generated legends using the ChartControlBase.LegendItemTemplate.

View Example

Imports System
Imports System.Collections.Generic
Imports System.Collections.ObjectModel
Imports System.Globalization
Imports System.IO
Imports System.Xml.Linq

Namespace MvvmSample.Model
    Friend Class WeatherInfo
        Private privateTimestamp As Date
        Public Property Timestamp() As Date
            Get
                Return privateTimestamp
            End Get
            Private Set(ByVal value As Date)
                privateTimestamp = value
            End Set
        End Property
        Private privateTemperature As Double
        Public Property Temperature() As Double
            Get
                Return privateTemperature
            End Get
            Private Set(ByVal value As Double)
                privateTemperature = value
            End Set
        End Property
        Private privatePressure As Integer
        Public Property Pressure() As Integer
            Get
                Return privatePressure
            End Get
            Private Set(ByVal value As Integer)
                privatePressure = value
            End Set
        End Property
        Private privateRelativeHumidity As Integer
        Public Property RelativeHumidity() As Integer
            Get
                Return privateRelativeHumidity
            End Get
            Private Set(ByVal value As Integer)
                privateRelativeHumidity = value
            End Set
        End Property

        Public Sub New(ByVal timestamp As Date, ByVal temperature As Double, ByVal pressure As Integer, ByVal relativeHumidity As Integer)
            Me.Timestamp = timestamp
            Me.Temperature = temperature
            Me.Pressure = pressure
            Me.RelativeHumidity = relativeHumidity
        End Sub
    End Class

    Friend Interface WeatherProvider
        ReadOnly Property WeatherInfos() As IEnumerable(Of WeatherInfo)
    End Interface

    Friend Class XmlWeatherProvider
        Implements WeatherProvider

        Private filename As String
        Public Sub New(ByVal filename As String)
            If File.Exists(filename) Then
                Me.filename = filename
            Else
                Throw New Exception(String.Format("The '{0}' file does not exist.", filename))
            End If
        End Sub

        Private infos As Collection(Of WeatherInfo)
        Public ReadOnly Property WeatherInfos() As IEnumerable(Of WeatherInfo) Implements WeatherProvider.WeatherInfos
            Get
                If infos Is Nothing Then
                    Dim doc As XDocument = XDocument.Load(filename)

                    infos = New Collection(Of WeatherInfo)()
                    For Each element As XElement In doc.Element("WeatherData").Elements("WeatherInfo")
                        infos.Add(New WeatherInfo(timestamp:= Date.Parse(element.Element("Timestamp").Value, CultureInfo.InvariantCulture), temperature:= Double.Parse(element.Element("Temperature").Value, CultureInfo.InvariantCulture), pressure:= Integer.Parse(element.Element("Pressure").Value, CultureInfo.InvariantCulture), relativeHumidity:= Integer.Parse(element.Element("RelativeHumidity").Value, CultureInfo.InvariantCulture)))
                    Next element
                End If
                Return infos
            End Get
        End Property
    End Class
End Namespace

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the SeriesItemsSource property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also