[请协助我完成此脚本...
首先,脚本可以完美地工作,没有任何向下钻取图表,但是如果我向脚本添加向下钻取,脚本将显示许多错误,例如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数据库中进行。.
谢谢...