如何在Google图表中设置透明背景?
我用过
'backgroundColor':'transparent'
和'backgroundColor' = {fill: <color>};
它可以在FF, Chrome, Safari和Opera中工作,但不能在Internet Explorer中工作。
有没有办法让它在ie中透明?
我有同样的问题,Internet Explorer 7,8将在iframe上显示图表,所以我在iframe上使用事件Ready of Chart添加了jQuery来透明正文标签的背景。
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['', ''],
['', 2],
['', 8]
]);
var options = {
colors: ['#b28dc1', '#79449a'],
legend: {position: 'none'},
backgroundColor: 'transparent',
pieSliceText: 'value',
pieHole: 0.55,
pieSliceBorderColor: 'none'
};
var chart = new google.visualization.PieChart(document.getElementById('chart1'));
google.visualization.events.addListener(chart, 'ready', addIETransparentBg);
chart.draw(data, options);
}
function addIETransparentBg(e) {
$("iframe").contents().find("body").css({'background': 'none'});
}
这可以通过
backgroundColor: {stroke:null, fill:null, strokeSize: 0} // or
backgroundColor:#colorcode ;
或者您可以添加空白的PNG图像背景来实现