我有问题。如何在类别highcharts上显示数据库中的数据?我使用组合双轴。我需要这个大学毕业。有人能帮我吗?
我用过这个
var data = {"name":"Percentage","data":[50,28,150,125,34,75]};
var categories = [<?php echo join($nama_tugas, ",") ?>];
但它不起作用
$i = mysql_query("SELECT * FROM tbl_detail_tugas WHERE kode_mapel='$km' AND nip ='$nip'");
while ($u = mysql_fetch_assoc($i)) {
$d = $u['detail_id'];
echo $d ;
$a = mysql_query("SELECT AVG(nilai) AS jum FROM tbl_nilai WHERE tbl_nilai.detail_id = $d");
while ($t = mysql_fetch_array($a)) {
echo $t['jum'];
$k[] = $t['jum'];
}
}
$aa = mysql_query("SELECT * FROM tbl_detail_tugas WHERE kode_mapel='$km' AND nip ='$nip'");
while ($uu = mysql_fetch_array($aa)) {
$dd = $uu['detail_id'];
$nama_tugas = $$uu['nama_tugas'];
$ii = mysql_query("SELECT * FROM tbl_nilai WHERE tbl_nilai.detail_id = $dd AND nis ='$id'");
while ($tt = mysql_fetch_array($ii)) {
echo $tt['jum'];
$kk[] = $tt['nilai'];
}
}
?>
<script type="text/javascript">
$(function () {
$('.dual').highcharts({
chart: {
zoomType: 'xy'
},
title: {
text: 'Nilai Tugas & Nilai Rata-rata <?php echo $km ?>'
},
subtitle: {
text: 'Sumber: SMK N2 Merangin'
},
xAxis: [{
categories: []
crosshair: true
}],
yAxis: [{ // Primary yAxis
labels: {
format: '{value}',
style: {
color: Highcharts.getOptions().colors[1]
}
},
title: {
text: 'Nilai',
style: {
color: Highcharts.getOptions().colors[1]
}
}
}, { // Secondary yAxis
title: {
text: 'aaa',
style: {
color: Highcharts.getOptions().colors[0]
}
},
labels: {
format: '{value}',
style: {
color: Highcharts.getOptions().colors[0]
}
},
opposite: true
}],
tooltip: {
shared: true
},
legend: {
layout: 'vertical',
align: 'left',
x: 120,
verticalAlign: 'top',
y: 100,
floating: true,
backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF'
},
series: [{
name: 'nilai',
type: 'column',
yAxis: 0,
data: data,
tooltip: {
valueSuffix: ''
}
},{
name: 'Rata-rata',
type: 'spline',
yAxis: 0,
data: [<?php echo join($k, ','); ?>],
tooltip: {
valueSuffix: ''
}
}]
});
});
</script>