有没有人用过google chart api 折线图,把php里的数组放到js里显示折线图$json =json_encode($myData['CourseInfo']);?> <br /> google.load("visualization", "1", {packages:["corechart"]});<br /> google.setOnLoadCallback(drawChart);<br /> function drawChart() {<br /> var json = <?php echo $json?>;<br /> var data = new google.visualization.DataTable();<br /> data.addColumn('string', 'day');<br /> data.addColumn('number', '长期数量');<br /> data.addColumn('number', '非长期数量');<br /> var cnt = json.length;<br /><br /> var arr=new Array();<br /> for(i=0;i<cnt;i++){<br /> var j='\''+json[i]['tdate']+'\'';<br /> var x = json[i]['coulong'];<br /> var y = json[i]['coulongun'];<br /> arr[i] = '[' + j + ',' +x+','+ y+']';<br /> }<br /> alert(arr);弹出(['2012-03-27',0,119],['2012-03-26',0,335],['2012-03-25',0,539],['2012-03-24',0,534],['2012-03-23',0,344],['2012-03-22',0,335],['2012-03-21',0,343],['2012-03-20',0,301])<br /> date.addRows([arr]);这样折线图不会显示出来<br />// data.addRows([<br />// ['2012-03-27',0,119],['2012-03-26',0,335],['2012-03-25',0,539],['2012-03-24',0,534],['2012-03-23',0,344],['2012-03-22',0,335],['2012-03-21',0,343],['2012-03-20',0,301]<br />// ]);这样折线图会显示出来<br /> var options = {<br /> title: '监控'<br /> };<br /><br /> var chart = new google.visualization.LineChart(document.getElementById('chart_div'));<br /> chart.draw(data, options);<br /> }<br /> 我是把php数组转为json数据,把json数据放到data.addRows([])这里,但是不显示,求解------解决方案--------------------给你发过去了,看看吧