Rounding value in google Scatter chart - Javascript Google Chart

Javascript examples for Google Chart:Chart Configuration

Description

Rounding value in google Scatter chart

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 w w  w . j av a 2s  . c  om
        var data = google.visualization.arrayToDataTable([
          ['Age', 'Weight'],
          [ 8,      3.535778],
          [ 4,      5.5],
          [ 11,     14],
          [ 4,      5],
          [ 3,      3.535678],
          [ 6.5,    7]
        ]);
       var NumberFormat = new google.visualization.NumberFormat({pattern:'##.#######'});
       NumberFormat.format(data, 1);
        var options = {
          title: 'Age vs. Weight comparison',
          hAxis: {title: 'Age', minValue: 0, maxValue: 15},
          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