Bind xvalues and yvalues independently

Hello, 

Is there a way to bind directly to the xvalues and yvalues of a FastLineSeries? I would like to bind two distinct arrays of double, let's say time and signal directly to the x and y lists. The reason for this is performance since in my case I do a lot of frequent signal shifts and just one array has to change at a time.
Can the FastLineSeries be modified to use float instead of double?

1 Reply 1 reply marked as answer

YP Yuvaraj Palanisamy Syncfusion Team May 3, 2021 12:35 PM UTC

Hi Emanuel, 
 
Greetings from Syncfusion. 
 
Currently SfChart supports bind the collection of data to the ItemsSource property of FastLineSeries in WPF SfChart and XBindingPath & YBindingPath are bound the corresponding property name of the DataPoint collection. And we can’t bind directly ‘X’ and ‘Y’ list.  
 
Binding of Array Property :  
 
We can achieve your requirement of binding array of integers to the series by binding the index of array property to the XBindingPath and YBindingPath as shown in the below code snippet,  
 
MainWindow.Xaml:  
  <chart:LineSeries ItemsSource="{Binding Collection}"  
                                XBindingPath="XValue[0]" YBindingPath="YValue[1]"                                />  
 
Model.Cs:  
 
public class Model  
    {  
        public double[] XValue { getset; }  
        public double[] YValue { getset; }      
    }  
  
ViewModel.Cs  
public class ViewModel  
{  
        public ObservableCollection<Model> Collection { getset; }  
   public ViewModel()  
   {  
            Collection = new ObservableCollection<Model>();  
  
            Collection.Add(new Model() { XValue = new double[] { 0, 20 }, YValue =new double[] { 8, 15, 22 }});  
            Collection.Add(new Model() { XValue = new double[] { 1, 21 }, YValue = new double[] { 5.5,13,24 }});  
            Collection.Add(new Model() { XValue = new double[] { 2, 22 }, YValue = new double[] { 3, 16, 21 }});  
            Collection.Add(new Model() { XValue = new double[] { 3, 23 }, YValue = new double[] { 9, 18, 25 }});  
            Collection.Add(new Model() { XValue = new double[] { 4, 24 }, YValue = new double[] { 6, 12, 23 }});  
            Collection.Add(new Model() { XValue = new double[] { 5, 25 }, YValue = new double[] { 7, 14, 27 }});  
    }  
}  
 
  
Setting the Array values to the property:  
 
Also we can set x and y  array values to the property directly as shown in the below code snippet,  
 
Model.Cs:  
public class Model  
    {  
        
        public string XValue { getset; }  
        public double YValue { getset; }             
    }  


 
ViewModel.Cs  
public class ViewModel  
    {  
        public ObservableCollection<Model> Collection { getset; }  
        string[] XValue = { "Apple""Orange""Grapes""Banana""Cherry" };  
        double[] DataSeries = { 20, 30, 50, 10, 60 };  
        public ViewModel()  
        {  
            Collection = new ObservableCollection<Model>();  
  
            var items = DataSeries.ToList();  
            for(int i =0;i<items.Count;i++)  
            {  
                Collection.Add(new Model() { XValue = XValue[i], YValue = items[i] });  
            }  
  
             
        }  
    }  
 
MainWindow.Xaml:  
<chart:LineSeries ItemsSource="{Binding Collection}"   
                                XBindingPath="XValue" YBindingPath="YValue"  
                                >  
 
For more details, please find the below KB document. 
 
And also, FastLineSeries have rendered with float and double datapoint value and it’s convert the double type for rendering.  
 
Regards, 
Yuvaraj. 


Marked as answer
Loader.
Up arrow icon