简体   繁体   English

如何从使用 Google Charts 生成的组合图中删除网格线

[英]How to remove gridlines from combo chart generated using Google Charts

I have the following code which generate da combo chart which I have generated using Javascript code:我有以下代码生成我使用 Javascript 代码生成的 da 组合图:

<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>

The chart looks like this:图表如下所示:

在此处输入图片说明

What shall I do to remove the gridlines??我该怎么做才能删除网格线? I have tried the option to make the gridlines transparant, but for some reason it is not working.我已经尝试过使网格线透明的选项,但由于某种原因它不起作用。 I am unable to understand that how I can remove the gridlines.我无法理解如何删除网格线。 Please help请帮忙

The problem is a typo in the definition for gridlines on vAxes 1 ...问题是 vAxes 1上的gridlines定义中的错字...

gridlines: {color: 'transparent'}
is defined outside the object curly braces在对象花括号外定义

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

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

vAxis: { gridlines: {color: 'none'} }

[eidt] 在这个谷歌文档开发者维基链接的小提琴中工作: https : //developers.google.com/chart/interactive/docs/datesandtimes#formatting-axis-gridline-and-tick-labels

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM