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. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

SfChart support for ItemsSource of collection of ExpandoObject

Thread ID:

Created:

Updated:

Platform:

Replies:

118309 Feb 24,2015 01:41 PM UTC Jun 9,2017 03:51 PM UTC Windows Phone 3
loading
Tags: SfChart
aijaja
Asked On February 24, 2015 01:41 PM UTC

Hi,

I'm evaluating SfChart support for dynamic models as I don't have model definition at the design time.
For example, when I create ItemSource from ObservableCollection<ExpandoObject>, the chart does not display any data, it is just blank.
Here is the sample code I use:

                    dynamic item1 = new ExpandoObject();
                    item1.Amount = 10;
                    item1.Category = "Electronics";

                    dynamic item2 = new ExpandoObject();
                    item2.Amount = 20;
                    item2.Category = "Jewelry";
                   
                    var chartData = new ObservableCollection<ExpandoObject>{item1, item2};

                    Chart.Header = "Test";
                    Chart.PrimaryAxis = new CategoryAxis() { Header = "Category" };
                    Chart.SecondaryAxis = new NumericalAxis() { Header = "Amount" };

                    ColumnSeries series1 = new ColumnSeries();
                    series1.ItemsSource = chartData;
                    series1.XBindingPath = "Category";
                    series1.YBindingPath = "Amount";

                    Chart.Series.Add(series1);

Is there a way to make the chart populate with data when using ExpandoObject?

Rachel A [Syncfusion]
Replied On February 25, 2015 12:13 PM UTC

Hi Aija,

Thank you contacting Syncfusion support.

Presently we are not having the ExpandoObject binding support. We have logged this as feature request and it will be implemented in any of our upcoming volume releases.

Please let us know if you require any further assistance.

Thanks,

Rachel. A



Arman Balin
Replied On June 8, 2017 01:38 PM UTC

Hi, 

Has binding to expandoObject been implemented already?

Regards,
Arman

Durgadevi Selvaraj [Syncfusion]
Replied On June 9, 2017 03:51 PM UTC

 Hi Arman,

We don’t have ExpandoObject binding support in SfChart. You can achieve dynamic object support by using ICustomTypeDescriptor binding as shown in the below code,
 
public MainWindow() 
{ 
            InitializeComponent(); 
            Collection = new ObservableCollection<CustomData>();         
            var rnd = new Random();   
            for(int i =0;i<10;i++) 
            { 
                customData = new CustomData(); 
                customData.SetValue("Category", i); 
                customData.SetValue("Amount", rnd.Next(100, 1000)); 
                collection.Add(customData); 
            } 
 
                SplineSeries ss = new SplineSeries(); 
                ss.XBindingPath = "Category"; 
                ss.YBindingPath = "Amount"; 
                ss.Label = "itm"; 
                ss.EnableAnimation = true; 
                ss.ShowTooltip = true; 
                ss.ItemsSource = Collection; 
                chart.Series.Add(ss);      
} 
 

We have prepared the WPF sample based on this for your reference and please downloaded from the below link,

Sample: DynamicDescriptor_Sample


Regards,
 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;