Binding line series to Array/List

4 posts, 0 answers
  1. Andrey
    Andrey avatar
    8 posts
    Member since:
    Aug 2012

    Posted 30 Aug 2012 Link to this post

    Hi, 
    I have my model described like: 
        public class PerformanceChartSeriesModel_2
        {
            public string[] Date { get; set; }
            public double[] P1 { get; set; }
        }

    Now, I chart :
        @(Html.Kendo().Chart<PerformanceChartSeriesModel_2>()
            .Name("chartPerformance")        
            .Legend(legend => legend
            .Position(ChartLegendPosition.Bottom)
            )
            .DataSource(ds => ds
                .Read(read => read.Action("PerformanceChartData", "Performance").Data("performanceChartData"))
            )
           .Series(series =>
           {
               series.Line(p=>p.P1);                      
           })
                   .CategoryAxis(axis =>
                   {
                       axis.Categories(l => l.Date);
                   })   

    Neither series nor categories pick up values, series actually behave in a strange way drawing only one point.
    Could you tell what is wrong, or how can I work with such model.
    Thanks.
  2. Hristo Germanov
    Admin
    Hristo Germanov avatar
    703 posts

    Posted 03 Sep 2012 Link to this post

    Hello Andrey Dorokhov,

    As you can see in our offline example line-charts/remote-data you need to pass an array with objects. Then you need to specify the bindable field.

    If you want to pass an array to the series you can do this with ViewBag or Model.Something.

    Kind regards,
    Hristo Germanov
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Attila
    Attila avatar
    16 posts
    Member since:
    Oct 2016

    Posted 06 Oct in reply to Andrey Link to this post

    Hi!

    Can you show me the PerformanceChartData action of your Performance controller? I'm facing similar problem and try to find some solution... My action returns with Json(res.ToDataSourceResult(request)), where res is IEnumerable<MyClass>.

     

    Many thanks

  4. Stefan
    Admin
    Stefan avatar
    1147 posts

    Posted 11 Oct Link to this post

    Hello, Attila,

    In general, the Action should return an array of objects as Hristo suggested.

    Please inspect the response from the server when the data is returned with "Json(res.ToDataSourceResult(request))"

    The expected result can be observed in our demo:

    http://demos.telerik.com/aspnet-mvc/line-charts/remote-data-binding

    Please have in mind that this is an old thread and there is a big chance Andrey to not have the code available as this was 5 years ago.

    If there is a specific issue, please provide more details or runnable example and we will gladly assist.

    Regards,
    Stefan
    Progress Telerik
    Try our brand new, jQuery-free Angular 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