We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Cannot bind a RangeColumnSeries in c#

I am using the following code to set up a rangecolumnseries object.


            RangeColumnSeries1.ItemsSource = this.MySourceData;
            RangeColumnSeries1.XBindingPath = "Name";
            RangeColumnSeries1.High = "High";
            RangeColumnSeries1.Low = "Low";
          


The MySourceData object is a collection of records that have public double properties for High and Low.  After the code runs the HighValues property has a count of 0 despite there being values in MySourceData. So the graph is empty. 

How do I programmatically get my High/Low values into the Chart Object.

Thanks folks.



3 Replies

DA Devi Aruna Maharasi Murugan Syncfusion Team March 17, 2017 09:05 AM UTC

Dear Customer, 
  
Thanks for contacting Syncfusion Support. 
  
We have prepared a demo sample by creating RangeColumnSeries in code behind. Please find the code snippet, 
 
SfChart chart = new SfChart(); 
RangeColumnSeries rangeSeries = new RangeColumnSeries(); 
rangeSeries.ItemsSource = new ViewModel().Collection; 
rangeSeries.XBindingPath = "XValue"; 
rangeSeries.High = "High"; 
rangeSeries.Low = "Low"; 
chart.Series.Add(rangeSeries); 
 
 
ViewModel.CS 
 
public class ViewModel 
{ 
    public ObservableCollection<Model> Collection { get; set; } 
    public ViewModel() 
     { 
       Collection = new ObservableCollection<Model>(); 
 
       Collection.Add(new Model() { XValue = 1, High = 604, Low = 595 }); 
       Collection.Add(new Model() { XValue = 2, High = 602, Low = 595 }); 
       Collection.Add(new Model() { XValue = 3, High = 608, Low = 594 }); 
       Collection.Add(new Model() { XValue = 4, High = 619, Low = 604 }); 
       Collection.Add(new Model() { XValue = 5, High = 608, Low = 594 }); 
     } 
} 
 
 
  
The demo sample can be downloaded from below link, 
  
  
Please find the output screenshot, 
 
 
  
Regards, 
Devi 






FM fmgstocks March 18, 2017 02:04 PM UTC

Thanks Devi,

My code was the same as far as I can tell except I created the chart in XAML.  Anyway, when I do everything in code following your example it works.  Much appreciated.




DA Devi Aruna Maharasi Murugan Syncfusion Team March 20, 2017 04:01 AM UTC

Dear Customer, 
  
Thanks for your update. 
  
Please let us know, if you need any further assistance on this. 
  
Regards, 
Devi 


Loader.
Up arrow icon