Sunday, April 26, 2015

Google Scatter Chart Example

Below is a scatter chart code. The intention is to plot the frequency of request in Y axis and the clock time on the X axis.

JSFiddler out put is below



 google.setOnLoadCallback(drawChart);
      function drawChart() {
        var data = google.visualization.arrayToDataTable([
          ['Time', 'Interval'],
          [ .30,      30],
          [ 1.00,      27],
          [ 1.30,     29],
          [ 2.00,      35],
          [ 3.00,      60],
          [ 3.30,    30]
        ]);

        var options = {
          title: 'Request Frequency scatter chart',
          hAxis: {title: 'Time', minValue: 0, maxValue: 2},
          vAxis: {title: 'Interval', minValue: 0, maxValue: 60},
          legend: 'none'
        };

        var chart = new google.visualization.ScatterChart(document.getElementById('chart_div'));

        chart.draw(data, options);
      }

References:
https://developers.google.com/chart/interactive/docs/gallery/scatterchart

No comments:

Post a Comment