dsbpaqt61965
2014-10-24 10:08
浏览 107

谷歌可视化组织orgchart同名的两个孩子没有显示

When assigning two sub names (Same name) for same superior displays only one sub level. How can i Solve this?

<html>
  <head>
    <script type="text/javascript" src="https://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', ''],
          ['Alice', 'Mike', ''],
          ['Bob', 'Jim', 'Bob Sponge'],
          ['Carol', 'Bob', '']
        ]);

        var chart = new google.visualization.OrgChart(document.getElementById('chart_div'));
        chart.draw(data, {allowHtml:true});
      }
   </script>
    </head>
  <body>
    <div id="chart_div""></div>
  </body>
</html>

Fiddle Link: http://jsfiddle.net/kb24mcp1/

In the above example Mike is the first level and Alice is the first child of MIKE when i add another child for MIKE with the same name as ALICE it s not showing. How can Solve this issue?

图片转代码服务由CSDN问答提供 功能建议

为同一上级分配两个子名称(同名)时,只显示一个子级别。 我该如何解决这个问题?

 &lt; html&gt; 
&lt; head&gt; 
&lt; script type =“text / javascript”src =“https:// www  .google.com / jsapi“&gt;&lt; / script&gt; 
&lt; script type =”text / javascript“&gt; 
 google.load(”visualization“,”1“,{packages:[”orgchart“]  } ;; 
 google.setOnLoadCallback(drawChart); 
函数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&lt; div style =“color:red; font-style:italic”&gt; President&lt; / div&gt;'},'','The President'],
 [{v:'Jim',f:'Jim&lt;  div style =“color:red; font-style:italic”&gt;副总裁&lt; div&gt;'},'Mike','VP'],
 ['Alice','Mike',''],
  ['Alice','Mike',''],
 ['Bob','Jim','Bob Sponge'],
 ['Carol','Bob',''] 
]); \  n 
 var chart = new google.vi  sualization.OrgChart(document.getElementById('chart_div')); 
 chart.draw(data,{allowHtml:true}); 
} 
&lt; / script&gt; 
&lt; / head&gt; 
&lt; 正文&gt; 
&lt; div id =“chart_div”“&gt;&lt; / div&gt; 
&lt; / body&gt; 
&lt; / html&gt; 
   
 
 

小提琴链接: http://jsfiddle.net/kb24mcp1/

在上面的示例中, Mike 是第一级, Alice MIKE 的第一个孩子,当我为 MIKE 添加另一个孩子,其名称与 ALICE 没有显示时相同。 如何解决这个问题?

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • drag2458 2014-10-27 11:30
    已采纳

    I didnt find a Great answer but It worked for me. given a space for the second name and it worked.

    i.e

    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', ''],
              ['Alice ', 'Mike', ''],
              ['Bob', 'Jim', 'Bob Sponge'],
              ['Carol', 'Bob', '']
            ]);
    

    For the second 'Alice ' after the name I given a space. Which worked.

    已采纳该答案
    打赏 评论

相关推荐 更多相似问题