小编Aur*_*x22的帖子

JS - 如何在 Google Graphs (slantedText) 上旋转标签 (hAxis)?

我一直试图简单地在下图上旋转我的 hAxis 很长时间了。尝试了以下解释的几种解决方案!不敢相信这么简单的事情似乎很难做到。源代码如下:

<html>

 <title>VM Allocation Performance</title>
 <meta http-equiv="refresh" content="30">

    <head>



        <script type="text/javascript" src="http://www.google.com/jsapi"></script>
        <script type="text/javascript">

        google.load("visualization", "1", {packages:["bar"]});
        google.setOnLoadCallback(drawChart);



            function drawChart() {
                var data = google.visualization.arrayToDataTable([
                ['09/12/2015 10:00:00',3.52],['09/12/2015 10:30:00',7.56],['09/12/2015 11:00:00',8.99],['09/12/2015 11:30:00',4.93],['09/12/2015 12:00:00',10.26],['09/12/2015 12:30:00',9.82],['09/12/2015 13:00:00',12.62],['09/12/2015 13:30:00',9.07],['09/12/2015 14:00:00',4.94],['09/12/2015 14:30:00',8.98],['09/12/2015 15:00:00',7.85],['09/12/2015 15:30:00',3.59],['09/12/2015 16:00:00',5.64]],true);              


            var options = {
                    chart: {
                            title: 'VM Allocation',
                            subtitle: 'Since Shift Start',
                    }
//I tried with slantedText: true here but while my graph was rendering, labels were not rotated!
                    };              

                var chart = new google.charts.Bar(document.getElementById('chart_div'));
                chart.draw(data, google.charts.Bar.convertOptions(options));
            } …
Run Code Online (Sandbox Code Playgroud)

html javascript axis graph google-visualization

2
推荐指数
1
解决办法
3179
查看次数

Java检查字符串变量长度(带子串)

我有一个String变量,每次运行时都可以有不同的长度.有了它,我会检查它的开头,例如:

 public void defineLocation(){
            if (newLocation.substring(0,2).equals("DO") || newLocation.substring(0,2).equals("30") || newLocation.substring(0,2).equals("21")) {
                locationInDc = "DOOR";
            } else if (newLocation.substring(0,2).equals("VT") || newLocation.substring(0,3).equals("MUF")) {
                locationInDc = "BLOUBLOU";
            } else if (newLocation.substring(0,3).equals("MAH")) {
                locationInDc = "BLOBLO";           
            } else if (newLocation.substring(0,7).equals("Zone 72") || newLocation.substring(0,7).equals("Zone 70")){
                locationInDc = "BLOFBLOF";
}
Run Code Online (Sandbox Code Playgroud)

我知道这不是最有效的方式,它必然会破坏,如果我的变量不在前3个检查中的任何一个但仍然具有比7更少的字符,那么它将抛出错误.

有没有更"正确"的方法来做到这一点?我应该首先检查字符串包含多少个字符,然后将其指向正确的检查/"ifs"?谢谢.

java string if-statement substring case

1
推荐指数
1
解决办法
682
查看次数