Click here to Skip to main content
15,896,207 members

How To bind Data to pie-chart from edmx file using jquery json

shakil4u asked:

Open original thread
Hi all i am working on Piecharts using jquery json in mvc3
Here i had created my models and controllers & view when i am exicuting it is taking the values in controllers but in case of vies not displayinng the pie chart could u plz chek it and plz help me to do this work
thank in advance
here my models :
=====================
C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data.Entity;

namespace JqueryCharts.Models
{
    public class PiechartModel:DbContext
    {
       public static List<PiechartModel> Employeelist { get; set; }

        public Int16 EmployeeId { get; set; }
        public string EmployeeName { get; set; }
        public string EmployeeEmailId { get; set; }
        public string GroupName { get; set; }
        public string EmployeePassword { get; set; }
        public List<PiechartModel> List { get; set; } 

    }
}

and hers are  my controllers :
======================================
<pre>using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using JqueryCharts.Models;
using System.Data.SqlClient;

namespace JqueryCharts.Controllers
{
    public class PiechartsController : Controller
    {
        //
        // GET: /Piecharts/
      public BugtrackerNewEntities1 db = new BugtrackerNewEntities1();

        public ActionResult Index()
        {
            return View();
        }


        public JsonResult GetData()
        {
            
            var ViewEmployelist = db.EmployeeDetails.ToList<EmployeeDetail>().Select(e =>
           new
           {
               
               EmployeId = e.EmployeId,
               EmployeeName = e.EmployeeName
           }).ToList();
            return Json(ViewEmployelist, JsonRequestBehavior.AllowGet);
        }
    }
}





and here my View page
=============================
<pre><%@ Page Language="C#" Inherits="System.Web.Mvc.ViewPage<JqueryCharts.Models.PiechartModel>" %>
<script src="../../Scripts/highcharts.src.js" type="text/javascript"></script>
<script src="../../Scripts/highcharts-more.js" type="text/javascript"></script>
<script src="../../Scripts/highcharts.js" type="text/javascript"></script>
<script src="../../Scripts/jquery-1.5.1.js" type="text/javascript"></script>
<script src="../../Scripts/modernizr-1.7.js" type="text/javascript"></script>
<script src="../../Scripts/jquery-ui-1.8.11.js" type="text/javascript"></script>
<!DOCTYPE html>

<html>
<head runat="server">
    <title>Index</title>

      <script type="text/javascript">
          $(function () {
          alert("1")
              $.getJSON('<%= Url.Action("GetData","Piecharts") %>', {}, function (data) {
                  var json = data;
                  var jsondata = [];
                  for (var i in json) {
                      // var serie = new Array(json[i].Projects, json[i].Bugs);
                      jsondata.push([json[i].EmployeId, json[i].EmployeeName]);
                      alert("1")
                  }
                  var chart = new Highcharts.Chart({
                      chart: {
                          renderTo: 'container',
                          type: 'pie',
                          plotBackgroundColor: null,
                          plotBorderWidth: null,
                          plotShadow: false
                      },
                      title: {
                          text: 'Resource Reports of BugTracker'
                         
                      },

                      plotOptions: {
                          pie: {
                              showInLegend: true,
                              animation: false,
                              allowPointSelect: true,
                              cursor: 'pointer'
                          }
                      },
                      legend: {
                          enabled: true
                      },
                      series: [{
                          type: 'pie',
                          data: jsondata
                      }]
                  });
              });
          });
          alert("1")
    </script>
</head>
<body>
    <div id="container" style="min-width: 400px; height: 400px; margin: 0 auto">
    
    </div>
</body>
</html>




could u plz help to do this work it is not displaying data in ives page
Thank in Advance
Tags: jQuery, MVC3, JSON

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900