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

How to pass model in Array in Group-stacked Bars

1 Answer 44 Views
Charts
This is a migrated thread and some comments may be shown as answers.
saroj
Top achievements
Rank 1
saroj asked on 07 Nov 2012, 05:44 AM
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; }
    }

1 Answer, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 12 Nov 2012, 10:22 AM
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!
Tags
Charts
Asked by
saroj
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Share this question
or