Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
297 views
in Technique[技术] by (71.8m points)

Can't remove the background of google chart

I have used google charts for a web app. I want to remove its white background. I tried changing the background color to transparent, but it isn't working.

<script type="text/javascript">
google.charts.load("current", {packages:["corechart"]});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
  var data = google.visualization.arrayToDataTable([
    ["Element", "Density", { role: "style" } ],
    ["LIC", 8.94, "#BCFFFF"],
    ["STAR", 10.49, "#FFC9C9"],
    ["UNIVERSAL", 19.30, "#F9FFD3"],
    ["APPOLLO", 21.45, "#C2FFBD"]
  ]);

  var view = new google.visualization.DataView(data);
  view.setColumns([0, 1,
                   { calc: "stringify",
                     sourceColumn: 0,
                     type: "string",
                     role: "annotation" },
                   2]);

  var options = {
    title: "CUSTOMERS",
    bar: {groupWidth: "70%"},
    
    legend: { position: "none" },
  };
  var chart = new google.visualization.BarChart(document.getElementById("barchart_values"));
  chart.draw(view, options);
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
var options = {
title: "CUSTOMERS",
bar: {groupWidth: "70%"},
backgroundColor: 'transparent',
legend: { position: "none" },

It works now, don't know why it didn't work before.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...