set x Axis range in google chart

前端 未结 3 1962
栀梦
栀梦 2020-12-15 05:39

I try to create bar chart using google chart example

    var data = new google.visualization.DataTable();
    data.addColumn(\'string\', \'Topping\');

    d         


        
相关标签:
3条回答
  • 2020-12-15 06:30

    Set the tick values:

    vAxis: { 
             ticks: [{v:0, f:'0%'},{v:10, f:'10%'},{v:20, f:'20%'},{v:30, f:'30%'}]
    }
    
    0 讨论(0)
  • 2020-12-15 06:30

    u can set x axis by modifing count value as we are using DataTable()

    var databmi = new google.visualization.DataTable();

     data.addColumn('string', 'Country');
          data.addColumn('number', 'GDP');
          data.addRows([
            ['US', 16768100],
            ['China', 9181204],
            ['Japan', 4898532],
            ['Germany', 3730261],
            ['France', 2678455]
          ]);
    
         var options = {
           title: 'GDP of selected countries, in US $millions',
           width: 500,
           height: 300,
           legend: 'none',
           bar: {groupWidth: '95%'},
           vAxis: { 
                 title :'your choice',
                 gridlines: { count: 4 } 
                  },
            hAxis: {
                   title :'your choice',
                    gridlines: {count: 4}
                  }
         };
    
    0 讨论(0)
  • 2020-12-15 06:44

    You can force the x-axis of a BarChart to always show a certain range by setting the hAxis.viewWindow.min and hAxis.viewWindow.max options:

    hAxis: {
        viewWindow: {
            min: 0,
            max: 100
        },
        ticks: [0, 25, 50, 75, 100] // display labels every 25
    }
    
    0 讨论(0)
提交回复
热议问题