- Google 圖表教程
- Google 圖表 - 主頁
- Google 圖表 - 概覽
- Google 圖表 - 環境設定
- 配置語法
- Google 圖表 - 區域圖表
- Google 圖表 - 條形圖
- Google 圖表 - 氣泡圖
- Google 圖表 - 日曆圖表
- Google 圖表 - 蠟燭棒圖
- Google 圖表 - 柱狀圖
- Google 圖表 - 組合圖
- Google 圖表 - 柱狀圖
- Google 圖表 - 折線圖
- Google 圖表 - 地圖
- Google 圖表 - 組織結構圖
- Google 圖表 - 餅圖
- Google 圖表 - 桑基圖
- Google 圖表 - 散點圖
- 階梯區域圖
- Google 圖表 - 表格圖
- Google 圖表 - 時間線圖
- Google 圖表 - 樹形圖
- Google 圖表 - 趨勢線圖表
- Google 圖表有用資源
- Google 圖表 - 快速指南
- Google 圖表 - 有用資源
- Google 圖表 - 討論
Google 圖表 - 組織結構圖
組織結構圖有助於呈現節點層次,用於描繪組織內的上級/下級關係。例如,家譜就是一種組織結構圖。我們已經在 Google 圖表配置語法 章節中看到了用於繪製此圖表所用的配置。因此,讓我們來看一下完整的示例。
配置
我們使用了 OrgChart 類來顯示基於組織的圖表。
//organization chart
var chart = new google.visualization.OrgChart(document.getElementById('container'));
示例
googlecharts_organization_chart.htm
<html>
<head>
<title>Google Charts Tutorial</title>
<script type = "text/javascript" src = "https://www.gstatic.com/charts/loader.js">
</script>
<script type = "text/javascript">
google.charts.load('current', {packages: ['orgchart']});
</script>
</head>
<body>
<div id = "container" style = "width: 550px; height: 400px; margin: 0 auto">
</div>
<script language = "JavaScript">
function drawChart() {
// Define the chart to be drawn.
var data = new google.visualization.DataTable();
data.addColumn('string', 'Name');
data.addColumn('string', 'Manager');
data.addColumn('string', 'ToolTip');
// For each orgchart box, provide the name, manager, and tooltip to show.
data.addRows([
[{v:'Robert', f:'Robert<div style="color:red; font-style:italic">President</div>'},'', 'President'],
[{v:'Jim', f:'Jim<div style="color:red; font-style:italic">Vice President</div>'},'Robert', 'Vice President'],
['Alice', 'Robert', ''],
['Bob', 'Jim', 'Bob Sponge'],
['Carol', 'Bob', '']
]);
// Set chart options
var options = {allowHtml:true};
// Instantiate and draw the chart.
var chart = new google.visualization.OrgChart(document.getElementById('container'));
chart.draw(data, options);
}
google.charts.setOnLoadCallback(drawChart);
</script>
</body>
</html>
結果
驗證結果。
廣告