George
George

Reputation: 2093

google charts histogram not using histogram.bucketSize option

I'm trying to make a basic histogram with Google Charts, but for some reason it's not using the bin width that I set. Below is a code sample:

<html>
  <head>
    <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
    <script type="text/javascript">
      google.charts.load("current", {packages:["corechart"]});
      google.charts.setOnLoadCallback(drawChart);
      function drawChart() {
        var data = google.visualization.arrayToDataTable([
          ['MyData', 'Value']
                    , ['whatevs', .57]
                    , ['whatevs', .57]
                    , ['whatevs', .57]
                    , ['whatevs', .8]
                    ]);

        var options = {
          title: 'My Histogram'
          , legend: { position: 'none' }
                    , histogram: {
                        bucketSize: .1
                    }
        };

        var chart = new google.visualization.Histogram(document.getElementById('chart_div'));
        chart.draw(data, options);
      }
    </script>
  </head>
  <body>
    <div id="chart_div" style="width: 900px; height: 500px;"></div>
  </body>
</html>

and here's an image of what happens:

enter image description here

but what I would like to happen would be for the bins to be uniformly sized at a width of 0.1.

Upvotes: 3

Views: 736

Answers (2)

George
George

Reputation: 2093

It seems like this is the result of a bug that can be fixed by adding hAxis: { type: 'category' } to the options.

Upvotes: 1

Kevin Schellenberg
Kevin Schellenberg

Reputation: 845

This appears to be a bug introduced in Charts API version 44. You can roll back to version 43 by specifying the version number when you load the library:

google.charts.load("43", {packages:["corechart"]});

Upvotes: 3

Related Questions