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

Type arguments for method cannot be inferred from the usage

1 Answer 3161 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Bill
Top achievements
Rank 1
Bill asked on 23 Feb 2017, 03:53 PM

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

1 Answer, 1 is accepted

Sort by
0
Alex Hajigeorgieva
Telerik team
answered on 27 Feb 2017, 02:03 PM
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 (charts) and form elements.
Tags
Chart
Asked by
Bill
Top achievements
Rank 1
Answers by
Alex Hajigeorgieva
Telerik team
Share this question
or