我正在尝试使用hightchar.js创建条形图我的代码如下所示:使用数组推无法在图表上插入数据获取数据
<?php
$data_suhu = array();
foreach($resultAll as $result){
array_push($data_suhu,array(strtotime($result['waktu']),$result['suhu']));
}
die (json_encode($data_suhu));
?>
php获取有关图表数据的数据
<script>
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container1'
},
title: {
text: 'Grafik Data Suhu'
},
xAxis: {
title: {
enabled: true,
text: 'Hours of the Day'
},
type: 'datetime',
showFirstLabel:true,
showLastLabel:true,
dateTimeLabelFormats : {
hour: '%I %p',
minute: '%I:%M %p',
month: '%e. %b',
year: '%b'
}
},
series: [{
name: "Suhu",
data: [
[Date.UTC(<?php echo json_encode($data_suhu);?>)]
]
}],
responsive: {
rules: [{
condition: {
maxWidth: 500
},
chartOptions: {
legend: {
layout: 'horizontal',
align: 'center',
verticalAlign: 'bottom'
}
}
}]
}
});
</script>
您可以在github https://github.com/bellabeen/simon-server上获得我的项目>
我正在尝试使用hightchar.js创建条形图。我的代码如下:使用数组推无法在图表上插入数据获取数据
尝试使用