Combo chart showing negative axis for zero values

127 views
Skip to first unread message

James Spibey

unread,
Apr 25, 2012, 5:22:03 AM4/25/12
to google-visua...@googlegroups.com
Hi

I'm using the combo chart to show some stats. The left x axis shows a bar chart and the right x-axis shows line charts.

However, I have a problem when the left x-axis has zero values for the series, but the right x-axis does have values as you can see in the screenshot below


The left x-axis shows a range of between -1 and +1 when it should just be zero. I've tried playing with the minValue and maxValue of the vAxis property but to no avail.

How can I fix this?

Thanks

James

asgallant

unread,
Apr 25, 2012, 10:44:23 AM4/25/12
to google-visua...@googlegroups.com
Try setting the bar's axis viewWindowMode option to 'explicit' and the viewWindow.min option to 0.

James Spibey

unread,
Apr 28, 2012, 12:38:10 PM4/28/12
to google-visua...@googlegroups.com
Thanks for that - that pretty much solved the problem.

Naresh

unread,
Nov 21, 2018, 12:57:56 AM11/21/18
to Google Visualization API
Hi,
Following is the code I have used to display only positive values in the axis but still its showing negative axis for zero values.Can you please suggest the solution for this problem.

<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
google.charts.load('current', {
  'packages': ['corechart']
});
google.charts.setOnLoadCallback(drawVisualization);
    
    function drawVisualization() {
        // Some raw data (not necessarily accurate)
        var data = google.visualization.arrayToDataTable([
            ['Method', 'Result size', 'conversion time (in seconds)'],
            ['veryfast',   0,    0],
            ['faster',     0,    0],
            ['fast',       0,    0],
            ['medium',     0,   0],
            ['slow',       0,   0],
            ['slower',     0,   0],
            ['veryslow',   0,  0]
        ]);
            
        var options = {
            title : 'ffmpeg preset comparison',
           vAxes: {
      // Adds titles to each axis.
      0: {
          viewWindow: { min: 0 },
        viewWindowMode: 'explicit'
      },
      1: {
      
        viewWindow: { min: 0 },
        viewWindowMode: 'explicit'
      }
    },
            //vAxis.baseline: 0,
            
            seriesType: 'bars',
            series: {
                5: {type: 'line', targetAxisIndex: 1}
            }
            };
            
        var chart = new google.visualization.ComboChart(document.getElementById('chart_div'));
        chart.draw(data, options);
Reply all
Reply to author
Forward
0 new messages