Setting a hard minimum axis value in Google Charts API

后端 未结 2 1232
悲&欢浪女
悲&欢浪女 2020-12-08 09:24

I\'m trying to build a Google Chart to show some uptime and downtime percentages, stacked. This works great except for one small thing - I\'d like the baseline of the chart

相关标签:
2条回答
  • 2020-12-08 09:47

    you need to set viewWindow like this:

    var data = new google.visualization.DataTable();
    data.addColumn('string', 'Date');
    data.addColumn('number', 'Uptime');
    data.addColumn('number', 'Downtime');
    data.addRows([
     ['Dec 1, 1830',   99.875, 0.125],
      ['Dec 8, 1830',   99.675, 0.325],
      ['Dec 15, 1830',  99.975, 0.025],
      ['Dec 22, 1830',  100.0,  0.0]
    
    ]);
    
    var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
    chart.draw(data,
               {width: 400, 
                height: 240, 
                isStacked: true,
                vAxis: { 
                  title: "Percentage Uptime", 
                  viewWindowMode:'explicit',
                  viewWindow:{
                    max:100,
                    min:99.8
                  }
                }
                }                 
              );
    

    //edited for newer version of api

    0 讨论(0)
  • 2020-12-08 09:47

    I had a similar problem and had to specify the property as "min" not "minValue"

    vAxis: { 
        viewWindowMode:'explicit',
        viewWindow: {
            max:100,
            min:99.8
        }
    }
    
    0 讨论(0)
提交回复
热议问题