0

如何删除这些堆叠列之间的水平白线?

在此处输入图像描述

这是我的代码:

<html>
<head>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">

google.charts.load('current', {'packages':['corechart']});

google.charts.setOnLoadCallback(drawChart);

function drawChart() {
    var data = google.visualization.arrayToDataTable([
        ['Genre', 'One', 'Two'],
        ['2010', 10, 24],
        ['2020', 16, 22]
    ]);

    var options = {
        width: 300,
        height: 200,
        legend: 'none',
        bar: { groupWidth: '100%' },
        isStacked: true,
        series: { 
            0: { color: '#40a1ec' }, 
            1: { color: '#ff8888'} 
        },          
    };

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

    chart.draw(data, options);
}
</script>
</head>

<body>
<div id="chart_div"></div>
</body>
</html>

我知道如何删除条之间的垂直空白(使用 groupWidth),但我找不到删除水平白线的方法。

谢谢!

4

1 回答 1

1

我认为唯一的方法是将CSS 样式添加到列中,以使 stroke 不为空:

google.charts.load('current', {
  'packages': ['corechart']
});

google.charts.setOnLoadCallback(drawChart);

function drawChart() {
  var data = google.visualization.arrayToDataTable([
    ['Genre', 'One', { role: 'style' }, 'Two', { role: 'style' } ],
    ['2010', 10,  'stroke-width: 1;stroke-color: blue;', 24,'stroke-width: 1;stroke-color: red;'],
    ['2020', 16, 'stroke-width: 1;stroke-color: blue;', 22, 'stroke-width: 1;stroke-color: red;']
  ]);
  var options = {
    width: 400,
    height: 400,
    legend: 'none',
    bar: {
      groupWidth: '100%'
    },
    isStacked: true,
    series: {
      0: {color: '#40a1ec'},
      1: {color: '#ff8888'}
    }
  };
  var chart = new google.visualization.ColumnChart(document.getElementById('chart_div'));
  chart.draw(data, options);
}
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>

<div id="chart_div">
</div>

于 2018-01-31T10:53:13.373 回答