weixin_33701251 2015-11-07 23:43 采纳率: 0%
浏览 21

从数据库中绘制图表

I'm trying to implement a FLOT chart from database, but I'm having a few problems...

I have a database with 2 rows: Data, Pcr

My files .php:

Datas.php

$dates=array();

while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
    $date=$row['Date'];
    $pcrs=(float)$row['Pcr'];
    $dates[] = array(strtotime($date)*1000,$pcrs);
}
echo json_encode($dates);

I get the array:

[[1434240000000,7.2],[1434758400000,4.83],[1443052800000,4.85],[1445817600000,4.56],[1446163200000,4.5]]

I would like to get a chart from this array, but I don't know how to do that...

I have this file, and I know that it is incomplete...

Flot.php

<script>
        $(document).ready(function(){ 
               $.ajax({
                    type:’post’,
         dataType:'json',
                    url:'datas.php',

                    success:function(data){
        var datasets = {
            "pcr": {
            label: "Pcr",
            data: dates
            }
        };

Could someone help me to do this chart?

Thank you very much

  • 写回答

0条回答 默认 最新

    报告相同问题?