This is a migrated thread and some comments may be shown as answers.

Databinding to custom business object fails

5 Answers 112 Views
Chart
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Andy
Top achievements
Rank 1
Andy asked on 12 Apr 2011, 12:33 PM
I'm following the the Getting started article "Create Data Bound Chart" to bind a silverlight chart to a collection of my custom business object.

<telerik:RadChart>
                            <telerikChart:RadChart.SeriesMappings>
                                <telerikCharting:SeriesMapping LegendLabel="Product Sales" ItemsSource="{Binding BusinessObject}">
                                    <telerikCharting:SeriesMapping.SeriesDefinition>
                                        <telerikCharting:SplineSeriesDefinition></telerikCharting:SplineSeriesDefinition>
                                    </telerikCharting:SeriesMapping.SeriesDefinition>
                                    <telerikCharting:SeriesMapping.ItemMappings>
                                        <telerikCharting:ItemMapping DataPointMember="XValue" FieldName="Timestamp"></telerikCharting:ItemMapping>
                                        <telerikCharting:ItemMapping DataPointMember="YValue" FieldName="Value"></telerikCharting:ItemMapping>
                                    </telerikCharting:SeriesMapping.ItemMappings>
                                </telerikCharting:SeriesMapping>
                            </telerikChart:RadChart.SeriesMappings>
                        </telerik:RadChart>

When the databinding happens I get an exception:

InvalidOperationException
No generic method 'Average' on type 'System.Linq.Enumerable' is compatible with the supplied type arguments and arguments. No type arguments should be provided if the method is non-generic.

I already tried different collection types and value types in my business object which doesn't change anything. Any ideas on what I'm doing wrong?

Thanks for your help

5 Answers, 1 is accepted

Sort by
0
Andy
Top achievements
Rank 1
answered on 12 Apr 2011, 02:00 PM
Still no luck. Here is some sample code from my business object:

   public class BusinessObject   {
        
       public System.DateTime Timestamp {
          get;
          set;
       }
 
      public uint Value {
          get;
          set;
       }
        
       public uint Hits {
          get;
          set;
       }
   }

The object I'm binding the radChart to is actually a List<BusinessObject>. (I already tried IList<>, ObservableCollection<>, ReadonlyObservableCollection<>, ...). I'm always getting the same exception when binding happens ...
0
Andy
Top achievements
Rank 1
answered on 12 Apr 2011, 03:16 PM
Finally I narrowed down my problem a bit. The data I want to show in the chart is received using a wcf service. If I return a locally created dummy collection instead of the real wcf received data everything works as expected. When returning the actual data I got from the wcf service, I get the exception. I even tried to copy all the objects to a newly created collection and use this one for binding but it fails, too.

Any ideas on how to solve this issue without copying all the data to new objects?
0
Yavor
Telerik team
answered on 14 Apr 2011, 07:08 AM
Hello Andy,

Based on the supplied information, it is hard to determine what is causing this exception. If the issue persists, you can open a formal support ticket, and send us a small working project, demonstrating your setup, and showing the unwanted behavior. We will debug it locally, and advise you further.
Additionally, you can locally verify where the exception occurs - in the service itself, or when passing the data to the chart control.

Kind regards,
Yavor
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Andy
Top achievements
Rank 1
answered on 14 Apr 2011, 03:25 PM
I solved this issue by myself after a lot of debugging and pure luck. Binding to an uint fails when the sampling feature of the control kicks in (more than 200 items in the data by default). This didn't happen with my test data.

Now I got the next problem: I need to bind to another property of my business object which is of type TimeSpan which seems to be impossible without strange workarounds (and of course fails with sampling enabled). I badly need to bind multiple members with different types and the appropriate labeling on the axis.

Disabeling sampling isn't a solution to my problem because I need to plot probably thousands of items.


0
Missing User
answered on 19 Apr 2011, 04:58 PM
Hello Andy,

Presently, RadChart does not support directly binding TimeSpan values out of the box.You can try to produce a double representation of TimeSpan values, so that the chart can be databound and displayed properly, but that might lead to various difficulties in different scenarios like displaying proper labels, etc.

Regards,
Polina
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
Chart
Asked by
Andy
Top achievements
Rank 1
Answers by
Andy
Top achievements
Rank 1
Yavor
Telerik team
Missing User
Share this question
or