ComponentOne Chart for WPF and Silverlight
Chart for WPF and Silverlight / Chart Features / Data Binding / Collection of Values
In This Topic
    Collection of Values
    In This Topic

    You can use several methods for delivering data to the chart. One method is binding a collection of values using the ValuesSource property.

    Any collection of numerical values that support IEnumerable interface can be used as a data source for the data series. Each data series class has appropriate properties for data binding. For example, the DataSeries class uses the ValuesSource property for data binding.

    To bind the collection of values to the DataSeries you can first specify the binding source as an array of double like the following:

    Copy Code
    <!—Binding Source -->
    <x:Array xmlns:sys="clr-namespace:System;assembly=mscorlib"
           x:Key="array" Type="sys:Double">

    To pass the array to the data series use the following markup:

    Copy Code
    <!—Binding Target -->
    <c1chart:C1Chart Name="chart">
         <c1chart:ChartData ItemsSource="{Binding Source={StaticResource array}, Path=Items}">
           <c1chart:DataSeries ValuesSource="{Binding Source={StaticResource array},Path=Items}"/>

    It is possible to specify the data values as an attribute, the values should be separated with spaces, for example:

    Copy Code
    <c1chart:DataSeries Values="1 2 9 16"/>

    The preceding markup declaratively binds the ValuesSource property of a DataSeries to the Items property of a DataSeries object which is given a value of "1 2 9 16".


    See Also