Scatter chart Creation - Javascript Google Chart

Javascript examples for Google Chart:Chart Configuration

Description

Scatter chart Creation

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>Scatter Chart Example</title> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
   </head> 
   <body> 
      <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> 
      <div id="chart_div" style="width: 900px; height: 500px;"></div> 
      <script type="text/javascript">
      google.charts.load('current', {'packages':['corechart']});
      google.charts.setOnLoadCallback(drawChart);
      function drawChart() {//from   ww  w.  j a  v a2 s.com
        var data = google.visualization.arrayToDataTable([
          ['Age', 'Weight'],
          [ 2006,      0],
          [ 2007,      0],
          [ 2008,     0],
          [ 2009,      0],
          [ 2010,      0],
          [ 2011,    0],
          [ 2012,    0],
          [ 2013,    0],
          [ 2014,    0],
          [ 2015,    1280],
          [ 2016,    80500],
        ]);
        var options = {
          title: 'Age vs. Weight comparison',
          hAxis: {title: 'Age', minValue:2005, maxValue: 2020},
          vAxis: {title: 'Weight', minValue: 0, maxValue: 15},
          legend: 'none'
        };
        var chart = new google.visualization.ScatterChart(document.getElementById('chart_div'));
        chart.draw(data, options);
      }

      </script>  
   </body>
</html>

Related Tutorials