谷歌图表消除了空间

时间:2015-04-20 10:22:25

标签: javascript google-visualization

是否可以消除每两个条之间的空间然后添加空格?

看看我的例子:

google.load('visualization', '1', {packages: ['corechart', 'bar']});
google.setOnLoadCallback(drawBasic);

function drawBasic() {

  var data = new google.visualization.DataTable();
  data.addColumn('string', 'Time of Day');
  data.addColumn('number', 'Motivation Level');

  data.addRows([
    ["6/4/2015", 10] ,
      ["13/4/2015", 10] ,
      ["7/4/2015", 20] ,
      ["14/4/2015", 10] ,
    ["8/4/2015", 10] ,
  ]);

  var chart = new google.visualization.ColumnChart(
    document.getElementById('chart_div'));

  chart.draw(data, null);
}

1 个答案:

答案 0 :(得分:0)

看看以下小提琴。在代码中,我添加了options数组,并将bar值设置为99%。这样可以减少间距(我相信)。

var options = {
    bar: {
        groupWidth: "99%"
    },
};

chart.draw(data, options);

http://jsfiddle.net/mikeyfreake/ppnengec/