Google折线图起始坐标? [英] Google Line Chart starting coordinate?

查看:143
本文介绍了Google折线图起始坐标?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何设置折线图设置,使得行从x:0开始,而不是以某种随机方式?

How to set the line chart setting so lines begin at x:0 , and not in some random way?

有没有道具,或者我需要堆叠更多的数据

Is there a prop for this, or i need to stack up more data????

推荐答案

如果你的x值是数字,你可以给选项 hAxis:{minValue :0} 到绘制函数:

If your x values are numeric you can give the option hAxis: {minValue:0} to the draw function :

function drawVisualization() {
  // Create and populate the data table.
  var data = new google.visualization.DataTable();
  data.addColumn('number', 'x');
  data.addColumn('number', 'Cats');
  data.addColumn('number', 'Blanket 1');
  data.addColumn('number', 'Blanket 2');
  data.addRow([0, 1, 1, 0.5]);
  data.addRow([1, 2, 0.5, 1]);
  data.addRow([2, 4, 1, 0.5]);
  data.addRow([3, 8, 0.5, 1]);
  data.addRow([4, 7, 1, 0.5]);
  data.addRow([5, 7, 0.5, 1]);
  data.addRow([6, 8, 1, 0.5]);
  data.addRow([7, 4, 0.5, 1]);
  data.addRow([8, 2, 1, 0.5]);
  data.addRow([9, 3.5, 0.5, 1]);

  // Create and draw the visualization.
  new google.visualization.LineChart(document.getElementById('visualization')).
      draw(data, {curveType: "function",
                  width: 900, height: 400,
                  hAxis: {minValue:0},
                  vAxis: {maxValue: 10}}
          );
}

请尝试此处的代码: http://code.google.com/apis/ajax/playground/?type=visualization#line_chart

这篇关于Google折线图起始坐标?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆