Hi. I'm trying to use this google api for an org chart and I'm a
little lost.

    <script type='text/javascript' src='http://www.google.com/jsapi'></
script>
    <script type='text/javascript'>
      google.load('visualization', '1', {packages:['orgchart']});
      google.setOnLoadCallback(drawChart);
      function drawChart() {
        var data = new google.visualization.DataTable();
        data.addColumn('string', 'Name');
        data.addColumn('string', 'Manager');
        data.addColumn('string', 'ToolTip');
        data.addRows([
          [{v:'Mike', f:'Mike<div style="color:red; font-
style:italic">President</div>'}, '', 'The President'],
          [{v:'Jim', f:'Jim<div style="color:red; font-
style:italic">Vice President<div>'}, 'Mike', 'VP'],
          ['Alice', 'Mike', ''],
          ['Bob', 'Jim', 'Bob Sponge'],
          ['Carol', 'Bob', '']
        ]);
        var chart = new google.visualization.OrgChart
(document.getElementById('chart_div'));
        chart.draw(data, {allowHtml:true});
      }
    </script>
As you can see it wants the data in an array. It seems like it should
be easy to create an array from json but I can't figure it out...
my json is returning as
[{"ename":"Employee","mgr":"Manager","title":"Title"}], etc.
I need to reformat is as [[Employee,Manager,Title]]

Reply via email to