请协助我完成这些脚本...
首先,脚本运行完美,没有任何深入分析图表,但如果我向脚本添加钻取,脚本会显示许多错误,例如id属性等......
我尝试按照Highchart Column Drilldown教程进行操作,其中包括要求图表进行深入分析的要求,但仍无法使其正常工作:
这是我的数据库:
以下是我的脚本,没有任何明细工作,没有错误。
<?php
require_once('../includes/database.php');
$stmt = mysqli_prepare($con, "SELECT state_name,totals FROM states");
$result = array('state_name' => array(), 'totals' => array());
if ($stmt) {
mysqli_stmt_execute($stmt);
mysqli_stmt_bind_result($stmt, $state_name, $totals);
while (mysqli_stmt_fetch($stmt)) {
$result['state_name'][] = $state_name;
$result['totals'][] = (int)$totals;
}
mysqli_stmt_close($stmt);
}
?>
<body>
<div id="div-chart"></div>
<script src="../assets/js/jquery-1.12.3.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/data.js"></script>
<script src="https://code.highcharts.com/modules/drilldown.js">
</script>
<script>
$(function () {
$('#div-chart').highcharts({
chart: {
type: 'column'
},
title: {
text: 'List of States'
},
xAxis: {
categories: <?php echo json_encode($result['state_name'])
?>,
crosshair: true
},
yAxis: {
min: 0,
title: {
text: 'Total'
}
},
plotOptions: {
column: {
pointPadding: 0.2,
borderWidth: 0
}
},
series: [{
name: 'States',
data: <?php echo json_encode($result['totals']) ?>
}]
});
});
</script>
</body>
以下是没有向下钻取属性的输出:
以下是具有钻取属性的更新脚本,根本不起作用:
<?php
require_once('../includes/database.php');
$stmt = mysqli_prepare($con, "SELECT state_name,one,two,three,totals FROM
states");
$result = array('state_name' => array(), 'one' => array(), 'two' =>
array(), 'three' => array(), 'totals' => array());
if ($stmt) {
mysqli_stmt_execute($stmt);
mysqli_stmt_bind_result($stmt, $state_name, $totals);
while (mysqli_stmt_fetch($stmt)) {
$result['state_name'][] = $state_name;
$result['one'][] = (int)$one;
$result['two'][] = (int)$two;
$result['three'][] = (int)$three;
$result['totals'][] = (int)$totals;
}
mysqli_stmt_close($stmt);
}
?>
<body>
<div id="div-chart"></div>
<script src="../assets/js/jquery-1.12.3.js"></script>
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/data.js"></script>
<script src="https://code.highcharts.com/modules/drilldown.js">
</script>
<script>
$(function () {
$('#div-chart').highcharts({
chart: {
type: 'column'
},
title: {
text: 'List of States'
},
xAxis: {
categories: <?php echo json_encode($result['state_name'])
?>,
crosshair: true
},
yAxis: {
min: 0,
title: {
text: 'Total'
}
},
plotOptions: {
column: {
pointPadding: 0.2,
borderWidth: 0
}
},
series: [{
name: 'States',
data: [{
name: <?php echo json_encode($result['state_name']) ?>,
y: <?php echo json_encode($result['totals']) ?>,
drilldown: <?php echo json_encode($result['state_name']) ?>
}]
}],
drilldown: {
series: [{
name: <?php echo json_encode($result['state_name']) ?>,
id: <?php echo json_encode($result['state_name']) ?>,
data: [
<?php echo json_encode($result['one']) ?>,
<?php echo json_encode($result['two']) ?>,
<?php echo json_encode($result['three']) ?>
]
}]
}
});
});
</script>
</body>
请帮我解决这个问题,我希望图表能够异步钻取,但是要从mysql数据库中解析..
谢谢......