我在javascript中使用google's organization chart摆弄,但我无法弄清楚如何更改链接线的颜色和厚度。该文档仅讨论了节点的样式,但没有关于连接它们的链接。
如何设置链接样式?
答案 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>