在基本的谷歌条形图中添加 API 代码



我有一个基本的谷歌图表:-

function drawVisualization() {
  // Create and populate the data table.
  var data = google.visualization.arrayToDataTable([
    ['Year', 'Austria', 'Belgium', 'Czech Republic'],
    ['2006',  1600652,   4604684,       940478],
    ['2007',  1968113,   4013653,       1037079],
    ['2008',  1901067,   6792087,       1037327]
  ]);
// Create and draw the visualization.
      new google.visualization.ColumnChart(document.getElementById('visualization')).
          draw(data,
           {title:"Yearly Coffee Consumption by Country",
            width:600, height:400,
            hAxis: {title: "Year"}}
      );
}

我希望能够指定边框颜色和宽度等。你能告诉我如何使用API命令吗:-背景颜色.描边,背景颜色.描边宽度,

即如何添加这些 API 调用。

谢谢

您可以将stroke颜色和strokeWidth的设置与其他选项一起发送,类似于您为hAxis指定标题的方式:

backgroundColor: {
    stroke: '#000',
    strokeWidth: '2'
}

这将给图表一个黑色的 2 像素边框,在 jsfiddle 上演示。

最新更新