How to pass time in “highcharts”?

前端 未结 3 1386
刺人心
刺人心 2020-12-12 05:30

i am passing data like this

$chart->series[] = array(\'data\' => array());
in array i have data in string  
1 => string \'11:03:01\' (length=8)
2 =         


        
相关标签:
3条回答
  • 2020-12-12 05:39

    process the array with times in a loop and add each item to a variable that is seperated by comma..

    then finally put

    series: [<?php echo $str;?>]
    

    assuming $str contains values:

    $str = "'11:03:01', '11:07:56'";
    
    0 讨论(0)
  • 2020-12-12 05:43

    You can do it in two ways,

    1. UTC format like [Date.UTC(2010, 0, 1), 29.9],
    2. Unix Timestamp like 1262307661000

    Highcharts accepts both of them,

    Hope this will help you to achieve what you need.

    0 讨论(0)
  • 2020-12-12 05:48

    There is no way to send just a time, directly.

    How to handle measuring times will depend on what exactly you're trying to do. If you want to use time on your x axis to track data throughout the day, the best method is to use the full date time string, sent as an epoch timestamp ( http://en.wikipedia.org/wiki/Unix_time )

    If you are tracking data by time, but not for a particular date, you will still need to use the full date stamp - in such a case, if you are tracking multiple dates in multiple series, you will need to use the same date for each series, appending the individual time stamps to the 'base' date.

    For various other uses, sending a number value instead of a time value will work better (ie if you want to send 10 hours, 30 minutes, you can send 10.5 instead of 10:30)

    0 讨论(0)
提交回复
热议问题