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

15 posts, 0 answers
  1. Rahul Khinvasara
    Rahul Khinvasara avatar
    303 posts
    Member since:
    Aug 2007

    Posted 03 Apr 2012 Link to this post

    Hi,
          i am using telerik silverlight chart.i got exception "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" when tried to bind list to chart.
    When I use very small data it works fine. But for large number of records I get following error.

     RadChart1.ItemsSource = lst1;

    i also tried with changes suggested in the forums:
    ItemMapping mapping = new ItemMapping("Sales", DataPointMember.YValue, ChartAggregateFunction.Sum);
    mapping.FieldType = typeof(double)
    but with no luck.
    and i also noticed one thing that exception is occurring when result set is reaches more than 200

    Thanks.

  2. Manoj
    Manoj avatar
    2 posts
    Member since:
    Mar 2012

    Posted 04 Apr 2012 Link to this post

    I am also facing same problem.
  3. Manoj
    Manoj avatar
    2 posts
    Member since:
    Mar 2012

    Posted 05 Apr 2012 Link to this post

    Any Update? I don't want to create duplicate ticket for this.
  4. Petar Marchev
    Admin
    Petar Marchev avatar
    995 posts

    Posted 06 Apr 2012 Link to this post

    Hello Rahul,

    I will need more information in order to be able to help you. Are you using any group settings? Do you have any other item mappings?

    200 is the default sampling threshold. Here you can read about sampling. So I guess that the problem will disappear when you disable sampling (by setting the threshold to zero). But I am not sure if this is the right way to go. You can send us some code that reproduces this, with which I can create a new project here so I can test it and try to find where the problem is.

    Manoj, even though you are getting a similar error it does not mean your problem is the same. You can either follow this thread or you can open a new support ticket and attach a small project that reproduces this so we can investigate your case, too. 

    All the best,
    Petar Marchev
    the Telerik team
    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
  5. Pat
    Pat avatar
    4 posts
    Member since:
    Sep 2011

    Posted 24 Oct 2012 Link to this post

    I seem to be getting this error when trying to chart data with DateTime as x-axis. In particular when x-axis data points are not unique. Wile trying to debug this it also tells me the Average function is not defined for collections of DateTime.
  6. Petar Marchev
    Admin
    Petar Marchev avatar
    995 posts

    Posted 25 Oct 2012 Link to this post

    Pat, we will need more information in order to help you. I have attached a simple app that demonstrates a bar chart which uses DateTime along its x-axis and takes advantage of the Sampling feature. I will ask of you that you open a new thread in which you explain your set up in more details and if possible - attach a modified version of the attached example that reproduces this exception.

    Greetings,
    Petar Marchev
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  7. Mark
    Mark avatar
    12 posts
    Member since:
    Nov 2011

    Posted 15 Jan 2013 Link to this post

    I found that I have same problem when I try get values from dictionary. I cannot reproduce this error if I have same mapping/path in XAML

    string xPropertyName = "ReadTime";
    string yPropertyName = string.Format("Parameters[{0}].Value", item.Id /*int key value*/);
    //yPropertyName = "Parameters.TestValue"; //this path does not raise exception
     
    var seriesMapping = new SeriesMapping();
    seriesMapping.LegendLabel = item.Name;
    seriesMapping.ItemsSource = item.ParameterValueSets;
    seriesMapping.SeriesDefinition = lineSeriesDefinition;
    seriesMapping.ItemMappings.Add(new ItemMapping() { FieldName = xPropertyName, DataPointMember = DataPointMember.XValue });
    seriesMapping.ItemMappings.Add(new ItemMapping() { FieldName = yPropertyName, DataPointMember = DataPointMember.YValue });
     
    radChart.SeriesMappings.Add(seriesMapping);

  8. Mark
    Mark avatar
    12 posts
    Member since:
    Nov 2011

    Posted 17 Jan 2013 Link to this post

    I was wrong in my previous message. Problem is here property Parameters[0].Value return type is Syste.Object and not double/int/float/byte. So class ChartSamplingFunctions does not contain method like 

    public static object MemberFirst<TSource>(IEnumerable<TSource> source, Func<TSource, System.Object> selector)

    and method below just crushes with weird message.

    public override System.Linq.Expressions.Expression CreateAggregateExpression(System.Linq.Expressions.Expression enumerableExpression)
    {
        var builder = this.binding.CreateExpressionBuilder(enumerableExpression, this);
        return builder.CreateAggregateExpression();
    }

  9. Petar Marchev
    Admin
    Petar Marchev avatar
    995 posts

    Posted 18 Jan 2013 Link to this post

    Hello Mark,

    I apologize for not understanding you fully. Have you managed to resolve the issues you are experiencing or do you need assistance? You can open a new thread (so that we don't jam this thread) in which you can give us more details for your current app and if possible attach a small project that reproduces the issue, so that we can test and look for solutions. 

    Greetings,
    Petar Marchev
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  10. arun
    arun avatar
    2 posts
    Member since:
    Nov 2016

    Posted 04 Nov 2016 in reply to Manoj Link to this post

    I'm also facing same issue, when X-Axis has more than 200 data point or items; it is working fine with less than 200 data items on x-axis.
  11. arun
    arun avatar
    2 posts
    Member since:
    Nov 2016

    Posted 04 Nov 2016 in reply to Rahul Khinvasara Link to this post

    Hi,

    I'm getting below error when x-axis data item has 200 data point or items.  -

    An unhandled exception of type 'System.InvalidOperationException' occurred in WindowsBase.dll

    Additional information: 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.

  12. Dinko
    Admin
    Dinko avatar
    282 posts

    Posted 08 Nov 2016 Link to this post

    Hello arun,

    We weren't able to reproduce this exception when the RadChartView is populated with 200 items. That is why we would ask you to send us sample project from your application reproducing this exception. This way we can further investigate it directly on our side.

    Regards,
    Dinko
    Telerik by Progress
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  13. Patrick
    Patrick avatar
    2 posts
    Member since:
    Nov 2014

    Posted 30 Mar Link to this post

    I am experiencing the same issue if I add more than 200 data points to the series.  The error is thrown on the raiseproperty.  Works perfectly fine until the series contain more than 200 points.

    PropertyInfo[] properties = typeof(U_Chart.ChartData).GetProperties();

    foreach (PropertyInfo tmpP in properties)

     

     

    {

     

    if ((tmpP.Name != "SampleNo") & (tmpP.Name != "Condition"))

     

     

    {

     

    _ChartSeriesMapping = new SeriesMapping();

     

     

    _ChartSeriesMapping.LegendLabel = tmpP.Name;

     

    _ChartSeriesMapping.SeriesDefinition = new SplineSeriesDefinition();

     

     

    _ChartSeriesMapping.ItemsSource = Uchart.Chart_Data;

     

    _ChartSeriesMapping.ItemMappings.Add(new ItemMapping("SampleNo", DataPointMember.XValue));

    _ChartSeriesMapping.ItemMappings.Add(new ItemMapping(tmpP.Name, DataPointMember.YValue));

    _ChartSeriesMapping.SeriesDefinition.ShowItemLabels = false;

     

     

    _ChartSeries.Add(_ChartSeriesMapping);

    }

    }

     

    RaisePropertyChanged(nameof(Uchart));

    RaisePropertyChanged(nameof(Uchart.Chart_Data));

    RaisePropertyChanged(nameof(ChartSeries));

     

  14. Patrick
    Patrick avatar
    2 posts
    Member since:
    Nov 2014

    Posted 30 Mar in reply to Patrick Link to this post

    in the properties for the rad chart I can increase the sampling threshold and it will plot correctly but when I close and reopen the WPF window the chart shows and error (red x and text "Value cannot be null.  Parameter name: source").  Through the property panel I can click the "New" next to Sampling Settings and the error goes away and the radchart displays as expected in the WPF window.  Any ideas?

  15. Dinko
    Admin
    Dinko avatar
    282 posts

    Posted 04 Apr Link to this post

    Hi Patrick,

    Looking at the provided code we can see that you are using the old RadChart. Instead of the old RadChart I recommend you to use the new RadChartView suite that resolves many known issues and limitations of the old chart. The new components have better implementation and improved performance. You can read about the differences between the charts in the RadChart vs. RadChartView help article. The new chartview is actually a set of controls - RadCartesianChart, RadPieChart, RadPolarChart, ChartDataSource. It is much faster, very flexible, resolves almost all limitations the old control had and is pretty easy to set up. You can also take a look at the following resources:
    Regards,
    Dinko
    Telerik by Progress
    Try our brand new, jQuery-free Angular 2 components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Back to Top