7

我正在使用 Google 饼图 API。

一切正常,除了 stroke: 和 strokeWidth: 的选项。无论我将它们设置为什么,都没有任何变化。

我的背景颜色很深,切片之间的线条是白色的。我正在尝试将它们更改为与背景相同的颜色。我也不能改变这些线条的宽度。

这是我的代码:

<script src="https://www.google.com/jsapi"></script>
<script>

google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);

function drawChart() {

    var data = new google.visualization.DataTable();
    data.addColumn('string', 'Task');
    data.addColumn('number', 'Hours per Day');
    data.addRows(5);
    data.setValue(0, 0, 'Work');
    data.setValue(0, 1, 11);
    data.setValue(1, 0, 'Eat');
    data.setValue(1, 1, 2);
    data.setValue(2, 0, 'Commute');
    data.setValue(2, 1, 2);
    data.setValue(3, 0, 'Watch TV');
    data.setValue(3, 1, 2);
    data.setValue(4, 0, 'Sleep');
    data.setValue(4, 1, 7);

    // Create and draw the visualization.
    new google.visualization.PieChart(document.getElementById('poll-chart')).
    draw(data, {

        title:"",
        fontSize: "12",
        legend: "none",
        width: 200,
        height: 200,
        chartArea: { left: 0, top: 0, width: "100%", height: "100%"},
        backgroundColor: { stroke: "#5A5A5A", strokeWidth: 5, fill: "#5A5A5A" }

    });
}

</script>

我在此页面上的选项中引用了 Google API:

http://code.google.com/apis/chart/interactive/docs/gallery/piechart.html#Configuration_Options

我不确定我是否做错了什么。

您的帮助或指导将不胜感激!

谢谢,迈克尔。

编辑:

好的,看来我搞砸的属性与整个图表的外部笔划有关,而不是每个切片。我仍然被困住了。有谁知道我怎样才能关闭切片之间的白色间隙?我在 Google 上找不到任何关于此的内容。

4

1 回答 1

11

使用pieSliceBorderColor. 自从提出此问题以来,可能已添加此内容,但对于任何将来的参考,这就是您的操作方式。注意:这仅适用于 2D 饼图

new google.visualization.PieChart(document.getElementById('poll-chart')).
    draw(data, {

        title:"",
        fontSize: "12",
        legend: "none",
        width: 200,
        height: 200,
        chartArea: { left: 0, top: 0, width: "100%", height: "100%"},
        backgroundColor: { stroke: "#5A5A5A", strokeWidth: 5, fill: "#5A5A5A" },

        // add this line
        pieSliceBorderColor : "#5A5A5A"
    });
于 2012-06-13T04:42:24.337 回答