我刚开始使用highcharts这里我坚持 -
我有2个阵列命名- js_platform, js_totalTest
,这我从数据库中获取。
所述代码来生成图表是 -
<!DOCTYPE html>
<body>
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/modules/exporting.js"> </script>
<script>
$(function () {
js_platform = <?php echo json_encode($platform); ?>;
js_totalTest = <?php echo json_encode($totalTest); ?>;
$('#container').highcharts({
chart: {
type: 'column'
},
title: {
text: 'Overall avalibility of testcases on each platform'
},
xAxis: {
categories: js_platform
},
yAxis: {
min: 0,
title: {
text: 'Total fruit consumption'
},
stackLabels: {
enabled: true,
style: {
fontWeight: 'bold',
color: (Highcharts.theme && Highcharts.theme.textColor) || 'gray'
}
}
},
legend: {
align: 'right',
x: -70,
verticalAlign: 'top',
y: 20,
floating: true,
backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColorSolid) || 'white',
borderColor: '#CCC',
borderWidth: 1,
shadow: false
},
tooltip: {
formatter: function() {
return '<b>'+ this.x +'</b><br/>'+
this.series.name +': '+ this.y +'<br/>'+
'Total: '+ this.point.stackTotal;
}
},
plotOptions: {
column: {
stacking: 'normal',
dataLabels: {
enabled: true,
color: (Highcharts.theme && Highcharts.theme.dataLabelsColor) || 'white',
style: {
textShadow: '0 0 3px black, 0 0 3px black'
}
}
}
},
series: [{
name: 'John',
data: [5, 3, 4, 7, 2]
}, {
name: 'Jane',
data: [2, 2, 3, 2, 1]
}, {
name: 'Joe',
data: [3, 4, 4, 2, 5]
}]
});
});
</script>
<div id="container" style="min-width: 310px; height: 400px; margin: 0 auto"></div>
</body>
</html>
现在,该系列我想给js_totalTest的数组值。
在这里,如果我这样做**series: [{data: [js_totalTest]}]**
,它不会显示任何内容。
我怎样才能做到这一点? 请指导。