Google Diff条形图 - 更改条形图颜色

时间:2014-06-21 17:47:06

标签: google-visualization

我有一张Google Diff条形图。我想改变外部酒吧的颜色。默认情况下,它是褪色的颜色。我可以使用选项下的颜色参数更改内部条形颜色。有人可以指导我吗?这是我的代码如下。

<script type="text/javascript" src="https://www.google.com/jsapi"></script>
  <script type="text/javascript">
    google.load("visualization", '1.1', {packages:['corechart']});
    google.setOnLoadCallback(drawChart);
function drawChart() {
var oldData = google.visualization.arrayToDataTable([
  ['Name', 'Popularity'],
  ['Cesar', 250],
  ['Rachel', 4200],
  ['Patrick', 2900],
  ['Eric', 8200]
]);

var newData = google.visualization.arrayToDataTable([
  ['Name', 'Popularity'],
  ['Cesar', 370],
  ['Rachel', 600],
  ['Patrick', 700],
  ['Eric', 3500]
]);
var colChartDiff = new google.visualization.ColumnChart(document.getElementById('colchart_diff'));
var options = { 
diff: { newData: { widthFactor: 0.6 } },
legend: { position: 'top' } ,
colors: ['#f38eff', '#C0C0C0'],
backgroundColor: '#fffff5',
hAxis: {title: 'People'},
  vAxis: {title: 'Numbers'}};
var diffData = colChartDiff.computeDiff(oldData, newData);
colChartDiff.draw(diffData, options);
}
 </script>

1 个答案:

答案 0 :(得分:8)

您可以在diff对象中设置它,例如

var options = { ...
    diff: { 
        oldData: { opacity: 1, color: '#e6693e' }, 
        newData: { opacity: 1}
    }...
 }