如何更改Google Organization Chart链接线颜色&厚度?

时间:2018-03-31 00:08:12

标签: javascript charts hyperlink styles organization

我在javascript中使用google's organization chart摆弄,但我无法弄清楚如何更改链接线的颜色和厚度。该文档仅讨论了节点的样式,但没有关于连接它们的链接。

如何设置链接样式?

1 个答案:

答案 0 :(得分:0)

连接节点的行没有配置选项

但您可以覆盖用于设置这些线条样式的CSS

此处,使用css border属性

更改厚度和颜色
#chart_div .google-visualization-orgchart-linebottom {
  border-bottom: 4px solid magenta;
}

#chart_div .google-visualization-orgchart-lineleft {
  border-left: 4px solid magenta;
}

#chart_div .google-visualization-orgchart-lineright {
  border-right: 4px solid magenta;
}

#chart_div .google-visualization-orgchart-linetop {
  border-top: 4px solid magenta;
}

请参阅以下工作代码段...

google.charts.load('current', {
  packages: ['orgchart']
}).then(function () {
  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});
});
#chart_div .google-visualization-orgchart-linebottom {
  border-bottom: 4px solid magenta;
}

#chart_div .google-visualization-orgchart-lineleft {
  border-left: 4px solid magenta;
}

#chart_div .google-visualization-orgchart-lineright {
  border-right: 4px solid magenta;
}

#chart_div .google-visualization-orgchart-linetop {
  border-top: 4px solid magenta;
}
<script src="https://www.gstatic.com/charts/loader.js"></script>
<div id="chart_div"></div>