Google Charts - Vertical Axis - 系列标签上的自动换行(垂直图表)

时间:2018-02-23 15:46:34

标签: google-apps-script google-visualization

我正在尝试在图表的系列标签上创建换行符或自动换行。使用' \ n'当我创建一个水平方向的图表时,它可以工作:

Word wrapping - horizontal orientation

然而,只要我在垂直方向尝试换行,标签就会以' ...'结束,即使垂直系列轴上有足够的宽度(鼠标的蓝色轮廓)悬停)为文本: Word wrapping - vertical orientation

注意:我使用Google Charts作为我的图表生成器,Google Sheets作为我的容器。

谢谢!

方向设置为'垂直'

的代码段
<!DOCTYPE html>
<html>
  <head>
    <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
    <script type="text/javascript">
      google.charts.load('current', {'packages':['corechart']});
      google.charts.setOnLoadCallback(drawVisualization);

      function drawVisualization() {
        var data = google.visualization.arrayToDataTable([
          ['Metric 1\n Desc of Metric', 20, 28, 38, 45, 50],
          ['Metric 2\n Desc of Metric', 31, 38, 55, 66, 50],
          ['Metric 2\n Desc of Metric', 50, 55, 77, 80, 50],
          ['Metric 2\n Desc of Metric', 77, 77, 66, 50, 50]
          // Treat first row as data as well.
        ], true);

        var options = {
          title : 'Metrics and Values',
          vAxis: {title: 'Values'},
          hAxis: {title: 'Metrics'},
          seriesType: 'candlesticks',
          isStacked: true,
          orientation: 'vertical',
          series: {
            //0: {color: 'white', stroke-width: 4},
            1: {type: 'line', pointShape: 'circle', pointSize: 15, lineWidth: 0}
          },
          chartArea: {  width: "50%", height: "70%" }
        };

        var chart = new google.visualization.ComboChart(document.getElementById('chart_div'));
        chart.draw(data, options);

    </script>
  </head>
  <body>
    <div id="chart_div" style="width: 900px; height: 500px;"></div>
  </body>
</html>

0 个答案:

没有答案