highcharts using entity framework

Last Reply 8 months ago By dharmendr

Posted 8 months ago

i try to use high charts to get result from database usig store procedure i use entity farmework and also i add properties

i get result on x axis but now i try to get series

i use this method

[WebMethod]
public static string jqufunc()
{
    string res = "[";
  ProjectdbEntities a = new ProjectdbEntities();

  var b = a.Catg_type;
    foreach (var c in b)
    {

        res += "'" + c.Catg_type1 + "',";
    }
    res = res.Substring(0, res.Length - 1);
    res += "]";
    return res;

}

to fetch result on x axis

then i try this

<script type="text/javascript">

    $(document).ready(function () {

    var webmethod = "WebForm1.aspx/jqufunc";

    $.ajax({
            type: "POST",
            url: webmethod,
            contentType: "application/json;charset=utf-8",
            dataType: "json",
            success: function (response) {
                alert(response.d);

                //Start

                chart = new Highcharts.Chart({
       chart: {
                type: 'bar',
                renderTo: 'container',

            }, 
       title: {  
         text: 'Studentinfo'  
       },  

      xAxis: {  
          categories:  eval(response.d)


       },  

       yAxis: {
                title: {
                    text: 'Figures'
                }
            },

       plotOptions: {  
          column: {  
            pointPadding: 0.2,  
            borderWidth: 0  
          }  
        },
    series: [{
        name: 'Pentinum 4',
        data: [1, 0, 4]
    }, {
        name: 'Pentinum 3',
        data: [5, 7, 3]
    }, {
        name: 'Core i7',
        data: [6, 3, 4]
    }] 
      });  

i hard code this series this series not get from database but now i get series from database please check image

chart image. in this image what i want to get 

i get this result from sp

Catg_type        Prog_name  total_students
Management        BBA              3
Finance           BS-AF             4
ComputerScience   BSCS              3
Management         MBA              2
Finance            MBA-Finance      2
ComputerScience    MS-IT             2
Results 1 - 5 of 9 12

Posted 8 months ago

this is not helpful for me :( 


Posted 8 months ago

Please share your complete code


Posted 8 months ago

above is my completed code 

 

and other code is 

 

 

//------------------------------------------------------------------------------
// <auto-generated>
//    This code was generated from a template.
//
//    Manual changes to this file may cause unexpected behavior in your application.
//    Manual changes to this file will be overwritten if the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------

using System;
using System.ComponentModel;
using System.Data.EntityClient;
using System.Data.Objects;
using System.Data.Objects.DataClasses;
using System.Linq;
using System.Runtime.Serialization;
using System.Xml.Serialization;

[assembly: EdmSchemaAttribute()]
namespace WebApplication1
{
    #region Contexts
    
    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    public partial class ProjectdbEntities : ObjectContext
    {
        #region Constructors
    
        /// <summary>
        /// Initializes a new ProjectdbEntities object using the connection string found in the 'ProjectdbEntities' section of the application configuration file.
        /// </summary>
        public ProjectdbEntities() : base("name=ProjectdbEntities", "ProjectdbEntities")
        {
            this.ContextOptions.LazyLoadingEnabled = true;
            OnContextCreated();
        }
    
        /// <summary>
        /// Initialize a new ProjectdbEntities object.
        /// </summary>
        public ProjectdbEntities(string connectionString) : base(connectionString, "ProjectdbEntities")
        {
            this.ContextOptions.LazyLoadingEnabled = true;
            OnContextCreated();
        }
    
        /// <summary>
        /// Initialize a new ProjectdbEntities object.
        /// </summary>
        public ProjectdbEntities(EntityConnection connection) : base(connection, "ProjectdbEntities")
        {
            this.ContextOptions.LazyLoadingEnabled = true;
            OnContextCreated();
        }
    
        #endregion
    
        #region Partial Methods
    
        partial void OnContextCreated();
    
        #endregion
    
        #region ObjectSet Properties
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        public ObjectSet<Catg_type> Catg_type
        {
            get
            {
                if ((_Catg_type == null))
                {
                    _Catg_type = base.CreateObjectSet<Catg_type>("Catg_type");
                }
                return _Catg_type;
            }
        }
        private ObjectSet<Catg_type> _Catg_type;
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        public ObjectSet<Std_info> Std_info
        {
            get
            {
                if ((_Std_info == null))
                {
                    _Std_info = base.CreateObjectSet<Std_info>("Std_info");
                }
                return _Std_info;
            }
        }
        private ObjectSet<Std_info> _Std_info;
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        public ObjectSet<Program_type> Program_type
        {
            get
            {
                if ((_Program_type == null))
                {
                    _Program_type = base.CreateObjectSet<Program_type>("Program_type");
                }
                return _Program_type;
            }
        }
        private ObjectSet<Program_type> _Program_type;

        #endregion

        #region AddTo Methods
    
        /// <summary>
        /// Deprecated Method for adding a new object to the Catg_type EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
        /// </summary>
        public void AddToCatg_type(Catg_type catg_type)
        {
            base.AddObject("Catg_type", catg_type);
        }
    
        /// <summary>
        /// Deprecated Method for adding a new object to the Std_info EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
        /// </summary>
        public void AddToStd_info(Std_info std_info)
        {
            base.AddObject("Std_info", std_info);
        }
    
        /// <summary>
        /// Deprecated Method for adding a new object to the Program_type EntitySet. Consider using the .Add method of the associated ObjectSet&lt;T&gt; property instead.
        /// </summary>
        public void AddToProgram_type(Program_type program_type)
        {
            base.AddObject("Program_type", program_type);
        }

        #endregion

        #region Function Imports
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        public int spstdinfo()
        {
            return base.ExecuteFunction("spstdinfo");
        }

        #endregion

    }

    #endregion

    #region Entities
    
    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    [EdmEntityTypeAttribute(NamespaceName="ProjectdbModel", Name="Catg_type")]
    [Serializable()]
    [DataContractAttribute(IsReference=true)]
    public partial class Catg_type : EntityObject
    {
        #region Factory Method
    
        /// <summary>
        /// Create a new Catg_type object.
        /// </summary>
        /// <param name="catg_id">Initial value of the Catg_id property.</param>
        public static Catg_type CreateCatg_type(global::System.Int32 catg_id)
        {
            Catg_type catg_type = new Catg_type();
            catg_type.Catg_id = catg_id;
            return catg_type;
        }

        #endregion

        #region Primitive Properties
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.Int32 Catg_id
        {
            get
            {
                return _Catg_id;
            }
            set
            {
                if (_Catg_id != value)
                {
                    OnCatg_idChanging(value);
                    ReportPropertyChanging("Catg_id");
                    _Catg_id = StructuralObject.SetValidValue(value);
                    ReportPropertyChanged("Catg_id");
                    OnCatg_idChanged();
                }
            }
        }
        private global::System.Int32 _Catg_id;
        partial void OnCatg_idChanging(global::System.Int32 value);
        partial void OnCatg_idChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public global::System.String Catg_type1
        {
            get
            {
                return _Catg_type1;
            }
            set
            {
                OnCatg_type1Changing(value);
                ReportPropertyChanging("Catg_type1");
                _Catg_type1 = StructuralObject.SetValidValue(value, true);
                ReportPropertyChanged("Catg_type1");
                OnCatg_type1Changed();
            }
        }
        private global::System.String _Catg_type1;
        partial void OnCatg_type1Changing(global::System.String value);
        partial void OnCatg_type1Changed();

        #endregion

    
    }
    
    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    [EdmEntityTypeAttribute(NamespaceName="ProjectdbModel", Name="Program_type")]
    [Serializable()]
    [DataContractAttribute(IsReference=true)]
    public partial class Program_type : EntityObject
    {
        #region Factory Method
    
        /// <summary>
        /// Create a new Program_type object.
        /// </summary>
        /// <param name="prog_id">Initial value of the Prog_id property.</param>
        public static Program_type CreateProgram_type(global::System.Int32 prog_id)
        {
            Program_type program_type = new Program_type();
            program_type.Prog_id = prog_id;
            return program_type;
        }

        #endregion

        #region Primitive Properties
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.Int32 Prog_id
        {
            get
            {
                return _Prog_id;
            }
            set
            {
                if (_Prog_id != value)
                {
                    OnProg_idChanging(value);
                    ReportPropertyChanging("Prog_id");
                    _Prog_id = StructuralObject.SetValidValue(value);
                    ReportPropertyChanged("Prog_id");
                    OnProg_idChanged();
                }
            }
        }
        private global::System.Int32 _Prog_id;
        partial void OnProg_idChanging(global::System.Int32 value);
        partial void OnProg_idChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public global::System.String Prog_name
        {
            get
            {
                return _Prog_name;
            }
            set
            {
                OnProg_nameChanging(value);
                ReportPropertyChanging("Prog_name");
                _Prog_name = StructuralObject.SetValidValue(value, true);
                ReportPropertyChanged("Prog_name");
                OnProg_nameChanged();
            }
        }
        private global::System.String _Prog_name;
        partial void OnProg_nameChanging(global::System.String value);
        partial void OnProg_nameChanged();

        #endregion

    
    }
    
    /// <summary>
    /// No Metadata Documentation available.
    /// </summary>
    [EdmEntityTypeAttribute(NamespaceName="ProjectdbModel", Name="Std_info")]
    [Serializable()]
    [DataContractAttribute(IsReference=true)]
    public partial class Std_info : EntityObject
    {
        #region Factory Method
    
        /// <summary>
        /// Create a new Std_info object.
        /// </summary>
        /// <param name="std_id">Initial value of the Std_id property.</param>
        public static Std_info CreateStd_info(global::System.Int32 std_id)
        {
            Std_info std_info = new Std_info();
            std_info.Std_id = std_id;
            return std_info;
        }

        #endregion

        #region Primitive Properties
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
        [DataMemberAttribute()]
        public global::System.Int32 Std_id
        {
            get
            {
                return _Std_id;
            }
            set
            {
                if (_Std_id != value)
                {
                    OnStd_idChanging(value);
                    ReportPropertyChanging("Std_id");
                    _Std_id = StructuralObject.SetValidValue(value);
                    ReportPropertyChanged("Std_id");
                    OnStd_idChanged();
                }
            }
        }
        private global::System.Int32 _Std_id;
        partial void OnStd_idChanging(global::System.Int32 value);
        partial void OnStd_idChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public global::System.String Std_name
        {
            get
            {
                return _Std_name;
            }
            set
            {
                OnStd_nameChanging(value);
                ReportPropertyChanging("Std_name");
                _Std_name = StructuralObject.SetValidValue(value, true);
                ReportPropertyChanged("Std_name");
                OnStd_nameChanged();
            }
        }
        private global::System.String _Std_name;
        partial void OnStd_nameChanging(global::System.String value);
        partial void OnStd_nameChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public global::System.String Std_address
        {
            get
            {
                return _Std_address;
            }
            set
            {
                OnStd_addressChanging(value);
                ReportPropertyChanging("Std_address");
                _Std_address = StructuralObject.SetValidValue(value, true);
                ReportPropertyChanged("Std_address");
                OnStd_addressChanged();
            }
        }
        private global::System.String _Std_address;
        partial void OnStd_addressChanging(global::System.String value);
        partial void OnStd_addressChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public global::System.String Std_number
        {
            get
            {
                return _Std_number;
            }
            set
            {
                OnStd_numberChanging(value);
                ReportPropertyChanging("Std_number");
                _Std_number = StructuralObject.SetValidValue(value, true);
                ReportPropertyChanged("Std_number");
                OnStd_numberChanged();
            }
        }
        private global::System.String _Std_number;
        partial void OnStd_numberChanging(global::System.String value);
        partial void OnStd_numberChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public Nullable<global::System.Int32> Catg_id
        {
            get
            {
                return _Catg_id;
            }
            set
            {
                OnCatg_idChanging(value);
                ReportPropertyChanging("Catg_id");
                _Catg_id = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("Catg_id");
                OnCatg_idChanged();
            }
        }
        private Nullable<global::System.Int32> _Catg_id;
        partial void OnCatg_idChanging(Nullable<global::System.Int32> value);
        partial void OnCatg_idChanged();
    
        /// <summary>
        /// No Metadata Documentation available.
        /// </summary>
        [EdmScalarPropertyAttribute(EntityKeyProperty=false, IsNullable=true)]
        [DataMemberAttribute()]
        public Nullable<global::System.Int32> Prog_id
        {
            get
            {
                return _Prog_id;
            }
            set
            {
                OnProg_idChanging(value);
                ReportPropertyChanging("Prog_id");
                _Prog_id = StructuralObject.SetValidValue(value);
                ReportPropertyChanged("Prog_id");
                OnProg_idChanged();
            }
        }
        private Nullable<global::System.Int32> _Prog_id;
        partial void OnProg_idChanging(Nullable<global::System.Int32> value);
        partial void OnProg_idChanged();

        #endregion

    
    }

    #endregion

    
}

 


Posted 8 months ago

Hi bakhtawar,

Refer the below link and get the list through entity in place of code.

http://www.codeproject.com/Articles/820349/Highcharts-in-asp-net-using-jquery-ajax

 

I agree, here is the link: http://e-iceblue.com/free-api