doupo2241 2019-03-30 07:16
浏览 41

我正在尝试根据select标签中的患者ID在我的网站上绘制实时数据图表

I'm trying to plot graph on real time data on my website according to there patient_id in select tag. In phpmyadmin database i have four column (temp,rate,date,patient_id) in followdata_temp i getting data of temp as per time.

in main page i'm gettin select option as well as graph below it but I'm not able to plot graph on it.

// followdata_temp.php (from where data is fetched)

    $mysqli = new mysqli(DB_HOST, DB_USERNAME, DB_PASSWORD, DB_NAME);
    //query to get data from the table   
    session_start();    
    //$pid = $_POST['patient_id'];
    //echo $pid;
    $query = sprintf("SELECT time, temp FROM heart_reating where patient_id='$pid' ") or die(mysql_error()); //$pid is where patient_id is declared in page.    
    //execute query
    $result = $mysqli->query($query);  

my html page

<html>
    <head>
        <title>ChartJS - Line</title>
        <meta charset="utf-8"/>
        <link href="css/default.css" rel="stylesheet">       
    </head>
    <body>   
      <div class="chart-container">
        <canvas id="line-chartcanvas"></canvas>
      </div>    
      <!-- javascript -->
     <script type="text/javascript" src="js2/jquery.min.js">    
        </script>
        <script type="text/javascript" src="js2/Chart.min.js">  
        </script>
    <script type="text/javascript" src="https://code.jquery.com/jquery-3.3.1.js">
    </script>
       <script>
            $(document).ready(function() {   
      /**
       * call the data.php file to fetch the result from db table.
       */
      $.ajax({
        url : "/followdata_temp.php",
        type : "GET",
        success : function(data){
          console.log(data);    
          var time = [];
          var temp = [];    
          var len = data.length;    
          for (var i = 0; i < len; i++) {
                   time.push("" + data[i].time);
            temp.push(data[i].temp);
          }  
          //get canvas
          var ctx = $("#line-chartcanvas");
          var chartdata = {
            labels : time,
            datasets : [
              { 
             label : "Temperature",
                data : temp,
                backgroundColor : "blue",
                borderColor : "lightblue",
                fill : false,
                lineTension : 0,
                pointRadius : 5
              }
            ]
          };   
          var chart = new Chart( ctx, {
            type : "line",
            data : chartdata
           });
    },
        error : function(data) {
          console.log(data);
        }
      });   
    });
        </script>    
    </body>
    </html> 

I wanted plot graph by selecting patient id from select that is in phpmyadmin plot graph of it as (temp, time)

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 BP神经网络控制倒立摆
    • ¥20 要这个数学建模编程的代码 并且能完整允许出来结果 完整的过程和数据的结果
    • ¥15 html5+css和javascript有人可以帮吗?图片要怎么插入代码里面啊
    • ¥30 Unity接入微信SDK 无法开启摄像头
    • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
    • ¥20 cad图纸,chx-3六轴码垛机器人
    • ¥15 移动摄像头专网需要解vlan
    • ¥20 access多表提取相同字段数据并合并
    • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
    • ¥20 Java-Oj-桌布的计算