谷歌图表api材料日期月

时间:2016-04-04 08:48:17

标签: google-visualization

我有一个包含多个系列和日期hAxis的谷歌条形图。

我的问题是我只想展示几个月,但我多次获得标签。 这是一个例子

google.charts.load('current', {'packages': ['bar'], 'language': 'de'});
google.charts.setOnLoadCallback(drawChart);

function drawChart() {

  var chart;
  var chartDiv = document.getElementById('test');

  var data = new google.visualization.DataTable('{"cols":[{"type":"date","pattern":""},{"type":"number"},{"type":"number"},{"type":"number"},{"type":"number"},{"type":"number"},{"type":"number"},{"type":"number"}],"rows":[{"c":[{"v":"Date(2016,2,1)"},{"v":2030,"f":"2030 km"},{"v":2098,"f":"2098 km"},{"v":1352,"f":"1352 km"},{"v":4412,"f":"4412 km"},{"v":132,"f":"132 km"},{"v":2435,"f":"2435 km"},{"v":3952,"f":"3952 km"}]},{"c":[{"v":"Date(2016,3,1)"},{"v":3177,"f":"3177 km"},{"v":2901,"f":"2901 km"},{"v":2491,"f":"2491 km"},{"v":1480,"f":"1480 km"},{"v":2272,"f":"2272 km"},{"v":400,"f":"400 km"},{"v":1096,"f":"1096 km"}]}]}');

  var options = {
    legend: { position: 'none' },
    hAxis: {
      type: 'category',
      format: 'MMMM'
    }
  };

  chart = new google.charts.Bar(chartDiv);
  chart.draw(data, google.charts.Bar.convertOptions(options));

}

https://jsfiddle.net/1Lusd06n/3/

如果我缩小小提琴的宽度,月份名称将被分组并显示一次,但如果有更多空格则不会发生这种情况。

0 个答案:

没有答案