Bind chart data from IEnumberable property of local data

2 posts, 0 answers
  1. Joan
    Joan avatar
    5 posts
    Member since:
    Apr 2012

    Posted 08 Oct 2014 Link to this post

    I am creating a bubble chart by using MVC and would like to bind this chart from local data as the example in the link http://demos.telerik.com/aspnet-mvc/bubble-charts/local-data-binding.

    The model I use is slightly different from the example.  I have a view model object,BubbleChartModel,contains a IEnumberable<MVCSample.Data.PGDataBySupplier> property called "DataPoints".
    When I tried to bind the bubbles to this IEnumberable<MVCSample.Data.PGDataBySupplier> property, I received the error of

    The model item passed into the dictionary is of type 'System.Collections.Generic.List`1[MVCSample.Data.PGDataBySupplier]', but this dictionary requires a model item of type 'MVCSample.Models.BubbleChartModel'.

    I am wondering if my approach is supported by Telerik. If not, is there any workaround?


    Following is my code:

    @model MVCSample.Models.BubbleChartModel
    <div class="chart-wrapper">
    @(Html.Kendo().Chart(Model.DataPoints)
    .Name("chart")
    .Series(series =>
    {
    series.Bubble(
    model => model.PercentSavingsLow,
    model => model.PotentialSavingsAvg,
    model => model.TotalSpend,
    model => model.ProviderShortName,
    model => model.MemberStatECOLOR,
    model => model.DisplayLegend,
    model => model.ProviderShortName


    ); 
                         }
    )
    )


    )
  2. Hristo Germanov
    Admin
    Hristo Germanov avatar
    703 posts

    Posted 10 Oct 2014 Link to this post

    Hi Joan,

    This error is not related with Kendo UI Chart. The model for your view must be the same as the dictionary that you pass. If you pass IEnumberable<MVCSample.Data.PGDataBySupplier> the model must be @model IEnumberable<MVCSample.Data.PGDataBySupplier>

    Regards,
    Hristo Germanov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
Back to Top