在HighChart中转换时间

时间:2013-04-18 11:49:16

标签: javascript datetime highcharts

我正在使用高图来比较每位患者的等待时间和放电时间。

例如:

Patient ID   Expected Time    Waiting Time
2            2 hours          1 hour 

我与数据库建立连接以获取这些时间:

$query2 = "SELECT PatientID,Forename, Patient.Illness, Patient.Priority, Arrival_time, MY_TIME() AS now, ABS( TIMEDIFF( MY_TIME( ) , Arrival_time ) ) AS Waiting_Time, TIME_TO_SEC( Expected_time) as Expected_time , TIME_TO_SEC( Discharge_time )  as Discharge_time, Examined
FROM Patient, priority_time
WHERE Patient.Illness = priority_time.Illness
AND Patient.Priority = priority_time.Priority;";
$result2 = mysqli_query($conn, $query2) or die("Invalid query: ".$query2); 

我想在X轴上显示患者ID,在Y轴上显示等待时间。

的问题:

Converting Time to display in this format: hours: minutes: seconds on Y axis.

这是我的代码:

<html>
    <head>
    <script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
    <script src="js/highcharts.js"></script>
    <script type="text/javascript">
        function drawChart(){
            var chart = new Highcharts.Chart({
                chart: {
                    renderTo: 'divforchart',
                    type:'column',
                },
                xAxis: {
                    name:'patients',
                    categories: ['Juan','Pepe','Paco']
                },
                yAxis: {
                    type: 'datetime'
                },

                series: [
                    {
                        name: 'Arrival time',
                        data: [
                            ['Juan',Date.UTC(2012,4,18,11,0)], 
                            ['Pepe',Date.UTC(2012,4,18,11,0)], 
                            ['Paco',Date.UTC(2012,4,18,11,0)] 
                        ]
                    },
                    {
                        name: 'Expected time',
                        data: [
                            ['Juan',Date.UTC(2012,4,18,12,00)], 
                            ['Pepe',Date.UTC(2012,4,18,13,00)], 
                            ['Paco',Date.UTC(2012,4,18,11,15)]
                        ]
                    }
                ]
            });
        }
    </script>
    </head>
    <body onLoad="drawChart()">
     <div id="divforchart" style="height: 400px"></div>
    </body>

编辑: Visualization

0 个答案:

没有答案