3

我正在尝试使用 Google 图表,下面提供的示例必须保持其大小以适合我的布局。

http://jsfiddle.net/eSKzR/

<html>
  <head>
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript">
      google.load("visualization", "1", {packages:["corechart"]});
      google.setOnLoadCallback(drawChart);
      function drawChart() {
        var data = google.visualization.arrayToDataTable([
          ['Year', 'Max'],
          ['00h',  1],
          ['01h',  1],
          ['02h',  1],
          ['03h',  1],
          ['04h',  0],
          ['05h',  20],
          ['06h',  40],
          ['07h',  3],
          ['08h',  1],
          ['09h',  1],
          ['10h',  1],
          ['12h',  1],
          ['13h',  1],
          ['14h',  1],
          ['15h',  1],
          ['16h',  1],
          ['17h',  1],
          ['18h',  1],
          ['19h',  0],
          ['20h',  0],
          ['21h',  0],
          ['22h',  1],
          ['now',  1],
        ]);

        var options = { };

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

底部的小时数是重叠的,我想知道你是否可以将它们侧向转动,它们在哪里垂直?

4

2 回答 2

1

文档中

var options = {
    hAxis: { slantedText: true, slantedTextAngle: 90 }
};

更新小提琴:http: //jsfiddle.net/eSKzR/15/

于 2012-09-13T13:10:18.843 回答
1

选项中设置:

var options = {
    hAxis:
       {
         slantedText : true,
         slantedTextAngle: 90
        }
    };
于 2012-09-13T13:10:24.760 回答