Home forums Using CanvasJS Dynamic Chart php did not send data to $.getJSON() using PHP,MYSQL,CanvasJS

This topic contains 4 replies, has 2 voices, and was last updated by  Indranil Deo 8 months, 2 weeks ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #18602

    Hello,
    I want to make dynamic chart input given by user send to ajax function drawgraph().Ajax function send data to php,and php send data to $.getJSON(“myphpService.php”, function(result).Its did not show anything

    #18605

    Indranil Deo
    Member

    Sajjad,

    Can you please check your Browser Console for any errors? Also, can you please create a sample project and share your code, so that we can look into it and help you out.

    ___________
    Indranil Deo,
    Team CanvasJS

    #18606

    Browser did no show any error and how i can share my code here.

    #18609
    <----------------------------DrawGraph.html-------------------->
    <html>
      <head>
        <title></title>
      </head>
      <body>
        <div class="container-fluid">
          <p>IN container </p>
          <div id="chartContainer" style="height: 370px; max-width: 920px; margin: 0px auto;"></div>
        </div>
        </div>
        <input type="date" name="gsdate" id="gsdate"></div>
        <input type="date" name="gedate" id="gedate"></div>
        <select name="gitem" id="gitem">
          <option value="">Select item</option>
          <option value="SetPoint">Set Point</option>
          <option value="SupplyWater">Supply Water</option>
        </select>
        <select name="gAHU" id="gAHU">
          <option value="">Select AHU</option>
          <option value="AHU 1-1">AHU 1-1</option>
          <option value="AHU 1-2">AHU 1-2</option>
          <option value="AHU 2-1">AHU 2-1</option>
          <option value="AHU 2-2">AHU 2-2</option>
        </select>
    
        <button type="button" id="run" onclick="drawgraph()">Draw Graph</button>
    
        <script type="text/javascript" src="https://canvasjs.com/assets/script/jquery-1.11.1.min.js"></script>
        <script type="text/javascript" src="https://canvasjs.com/assets/script/jquery.canvasjs.min.js"></script>
        <script type="text/javascript">
    
    	function drawgraph()
          {
              var gsdate  = $("#gsdate").val();
              var gedate  = $("#gedate").val();
              var gAHU    = $("#gAHU").val();
              var gitem   = $('#gitem').val();
          
             
                DataArray = 
              {
          
                "gsdate"    : gsdate,
                "gedate"    : gedate,
                "gAHU"      : gAHU ,
                "gitem"     : gitem 
              }
              $.ajax({
                  type:"POST",
                  url : "myphpService.php",
                  data : DataArray,
                  datatype : 'html',
              }).done(function(data,Status)
              {
                $("#gmessage").html(data);
          
              })
          
              
          }
          
           
          $.getJSON("myphpService.php", function(result)
          {
                    var dps= [];
          
          for(var i=0; i<result.length;i++)
          {
             dps.push({
                        "label":result[i].year, 
                        "y":[result[i].minivalue,result[i].maxivalue]
                      });
          
          }
          
          var chart = new CanvasJS.Chart("chartContainer",
           {
              animationEnabled:true,
              title:
              {
                  text: "BMS Performance Monitroing",
              },
              axisX:
              {
                  title: "Date",
              },
          
              axisY:
                {
                  title: "Range",
              },
          
          
              data: [{
                  type: "rangeColumn",
                  dataPoints: dps
                      }]
          });
          
          
          chart.render();
          
          });
          
          
          
        </script>
      </body>
    </html>
    
    #18614

    Indranil Deo
    Member

    Sajjad,

    Please take a look at Rendering Charts from JSON API using AJAX. Also, can you please provide the sample JSON data returned from myphpService.php so that we can look into the data and help you out.

    ___________
    Indranil Deo,
    Team CanvasJS

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.