- Home
- Forum
- Windows Phone
- SfChart support for ItemsSource of collection of ExpandoObject
SfChart support for ItemsSource of collection of ExpandoObject
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?
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?
SIGN IN To post a reply.
3 Replies
RA
Rachel A
Syncfusion Team
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
AB
Arman Balin
June 8, 2017 01:38 PM UTC
Hi,
Has binding to expandoObject been implemented already?
Regards,
Arman
DS
Durgadevi Selvaraj
Syncfusion Team
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,
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,
SIGN IN To post a reply.
- 3 Replies
- 4 Participants
-
AI aijaja
- Feb 24, 2015 01:41 PM UTC
- Jun 9, 2017 03:51 PM UTC