高股价图中的错误日期

时间:2017-09-22 00:38:19

标签: javascript highcharts highstock

如何将正确的日期纳入我的高库存图表?我一直在滑块中获得1月到2月的月份(正确的范围应该是从7月到8月),这是不正确的。在我的PHP中,我将数据库中的日期/时间转换为JavaScript时间戳,但仍然无法正常工作。任何帮助都会很棒,谢谢!

输出数组:data.txt

当前高位股票图表:highstock line chart

PHP& JS和HTML:



<?php
$stmt = mysqli_prepare($con, "SELECT date, IFNULL(AT,'null') FROM test");
	$result = array('date' => array(), 'AT' => array());
	if ($stmt) {
		mysqli_stmt_execute($stmt);
		mysqli_stmt_bind_result($stmt, $date, $at);
	    while (mysqli_stmt_fetch($stmt)) {
	        $result['date'][] = $date;
	        $result['AT'][] = (int)$at;
            
           $stamp = strtotime($date); // get unix timestamp
           $time = $stamp*1000;       

	    }
	    mysqli_stmt_close($stmt);
       
    }
 
?>
<!DOCTYPE html> 
<html > 
    <!--<![endif]-->     
    <head> 
        <meta charset="utf-8"> 
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> 
<script type="text/javascript" src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="https://code.highcharts.com/stock/highstock.js"></script>
<script src="https://code.highcharts.com/highcharts-more.js"></script>
<script src="https://code.highcharts.com/modules/data.js"></script>      

<script>

$(function(data) {
  
     
       
	

     $('#chart2').highcharts('StockChart', {          //Stock chart - might need zones to match gauges
		

		    rangeSelector : {
                buttons : [{
                    type : 'hour',
                    count : 3,
                    text : '3h'
                }, {
                    type : 'day',
                    count : 2,
                    text : '2D'
                }, {
                    type : 'week',
                    count : 1,
                    text : '1W'
                }, {
                    type : 'month',
                    count : 1,
                    text : '1M'
                },  {
                    type : 'all',
                    count : 1,
                    text : 'All'
                }],
                selected : 2,
                
            },

		    title: {
		        text: 'Power'
		    },
         

			
		    yAxis: [{
		        title: {
		            text: 'Bat V'
		        },
		        height: 400,
		        lineWidth: 2,
				oposite: true
		    }, {
		        title: {										// yAxis 1 ie secondary y-axis
		            text: 'Solar V'
		        },
		        //top: 200,
		        height: 400,
		        offset: 25,
		        lineWidth: 2,
				oposite: false
		    }],
		    
			xAxis:{
					type: <?php echo json_encode($time) ?>,
     
				  },  
				  
		    series: [{
                 pointInterval:  24 * 3600 * 1000,
		        type: 'line',
		        data:  <?php echo json_encode($result['AT']) ?>
		    },],
		});										//end of stockchart graphic

      									// end of get function
		
  });											// end of graphing function

</script>         
</head>     
    <body>     
        <?php echo $time; ?>
		  <br><br /><br /><br />
		  <div id="chart2" style="width:100%; height:600px;"></div>
    </body>     
</html>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:2)

基于您的输出数组:data.txt let navitem = UINavigationItem() navitem.rightBarButtonItem = item1 navBar.setItems([navitem], animated: true) 它应该是[["2017-07-25 16:44",12],["2017-07-25 17:00",12],...]所以修复[[1500981240000,12],[1500982200000,12],...]获取unix时间戳(以毫秒为单位)

$result['date'][] = strtotime($date)*1000