简体   繁体   English

如何更改Google Area Chart Overlap的颜色或不透明度?

[英]How to change Google Area Chart Overlap colour or opacity?

Regarding Google Charts, is there a way to adjust the colour or opacity between two or more overlapping areas of an area chart? 关于Google图表,是否可以调整区域图的两个或多个重叠区域之间的颜色或不透明度? I've been attempting to modify Google's sample code provided at the Area Chart development website. 我一直在尝试修改Area Chart开发网站上提供的Google示例代码。 For convenience I have provided a copy of the sample code below. 为了方便起见,我在下面提供了示例代码的副本。 Note: If there isn't an officially supported way to do this I am interested in any dirty ways to go about it too. 注意:如果没有正式支持的方法,我也对任何肮脏的方法感兴趣。

  google.load("visualization", "1", {packages:["corechart"]});
  google.setOnLoadCallback(drawChart);
  function drawChart() {
    var data = google.visualization.arrayToDataTable([
      ['Year', 'Sales', 'Expenses'],
      ['2013',  1000,      400],
      ['2014',  1170,      460],
      ['2015',  660,       1120],
      ['2016',  1030,      540]
    ]);

    var options = {
      title: 'Company Performance',
      hAxis: {title: 'Year',  titleTextStyle: {color: '#333'}},
      vAxis: {minValue: 0}
    };

    var chart = new
    google.visualization.AreaChart(document.getElementById('chart_div'));
    chart.draw(data, options);
  }

To help clarify what I hope to accomplish please see the following image. 为了帮助阐明我希望完成的工作,请参见下图。 在此处输入图片说明

You can add series with different areaOpacity to your options: 您可以将具有不同areaOpacity series添加到选项中:

...
vAxis: {minValue: 0},
series: {
    0: { areaOpacity: 0.2},
    1: { areaOpacity: 0.7}
}

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

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