doujiu7704 2017-04-20 08:01
浏览 26

highcharts不与DB合作

i have sensor send data to database and store there and the data of sensor shows in a website as a chart but its not working guys i want to make these codes working so how can i ? p.s. the database store real time data and the chart display the values in real time also

this php code to fetch data from database .. which is new.php

 <?php
 require 'mysql0.php';

 $query="SELECT * FROM `pulsesensor`";
 if($query_run=mysql_query($query))
 {
         echo "query executed<br>";

 while($query_execute=mysql_fetch_assoc($query_run))
{
        echo $query_execute['value'].'<br>';
       //echo $query_execute['date'].'<br>';
}    
} 
else 
{
      echo "query not exicuted";
} 

?>

and html code with is chart code is that

    <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>  
    <script src="https://code.highcharts.com/highcharts.js"></script>
    <script src="https://code.highcharts.com/modules/exporting.js"></script>
    <div id="container" style="min-width: 310px; height: 400px; margin: 0 
   auto">
    </div>
<script>
 /** 
 * Request data from the server, add it to the graph and set a timeout
 * to request again
 */
function requestData() {
 $.ajax({
    url: 'new.php',
    success: function(point) {
        var series = chart.series[0],
            shift = series.data.length > 20; // shift if the series is
                                             // longer than 20
        // add the point
        chart.series[0].addPoint(point, true, shift);
        // call it again after one second
        setTimeout(requestData, 1000);
    },
    cache: false
});
}
 $(document).ready(function() {
  chart = new Highcharts.Chart({
    chart: {
        renderTo: 'container',
        defaultSeriesType: 'spline',
        events: {
            load: requestData
        }
    },
    title: {
        text: 'Live Heartbeats data'
    },
    xAxis: {
        type: 'datetime',
        tickPixelInterval: 150,
        maxZoom: 20 * 1000
    },
    yAxis: {
        minPadding: 0.2,
        maxPadding: 0.2,
        title: {
            text: 'Value',
            margin: 80
        }
    },
    series: [{
        name: 'heartbeats data',
        data: []
    }]
});
});
        </script>

the result is that

enter image description here

what is the wrong?

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 素材场景中光线烘焙后灯光失效
    • ¥15 请教一下各位,为什么我这个没有实现模拟点击
    • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
    • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
    • ¥20 有关区间dp的问题求解
    • ¥15 多电路系统共用电源的串扰问题
    • ¥15 slam rangenet++配置
    • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
    • ¥15 ubuntu子系统密码忘记
    • ¥15 保护模式-系统加载-段寄存器