- 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 圖表配置語法 章節中學到了繪製此類圖表的配置資訊。下面展示一個完整的示例。
配置
我們使用 Calendar 類顯示基於日曆的圖表。
//Calendar chart
var chart = new google.visualization.Calendar(document.getElementById('container'));
示例
googlecharts_calendar_basic.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: ['corechart','calendar']});
</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({ type: 'date', id: 'Date' });
data.addColumn({ type: 'number', id: 'Students' });
data.addRows([
[ new Date(2012, 3, 13), 50 ],
[ new Date(2012, 3, 14), 50 ],
[ new Date(2012, 3, 15), 49 ],
[ new Date(2012, 3, 16), 48 ],
[ new Date(2012, 3, 17), 50 ],
[ new Date(2012, 4, 1), 50 ],
[ new Date(2012, 4, 2), 50 ],
[ new Date(2012, 4, 3), 49 ],
[ new Date(2012, 4, 4), 48 ],
[ new Date(2012, 4, 5), 50 ],
[ new Date(2012, 5, 4), 40 ],
[ new Date(2012, 5, 5), 50 ],
[ new Date(2012, 5, 10), 48 ],
[ new Date(2012, 5, 11), 50 ],
[ new Date(2012, 5, 12), 42 ],
[ new Date(2012, 5, 20), 45 ],
[ new Date(2012, 5, 21), 46 ],
[ new Date(2012, 5, 29), 45 ],
[ new Date(2013, 3, 13), 40 ],
[ new Date(2013, 3, 14), 40 ],
[ new Date(2013, 3, 15), 39 ],
[ new Date(2013, 3, 16), 38 ],
[ new Date(2013, 3, 17), 40 ],
[ new Date(2013, 4, 1), 40 ],
[ new Date(2013, 4, 2), 40 ],
[ new Date(2013, 4, 3), 49 ],
[ new Date(2013, 4, 4), 48 ],
[ new Date(2013, 4, 5), 40 ],
[ new Date(2013, 5, 4), 40 ],
[ new Date(2013, 5, 5), 50 ],
[ new Date(2013, 5, 12), 48 ],
[ new Date(2013, 5, 13), 40 ],
[ new Date(2013, 5, 19), 32 ],
[ new Date(2013, 5, 23), 45 ],
[ new Date(2013, 5, 24), 36 ],
[ new Date(2013, 5, 30), 45 ]
]);
// Set chart options
var options = {'title':'Attendence', 'width':550, 'height':400};
// Instantiate and draw the chart.
var chart = new google.visualization.Calendar(document.getElementById('container'));
chart.draw(data, options);
}
google.charts.setOnLoadCallback(drawChart);
</script>
</body>
</html>
結果
驗證結果。
googlecharts_calendar_charts.htm
廣告