Chart - Local Data Error

6 posts, 0 answers
  1. Allan
    Allan avatar
    34 posts
    Member since:
    Aug 2015

    Posted 08 Feb Link to this post

    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

  2. Helen
    Admin
    Helen avatar
    1052 posts

    Posted 09 Feb Link to this post

    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
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Allan
    Allan avatar
    34 posts
    Member since:
    Aug 2015

    Posted 09 Feb in reply to Helen Link to this post

    Thanks for this Helen, this cured the error message althouh the chart doesn't show at all.
  5. Helen
    Admin
    Helen avatar
    1052 posts

    Posted 10 Feb Link to this post

    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
  6. Mark
    Mark avatar
    4 posts
    Member since:
    Apr 2015

    Posted 02 Mar in reply to Helen Link to this post

    Any resolution here? Having same issue.
  7. T. Tsonev
    Admin
    T. Tsonev avatar
    2772 posts

    Posted 04 Mar Link to this post

    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
Back to Top
UI for ASP.NET MVC is VS 2017 Ready