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

Chart - Local Data Error

5 Answers 43 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Allan
Top achievements
Rank 1
Allan asked on 08 Feb 2016, 04:28 PM

Hello,

I have a donut chart that uses local data and I'm getting an error on my series of:

Cannot convert lambda expression to type 'System.Collections.IEnumerable' because it is not a delegate type

The chart is being used in a partial view.  Here is my source code.

Partial View

@model IEnumerable<MyProject.ViewModels.UtilisationViewModel> 
<div class="row">
    <div class="col-md-6">
        <div class="demo-section k-content wide">
        @(Html.Kendo().Chart(Model)
            .Name("chart")
            .Title("Utilisation")
            .Legend(legend => legend
            .Position(ChartLegendPosition.Bottom))       
        .Series(series =>
        {
            series.Donut(
                model => model.ahts
            );
          })
        )
        </div>
    </div>
</div>

The ViewModel

using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Data.Entity;
using System.Web;
using Spoton_Areas_Test.Models;
 
namespace MyProject.ViewModels
{
    public class UtilisationViewModel
    {
        public int idx_index { get; set; }
        public Nullable<System.DateTime> applies_date { get; set; }
        public Nullable<decimal> ahts { get; set; }
        public Nullable<decimal> psv { get; set; }
        public Nullable<int> region_idx { get; set; }
        public string region_name { get; set; }
    }
}

Can anyone point me in the direction of what is going wrong? 

 

Many thanks

5 Answers, 1 is accepted

Sort by
0
Helen
Telerik team
answered on 09 Feb 2016, 12:41 PM
Hello Allan,

Try with the following declaration:

@model IEnumerable<MyProject.ViewModels.UtilisationViewModel>
<div class="row">
    <div class="col-md-6">
        <div class="demo-section k-content wide">
            @(Html.Kendo().Chart(Model)
                    .Name("chart")
                    .Title("Utilisation")
                    .Legend(legend => legend
                    .Position(ChartLegendPosition.Bottom))
                             .Series(series =>
                             {
                                 series.Donut(
                                     model => model.ahts,
                                     null
                                     
                                 );
                             })
             
            )
        </div>
    </div>
</div>




Regards,
Helen
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Allan
Top achievements
Rank 1
answered on 09 Feb 2016, 01:44 PM
Thanks for this Helen, this cured the error message althouh the chart doesn't show at all.
0
Helen
Telerik team
answered on 10 Feb 2016, 07:56 AM
Hi Allan,

How exactly do you fill chart with data in the controller? You may open a support ticket and send us your complete project to examine it locally.

Regards,
Helen
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Mark
Top achievements
Rank 1
Veteran
answered on 02 Mar 2016, 05:00 PM
Any resolution here? Having same issue.
0
T. Tsonev
Telerik team
answered on 04 Mar 2016, 12:52 PM
Hello,

The donut series expect the model to define a value and category for each data point. See the code from the demo.

We can reduce it to:
    Html.Kendo().Chart(Model)
        .Name("chart")
        .Series(series =>
        {
            series.Donut(
                model => model.Percentage,
                model => model.Source
            );
        })
        ...

I hope this helps.

Regards,
T. Tsonev
Telerik
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 Feedback Portal and vote to affect the priority of the items
Tags
Chart
Asked by
Allan
Top achievements
Rank 1
Answers by
Helen
Telerik team
Allan
Top achievements
Rank 1
Mark
Top achievements
Rank 1
Veteran
T. Tsonev
Telerik team
Share this question
or