How to pass model in Array in Group-stacked Bars

2 posts, 0 answers
  1. saroj
    saroj avatar
    39 posts
    Member since:
    Oct 2011

    Posted 06 Nov 2012 Link to this post

    Hi,

    Below is my code and i am trying to pass model inside array but i am always getting null value even there is data, can anyone help me how to pass model inside array.

    ------Partial view----
    @(Html.Kendo().Chart<DashboardRepairMaintenance>()
            .Name("chart3")
            .Title("Repair and maintenance status")
            .HtmlAttributes(new { style = "width: 550px; height: 170px; border: transparent; margin-left:5px; " })  
            .DataSource(dataSource => dataSource
            .Read(read => read.Action("_DashboardRepairMaintenance", "DashboardRepairMaintenance"))
            )
             .Series(series =>
                    {
                        series
     .Column(new int[] {(int)Model.FirstOrDefault().ACTIVE , (int)Model.FirstOrDefault().PENDING ,(int)Model.FirstOrDefault().CARFWD }
    )
             .Name("Active").Stack("Active");
                 

                    })
                    .CategoryAxis(axis => axis
                        .Categories(model => model.DAYS)
                    )
                    .ValueAxis(axis => axis.Numeric()
                        .Labels(labels => labels.Format("{0:N0}"))
                        .MajorUnit(2)
                         
                    )
                    .Tooltip(tooltip => tooltip
                        .Visible(true)
                        .Format("{0:N0}")
                    )
                ) 


    ------Controller---------------

      public ActionResult _DashboardRepairMaintenance()
            {
               return Json(_dashboardRepository.GetRepairMaintenance());
            }

    --------Model class-------
     public class DashboardRepairMaintenance
        {
            public string DAYS { get; set; }
            public int? ACTIVE { get; set; }
            public int? PENDING { get; set; }
            public int? CARFWD { get; set; }
        }

  2. Daniel
    Admin
    Daniel avatar
    2219 posts

    Posted 12 Nov 2012 Link to this post

    Hello Saroj,

    I am not sure if I understand exactly what is the needed functionality. Is there a model passed to the View from which the "ACTIVE", "PENDING" and "CARFWD" values to taken from? If there is not and you rely on the data to be loaded with the Ajax request, then you should just define the field names for the series from which the Chart should take the values.

    Regards,
    Daniel
    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Back to Top