您好我很难尝试用我的SQL数据填充我的Highchart但有条件。例如,在1月份注册的人数等等 - 直到12月份。
这是我的代码
<?php
require_once './library/config.php';
$sql = mysql_query("SELECT count(*) from tbl_users where MonthCreated = 'January' and YearCreated = '2016';");
$row = mysql_fetch_assoc($sql);
$jan = $row['count'];
?>
这是我的HighChart.htm
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Barangay Statistics</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<style type="text/css">
${demo.css}
</style>
<script type="text/javascript">
$(function () {
$('#container').highcharts({
title: {
text: 'Monthly Requests Report',
x: -20 //center
},
subtitle: {
text: 'Source: Barangay Harapin ang Bukas',
x: -20
},
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun',
'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
yAxis: {
title: {
text: 'Volume'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
tooltip: {
valueSuffix: '' //suffix *C
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'middle',
borderWidth: 0
},
series: [{
name: 'Complaints',
data: [7.0, 6.9, 9.5, 14.5, 18.2, 21.5, 25.2, 26.5, 23.3, 18.3, 13.9,20]
}, {
name: 'Services',
data: [-0.2, 0.8, 5.7, 11.3, 17.0, 22.0, 24.8, 24.1, 20.1, 14.1, 8.6, 2.5]
}, {
下面是我想要显示的值。但它仍然没有显示任何价值:(
name: 'Registered Constituents',
data: [1,2,3,4,5,6,7,<?php echo $jan; ?>]
}]
});
});
</script>
</head>
<body>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/exporting.js"></script>
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"> </div>
</body>
</html>
非常感谢!