最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to display both horizontal and vertical grid lines in google chart - Stack Overflow

programmeradmin1浏览0评论
  google.setOnLoadCallback(drawChart);

  function drawChart() {
      var data = google.visualization.arrayToDataTable([
          ['Year', 'Sales', 'Expenses'],
          ['2004', 1000, 400],
          ['2005', 1170, 460],
          ['2006', 660, 1120],
          ['2007', 1030, 540]
      ]);

      var options = {
          title: 'Company Performance',
      };

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

      chart.draw(data, options);
  }

this code only shows horizontal grid line, I want to show vertical lines also.

  google.setOnLoadCallback(drawChart);

  function drawChart() {
      var data = google.visualization.arrayToDataTable([
          ['Year', 'Sales', 'Expenses'],
          ['2004', 1000, 400],
          ['2005', 1170, 460],
          ['2006', 660, 1120],
          ['2007', 1030, 540]
      ]);

      var options = {
          title: 'Company Performance',
      };

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

      chart.draw(data, options);
  }

this code only shows horizontal grid line, I want to show vertical lines also.

Share Improve this question asked Sep 26, 2014 at 4:08 SuRuSuRu 7391 gold badge6 silver badges19 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 2

Check vAxis.gridlines and hAxis.gridlines in these docs.

vAxis.gridlines is an object with properties to configure the gridlines on the vertical axis. To specify properties of this object, you can use object literal notation, as shown here:

 {color: '#333', count: 4}

You can use the following in your options for the vertical gridlines:

vAxis.gridlines: {color: '#333', count: 4}

EDIT: See these examples:
http://jsfiddle/rdesai/R4DGp/2/
http://jsfiddle/8eCSW/1/

Hope it helps. :)

发布评论

评论列表(0)

  1. 暂无评论