我对谷歌图表有疑问,当我使用 addRows 命令时,我的 php 变量采用所需的格式就足够了吗?
我将放置我正在使用的代码:
<!--Load the AJAX API-->
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
        google.load("visualization", "1.0",{"packages":["corechart"]});
        google.setOnLoadCallback(drawChart);
        function drawChart(){
            //create the data table
            var data = new google.visualization.DataTable();
            data.addColumn("string","Fruits");
            data.addColumn("number","Amount");
            data.addRows([<?php echo "'$jsRows'";?>]);
            //set chart options
            var options = {"title":"Amount of different fruits",
                "width":400,
                "height":300};
            //instantiate and draw chart, passing in options
            var options = new google.visualization.PieChart(document.getElementById("chart_div"));
            chart.draw(data, options);
            } //end of drawchart function
            </script>
当我写:echo $jsRows; 我得到:["0 as 6 h",0],["6 as 12h",0],["12 as 18h",8],["18 as 24h",0],这是谷歌图表可以处理的数据格式,但是使用此代码,我的图表不会出现。有谁知道为什么?提前致谢!