- Google 圖表教程
- Google 圖表 - 首頁
- Google 圖表 - 概覽
- Google 圖表 - 環境設定
- 配置語法
- Google 圖表 - 區域圖表
- Google 圖表 - 條形圖
- Google 圖表 - 氣泡圖
- Google 圖表 - 日曆圖表
- Google 圖表 - 蠟燭圖
- Google 圖表 - 柱狀圖
- Google 圖表 - 組合圖表
- Google 圖表 - 直方圖
- Google 圖表 - 折線圖
- Google 圖表 - 地圖
- Google 圖表 - 組織結構圖
- Google 圖表 - 餅圖
- Google 圖表 - Sankey 圖表
- Google 圖表 - 散點圖
- 階梯面積圖
- Google 圖表 - 表格圖表
- Google 圖表 - 時間軸圖表
- Google 圖表 - TreeMap 圖表
- Google 圖表 - 趨勢線圖表
- Google 圖表有用資源
- Google 圖表 - 快速指南
- Google 圖表 - 有用資源
- Google 圖表 - 討論
Google 圖表 - 組合圖表
組合圖表有助於將每個系列呈現為以下列表中不同的標記型別:折線、面積、條形、蠟燭和階梯區域。要為系列分配預設標記型別,請使用 seriesType 屬性。Series 屬性用於分別指定每個系列的屬性。我們在 Google 圖表配置語法 一章中已經看到了用於繪製此圖表的配置。那麼,我們來看看一個完整的示例。
配置
我們使用 ComboChart 類來顯示基於組合的圖表。
//combination chart
var chart = new google.visualization.ComboChart(document.getElementById('container'));
示例
googlecharts_combination_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: ['corechart']});
</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 = google.visualization.arrayToDataTable([
['Fruit', 'Jane', 'John', 'Average'],
['Apples', 3, 2, 2.5],
['Oranges', 2, 3, 2.5],
['Pears', 1, 5, 3],
['Bananas', 3, 9, 6],
['Plums', 4, 2, 3]
]);
// Set chart options
var options = {
title : 'Fruits distribution',
vAxis: {title: 'Fruits'},
hAxis: {title: 'Person'},
seriesType: 'bars',
series: {2: {type: 'line'}}
};
// Instantiate and draw the chart.
var chart = new google.visualization.ComboChart(document.getElementById('container'));
chart.draw(data, options);
}
google.charts.setOnLoadCallback(drawChart);
</script>
</body>
</html>
結果
驗證結果。
廣告