//引入highcharts.js
<script type="text/javascript">
$(function(){
$('#container').highcharts({ title: { text: '',//x轴上方的标题 x: -20 //center }, credits: {//去掉右下角log标志 enabled:false }, exporting: {//去掉导出按钮 enabled:false }, xAxis: { categories: <?=$result['statDateJson']?>,//x轴json数组array(0=>,1=>,2=>,3=>,4=>,5=>,6=>) labels: { rotation : 67 //这个是控制x坐标轴 x值的字体方向 } }, yAxis: { title: { text: ''//y轴方向的标题 }, min: 0, labels: { format: '{value}' }, plotLines: [{ value: 0, width: 1, color: '#808080' }] }, tooltip: { valueSuffix: '个' }, series: <?=$result['dataJson']?> //json数组格式 array(0=>array('name'=>,'data'=>array(0=>,1=>,2=>,3=>,4=>,5=>,6=>)),1=>array('name'=>,'data'=>array(0=>,1=>,2=>,3=>,4=>,5=>,6=>))); }); });
});
</script>
//题外话:突然想起来前几天朋友说腾讯的一个面试题,写一个二维数组的json格式??你能写出来么??====》要看这个二维数组是关联还是索引数组哦~~ 四种!!
echo json_encode(array(array(1,2,3),array(4,5,6))).'<br/>';
echo json_encode(array(array(1=>'1',2=>'b',3=>'c'),array(4=>'d',5=>'e',6=>'f'))).'<br/>';
echo json_encode(array('a'=>array(1,2,3),'b'=>array(4,5,6))).'<br/>';
echo json_encode(array('a'=>array(1=>'1',2=>'b',3=>'c'),array(4=>'d',5=>'e',6=>'f'))).'<br/>';
答案:
[[1,2,3],[4,5,6]]
[{"1":"1","2":"b","3":"c"},{"4":"d","5":"e","6":"f"}]
{"a":[1,2,3],"b":[4,5,6]}
{"a":{"1":"1","2":"b","3":"c"},"0":{"4":"d","5":"e","6":"f"}}
===》由此可见:索引用方括号[] 关联用大括号{}=====》引申 来!写一个三维的 array('a'=>array(1,2,3),array('b'=>array(1,2,3)));
{"a":[1,2,3],"0":{"b":[1,2,3]}}