Code
Execute
<!DOCTYPE html> <html> <head> <title>Google Charts tutorial 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, 07], [1, 1, 18], [2, 2, 27], [3, 3, 53], [4, 4, 84], [5, 5, 95], [6, 6, 76], [7, 7, 74], [8, 8, 83], [9, 9, 90], [10, 20, 62], [11, 1, 35], [12, 2, 50], [13, 3, 60], [14, 4, 82], [15, 5, 50], [16, 6, 46], [17, 7, 78], [18, 8, 86], [19, 9, 99], [20, 2, 44], [21, 1, 84], [22, 2, 96], [23, 3, 37], [24, 4, 40], [25, 5, 50], [26, 6, 62], [27, 7, 87], [28, 8, 89], [29, 9, 93] ]); 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>
Result