Skip to content

I have like to create funnel chart in mvc3 application and my charts vales to be get from the stored procedure.. pls anyone can help me.regards chandru([email protected])

chandru santhosh

Asked Aug 9, 2012, 7:11 PM EDT1 answer
Share
LinkedInX
Im a beginner and new to mvc.. so pls explain it by step by step

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    HI, guys i found solution.

    create a controller name it as Home

         public ActionResult Chart()
             {

                Display();
                Display1();
                Display2();
                var priH = prioitH;
                var priC = prioitC;
                var pricW = prioitW;
                var chart = new Chart(width: 400, height: 250)
            .AddSeries(
                chartType: "Funnel",
                legend: "Rainfall",
                yValues: new[] { priH,priC,pricW}).Write("png");
               
                return View();
            }


    and read a values from the database:
     List FunnelValue = new List();
        SqlDataReader reader= null;
        SqlConnection con= null;
        SqlCommand cmd=null;
        FunnelObj fune = null;
       // Int64 prioitH=0;
        using (con = new SqlConnection (connectionstring))
        {
            con.Open();
            cmd = con.CreateCommand();
            using (cmd = new SqlCommand("sp_funnel1", con))
            {
                cmd.CommandType = CommandType.StoredProcedure;

                reader=cmd.ExecuteReader();
                while (reader.Read())
                {
                    //prioit = Convert.ToInt32(reader["Warm"]);
                    //prioit = Convert.ToInt32(reader["Cold"]);
                    prioitH = Convert.ToInt32(reader["Hot"]);
                }
                reader.Close();
                // while (reader.Read())
                // {
                //fune = new FunnelObj();
                //fune.PriorityId = Convert.ToInt64(reader["c"]);
                //    // FunnelValue.Add(fune);

                // }
                //  reader.Close();
            }
                return prioitH;
    and as follows create how many methods u want..


    now create your view name is called index.cshtml


        
           
       






      
      


     

         $(document).ready(function () {


             $('#btnview').click(function (event) {

                 var id = $("#txtattach").val();
                 window.location.href = '../Home/Chart/?';


             });

    then create another view method called Chart.cshtml:paste the code below


    ....

     now run your project.. it works well.
    0