Google Charts API transparent background

Posted on 2011-09-13
Last Modified: 2012-05-12

I have this code:

<script type="text/javascript" src=""></script> 
<script type="text/javascript"> 
google.load("visualization", "1", {packages:["corechart"]}); 
function drawChart() { 
var data = new google.visualization.DataTable(); 
data.addColumn('string', 'Days'); 
data.addColumn('number', 'Useri'); 
data.addColumn('number', 'Credite'); 
data.setValue(0, 0, '2004'); 
data.setValue(0, 1, 1000); 
data.setValue(0, 2, 400); 
data.setValue(1, 0, '2005'); 
data.setValue(1, 1, 1170); 
data.setValue(1, 2, 460); 
data.setValue(2, 0, '2006'); 
data.setValue(2, 1, 860); 
data.setValue(2, 2, 580); 
data.setValue(3, 0, '2007'); 
data.setValue(3, 1, 1030); 
data.setValue(3, 2, 540); 

var chart = new google.visualization.LineChart(document.getElementById('chart_div')); 
chart.draw(data, {width: 400, height: 240, title: 'Evolutie useri/credite'}); 

<body style="background-color:#009999"> 
<div id="chart_div"></div> 

Open in new window

This code create a chart. I need to set transparent background and I don't know how to do that.

I read that I need the variable:

Open in new window

but i don't know where or how to add to this code.

Question by:radugheorghies
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 40

Expert Comment

ID: 36528258
try replacing line 33 by
<div id="chart_div" style="opacity:0.4;filter:alpha(opacity=40);"></div>

Accepted Solution

radugheorghies earned 0 total points
ID: 36536048
Thanks gurvinder372,

but this solution it is not good. I need a transparent background only in chart, not for graphics.

I fount the solution myself:

   <title> Test </title>
   <script language="javascript" src=""></script>
   <body style=" background-color:#6C9">

   <div id="chart"></div>

   <script type="text/javascript">
      var queryString = '';
      var dataUrl = '';

      function onLoadCallback() {
        if (dataUrl.length > 0) {
          var query = new google.visualization.Query(dataUrl);
        } else {
          var dataTable = new google.visualization.DataTable();

          dataTable.setValue(0, 0, 20);
          dataTable.setValue(0, 1, 5);
          dataTable.setValue(1, 0, 30);
          dataTable.setValue(1, 1, 10);
          dataTable.setValue(2, 0, 40);
          dataTable.setValue(2, 1, 22);
          dataTable.setValue(3, 0, 50);
          dataTable.setValue(3, 1, 35);
          dataTable.setValue(4, 0, 60);
          dataTable.setValue(4, 1, 85);
          dataTable.setValue(5, 0, 70);
          dataTable.setValue(5, 1, null);
          dataTable.setValue(6, 0, 80);
          dataTable.setValue(6, 1, null);


      function draw(dataTable) {
        var vis = new google.visualization.ImageChart(document.getElementById('chart'));
        var options = {
          chf: 'a,s,000000FF|bg,s,FFFFFF00',
          chs: '440x220',
          cht: 'lxy',
          chco: '3072F3,FF0000',
          chd: 't:10,20,40,80,90,95,99|20,30,40,50,60,70,80|-1|5,10,22,35,85',
          chdl: 'Ponies|Unicorns',
          chdlp: 'b',
          chls: '2,4,1|1',
          chma: '5,5,5,25',
          chtt: 'Test'
        vis.draw(dataTable, options);

      function handleQueryResponse(response) {
        if (response.isError()) {
          alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());

      google.load("visualization", "1", {packages:["imagechart"]});


Open in new window


Author Closing Comment

ID: 36558743
This is what I need.

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Online collaboration is quickly becoming embedded in the workplace, and its benefits are tangible. See what the current landscape looks like and what the future holds for collaboration tools and the future of work.
Messaging apps are amazing tools with the power to do a lot of good, but the truth is the process of collaborating with coworkers requires relationships established through meaningful communication - the kind of communication that only happens face-…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

631 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question