样式未在Google组织结构图中显示

时间:2014-01-10 13:29:56

标签: php json google-visualization

$table = array();
$str = '<b>BB</b>';
$table['cols'] = array(
array("id"=>"","label"=>"Name","pattern"=>"","type"=>"string"),
array("id"=>"","label"=>"Manager","pattern"=>"","type"=>"string"),
array("id"=>"","label"=>"Tooltip","pattern"=>"","type"=>"string")
);
$rows = array();
$temp = array();
$temp[] = array("v"=>"BB","f"=>"BB");
$temp[] = array("v"=>null,"f"=>null);
$temp[] = array("v"=>null,"f"=>null);


$rows[] = array('c' => $temp,'p'=>'{style: border: 2px solid #D1D0CE;}');
$table['rows'] = $rows;
$jsonTable = json_encode($table);
echo $jsonTable; 

'p'=&gt;'{style:border:2px solid#D1D0CE;}'此样式未在Google组织结构图中显示。 实际上它在'操作数c

中显示错误jQuery错误“TypeError:invalid” 没有它,组织结构图显示正常。给p:tag的正确格式是什么。

我的客户端代码:

<!Doctype html>
<html>
<head>
    <meta charset="utf-8">
    <!--Load the AJAX API-->
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript" src="js/jquery-2.0.2.min.js"></script>
    <script type="text/javascript">

        // Load the Visualization API and the piechart package.
        google.load('visualization', '1', {'packages': ['orgchart']});

        // Set a callback to run when the Google Visualization API is loaded.
        google.setOnLoadCallback(drawChart);

        function drawChart() {
            var jsonData = $.ajax({
                url: "getData.php",
                dataType: "json",
                async: false
            }).responseText;


            // Create our data table out of JSON data loaded from server.
            var data = new google.visualization.DataTable(jsonData);

            // Instantiate and draw our chart, passing in some options.
            var chart = new       google.visualization.OrgChart(document.getElementById('chart_div'));
            chart.draw(data, {allowHtml: true});
        }

    </script>
</head>

这是我的json回复。

{"cols":[{"id":"","label":"Name","pattern":"","type":"string"},       {"id":"","label":"Manager","pattern":"","type":"string"},{"id":"","label":"Tooltip","pattern":"","type":"string"}],"rows":[{"c":[{"v":"BB","f":"BB"},{"v":null,"f":null},{"v":null,"f":null}],"p":"{style: 'border: 2px solid #D1D0CE;'}"}]}

提前致谢。

0 个答案:

没有答案