如何设置注释文本或值的方向

时间:2017-09-19 03:31:55

标签: javascript charts google-visualization

我开始使用Google Visualization为我的网络学习。

我的注释有些问题。注释文本堆积如山,在我看来,如果数据无法读取,则数据无用

the annotation text is pile up, in my opinion the data is useless if its cannot read

这是我的注释代码

var options = {
    width: 1200,
    height: 680,
    vAxis: {title: 'QTY'},
    hAxis: {title: 'DAYS'},
    legend: { position: 'center', maxLines: 3 },
    bar: { groupWidth: '80%' },
    isStacked: true,
    title : 'PRODUCTION BY PROCESS <?php echo $proc;?> SECTION <?php echo $fact;?> <?php echo $Date ?> ',
    series: {20: {type: 'line'}}
};

如何将注释文本或值的方向设置为逆时针或使注释文本不像图像那样堆积。

1 个答案:

答案 0 :(得分:1)

要旋转注释,请将@RequestBody更改为style

'line'

请参阅以下工作代码段...

var options = {
  annotations: {
    style: 'line'
  }
};
google.charts.load('current', {
  callback: drawChart,
  packages: ['corechart']
});

function drawChart() {
  var data = google.visualization.arrayToDataTable([
    [
      "x",
      "y0",
      "y1",
      "y2",
      "y3"
    ],
    ["29-04-2017", 212558.50, 212558.2, 212558.4, 212555.5],
    ["13-05-2017", 212558.60, 212558.32, 212558.53, 212555.67],
    ["12-06-2017", 212558.30, 212558.72, 212558.13, 212555.37],
    ["23-08-2017", 212558.50, 212558.22, 212558.43, 212555.57]
  ]);

  var viewColumns = [0];
  $.each(new Array(data.getNumberOfColumns() - 1), function (index) {
    viewColumns.push(index + 1);
    viewColumns.push({
      calc: function (dt, row) {
        return dt.getFormattedValue(row, index + 1);
      },
      role: 'annotation',
      type: 'string'
    });
  });
  var view = new google.visualization.DataView(data);
  view.setColumns(viewColumns);

  var options = {
    annotations: {
      style: 'line'
    },
    colors: ["#0F5470", "#8EA3A4", "#3EB8BC", "#98D4F2"]
  };

  var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
  chart.draw(view, options);
}