我有以下代码生成d组合图,该组合图是使用Javascript代码生成的:

<script type="text/javascript">
  google.setOnLoadCallback(drawVisualization);


  function drawVisualization() {
    // Some raw data (not necessarily accurate)
    var data = google.visualization.arrayToDataTable([
     ['Days', 'Seat Utilization', 'RevPash'],
     ['Monday',  .61,      34.33],
     ['Tuesday',  .59,      33.15],
     ['Wednesday',  .64,      34.83],
     ['Thursday',  .62,      32.85],
     ['Friday',  .73,      37.30],
     ['Saturday',  .89,      49.76],
     ['Sunday',  .87,      45.99]
  ]);
        var view = new google.visualization.DataView(data);
            view.setColumns([0, 1,
                            { //calc: "stringify",
                                sourceColumn: 1,
                                type: "number",
                                role: "annotation" },2]);
var options = {
  title : '',
  vAxes: {0: {title: "",titleTextStyle: {italic: false},gridlines: { color: 'transparent'}}, 1: {title: "",titleTextStyle: {italic: false},format: 'percent'},gridlines: { color: 'transparent'} },
  hAxis: {title: 'Days',titleTextStyle: {italic: false},gridlines: { color: 'transparent'},textStyle : {fontSize: 9 } },
  chartArea: {'width': '90%', 'height': '80%'},
  seriesType: 'bars',
  series: {1: {type: 'area'}},
  legend: { position: 'top' },
  height: 300,

  series: {
        1:{ type: "area", targetAxisIndex: 0, color:'#EA922B' },
        0:{ type: "bars", targetAxisIndex: 1, color:'#20488D' },
        2:{ type: "bars", targetAxisIndex: 1, color:'#94CAFC' },


    }
};

var chart = new google.visualization.ComboChart(document.getElementById('chart_combo'));
chart.draw(view, options);
 }
</script>


该图表如下所示:

javascript - 如何从使用Google图表生成的组合图中删除网格线-LMLPHP

我该怎么做才能删除网格线?我尝试了使网格线透明的选项,但是由于某些原因,它无法正常工作。我无法理解如何删除网格线。请帮忙

最佳答案

问题是vAxes gridlines1的定义中有错字...

gridlines: {color: 'transparent'}
在对象花括号外定义

从...改变
vAxes: {0: {title: "",titleTextStyle: {italic: false},gridlines: { color: 'transparent'}}, 1: {title: "",titleTextStyle: {italic: false},format: 'percent'},gridlines: { color: 'transparent'} }

至...
vAxes: {0: {title: "",titleTextStyle: {italic: false},gridlines: { color: 'transparent'}}, 1: {title: "",titleTextStyle: {italic: false},format: 'percent',gridlines: { color: 'transparent'}} }

关于javascript - 如何从使用Google图表生成的组合图中删除网格线,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/36740665/

10-11 05:44