Type arguments for method cannot be inferred from the usage

2 posts, 0 answers
  1. Bill
    Bill avatar
    1 posts
    Member since:
    Nov 2007

    Posted 23 Feb Link to this post

    I am trying to create a line chart binding to grouped data, but when I use the code below I get a "CS0411: The type arguments for method 'Kendo.Mvc.UI.Fluent.DataSourceGroupDescriptorFactory<object>.Add<TValue>(System.Linq.Expressions.Expression<System.Func<object,TValue>>)' cannot be inferred from the usage. Try specifying the type arguments explicitly." error when I run it and in Visual Studio it underlines the ".Add" for group.Add and all the property names of the model (see attached screenshot).

    Any ideas why?

    View:

    @model IEnumerable<IntegrationLoader.Models.Application>
     
    @(Html.Kendo().Chart()
            .Name("chart")
            .Title("Fatal Exceptions In Last 10 Days")
            .Legend(legend => legend
                .Position(ChartLegendPosition.Bottom)
            )
            .ChartArea(chartArea => chartArea
                .Background("transparent")
            )
            .SeriesDefaults(seriesDefaults =>
                seriesDefaults.Line().Style(ChartLineStyle.Smooth)
            )
            .DataSource(dataSource => dataSource
                .Read(read => read.Action("AppCounts_Read", "LogEntries"))
                .Group(group => group.Add(model => model.Name))
                .Sort(sort => sort.Add(model => model.Day).Ascending())
            )
            .Series(series =>
            {
                series.Line(model => model.FatalCount)
                    .Name("#= group.value # (Count)");
            })
            .CategoryAxis(axis => axis
                .Categories(model => model.Day)
                .Labels(labels => labels.Format("yyyyMMdd"))
            )
            .ValueAxis(axis => axis
                .Numeric().Labels(labels => labels.Format("{0}"))
                .Line(line => line.Visible(false))
                .AxisCrossingValue(-10)
                .Title("Errors")
            )
            .Tooltip(tooltip => tooltip
                .Visible(true)
                .Format("{0}")
            )
    )

     

    Thanks,
    Bill

  2. Alex Hajigeorgieva
    Admin
    Alex Hajigeorgieva avatar
    290 posts

    Posted 27 Feb Link to this post

    Hello Bill,

    The error which is enclosed in this ticket most likely occurs because the Kendo UI Chart has no knowledge of the model. 

    If you change the first line as below, it should work as expected:

    @(Html.Kendo().Chart<IntegrationLoader.Models.Application>()

    Documentation reference: 

    http://docs.telerik.com/aspnet-mvc/helpers/chart/ajax-binding#configuration-Configure

    Let me know how you get on.

    Kind Regards,
    Alex Hajigeorgieva
    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