Googlecharts-combination-chart

提供:Dev Guides
移動先:案内検索

Googleチャート-組み合わせチャート

組み合わせグラフは、各シリーズを、ライン、エリア、バー、ローソク足、および階段状エリアのリストから異なるマーカータイプとしてレンダリングするのに役立ちます。 シリーズにデフォルトのマーカータイプを割り当てるには、seriesTypeプロパティを使用します。 シリーズプロパティを使用して、各シリーズのプロパティを個別に指定します。 link:/googlecharts/googlecharts_configuration_syntax [Googleグラフの構成構文]の章で、このグラフを描画するために使用される構成を見てきました。 それでは、完全な例を見てみましょう。

構成

*ComboChart* クラスを使用して、組み合わせベースのチャートを表示しました。
//combination chart
var chart = new google.visualization.ComboChart(document.getElementById('container'));

googlecharts_combination_chart

<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>

結果

結果を確認します。