Nuage de points avec double axe Y

Voici un exemple de diagramme de dispersion de matériau avec double axe Y. Nous avons déjà vu la configuration utilisée pour dessiner ce graphique dans le chapitre Syntaxe de configuration de Google Charts . Alors, voyons l'exemple complet.

Configurations

Nous avons utilisé axes.y configuration pour afficher deux axes y.

// Set chart options
var options = { 
   axes: {
      y: {
         'hours studied': {label: 'Hours Studied'},
         'final grade': {label: 'Final Exam Grade'}
      }
   }
};

Exemple

googlecharts_scatter_dualy.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','scatter']});     
      </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('number', 'Student ID');
            data.addColumn('number', 'Hours Studied');
            data.addColumn('number', 'Final');

            data.addRows([
               [0, 0, 67],  [1, 1, 88],   [2, 2, 77],
               [3, 3, 93],  [4, 4, 85],   [5, 5, 91],
               [6, 6, 71],  [7, 7, 78],   [8, 8, 93],
               [9, 9, 80],  [10, 10, 82], [11, 0, 75],
               [12, 5, 80], [13, 3, 90],  [14, 1, 72],
               [15, 5, 75], [16, 6, 68],  [17, 7, 98],
               [18, 3, 82], [19, 9, 94],  [20, 2, 79],
               [21, 2, 95], [22, 2, 86],  [23, 3, 67],
               [24, 4, 60], [25, 2, 80],  [26, 6, 92],
               [27, 2, 81], [28, 8, 79],  [29, 9, 83]
            ]);

            var options = {
               chart: {
                  title: 'Students\' Final Grades',
                  subtitle: 'based on hours studied'
               },
               width: 800,
               height: 500,
               series: {
                  0: {axis: 'hours studied'},
                  1: {axis: 'final grade'}
               },
               axes: {
                  y: {
                     'hours studied': {label: 'Hours Studied'},
                     'final grade': {label: 'Final Exam Grade'}
                  }
               }
            };
            // Instantiate and draw the chart.
            var chart = new google.charts.Scatter(document.getElementById('container'));
            chart.draw(data, google.charts.Scatter.convertOptions(options));
         }
         google.charts.setOnLoadCallback(drawChart);
      </script>
   </body>
</html>

Résultat

Vérifiez le résultat.