Bhavna Chaudhri

Bhavna Chaudhri

  • NA
  • 529
  • 20.7k

Kendo Chart in MVC not working.

Oct 22 2020 10:14 AM
These are my code
  1. <div class="demo-section k-content wide">  
  2.            @(Html.Kendo().Chart(Model)  
  3.                  .Name("chart22")  
  4.                  .Title("Bar Chart")  
  5.                                      .DataSource(dataSource =>  
  6.                                          {  
  7.                                              dataSource.Read(read => read.Action("AcccountNameBind""Account"));  
  8.                                              // ds.Filter(filter => filter.Add(model => model.User_Email).IsEqualTo(User_Email));  
  9.   
  10.                                          })  
  11.            .SeriesColors(new string[] { "#03a9f4""#ff9800""#fad84a""#4caf50" })  
  12.                  .Series(series =>  
  13.                  {  
  14.                      series.Bar(  
  15.                          model => model.AccountId,  
  16.                       model => model.AccountName  
  17.                      );  
  18.                  })                              //.Tooltip(tooltip => tooltip.  
  19.                  //                      Template("${ User_Email } - ${ Userid }%").Visible(true)  
  20.                  //  )  
  21.                                           .CategoryAxis(axis => axis  
  22.                                            .Name("series-axis")  
  23.                                            .Line(line => line.Visible(false))  
  24.                                            )  
  25.                            .CategoryAxis(axis => axis  
  26.                            .Name("label-axis")  
  27.                                    .Categories(m => m.AccountName)  
  28.                                )  
  29.                            .ValueAxis(axis => axis  
  30.                            .Numeric()  
  31.                                    .Labels(labels => labels.Format("{0}"))  
  32.                                    .AxisCrossingValue(0, int.MinValue)  
  33.                            )  
  34.                                      
  35.            )  
  36.   
  37.        </div>  
  38.   
  39.   
  40. public ActionResult AcccountNameBind()  
  41.        {  
  42.            try  
  43.            {  
  44.                var data = GetAccountData().ToList();  
  45.                var query = (from a in data  
  46.                             select new  
  47.                             {  
  48.                                 a.AccountId,  
  49.                                 a.AccountName,  
  50.                                  
  51.                             }).ToList();  
  52.   
  53.                if (query.Count > 0)  
  54.                {  
  55.                    return Json(query, JsonRequestBehavior.AllowGet);  
  56.                }  
  57.                else  
  58.                {  
  59.                    return null;  
  60.                }  
  61.            }  
  62.            catch (Exception ex)  
  63.            {  
  64.                return Json(ex.Message);  
  65.            }  
  66.        }  
 

Answers (3)