Transparent Background on Piechart?

1,259 views
Skip to first unread message

Vincent Fraser

unread,
Aug 27, 2014, 10:18:17 AM8/27/14
to google-visua...@googlegroups.com
Is is posiable for me to make the Pie Chart have a transparent back ground? Where would i put it in the code?

<html>
  <head>
    <!--Load the AJAX API-->
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript">

      // Load the Visualization API and the piechart package.
      google.load('visualization', '0.5', {'packages':['corechart']});

      // Set a callback to run when the Google Visualization API is loaded.
      google.setOnLoadCallback(drawChart);

      // Callback that creates and populates a data table,
      // instantiates the pie chart, passes in the data and
      // draws it.
      function drawChart() {

        // Create the data table.
        var data = new google.visualization.DataTable();
        data.addColumn('string', 'Topping');
        data.addColumn('number', 'Slices');
        data.addRows([
        //    ['Test', 6],
          ['Foucs',5],
          ['Euphoric', 4],
          ['Creative', 4],
          ['Sleepy', 2],
          ['Paranoia', 1]
        ]);

        // Set chart options
        var options = {'title':'Effects',
                       'width':400,
                       'height':300};

        // Instantiate and draw our chart, passing in some options.
        var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
        chart.draw(data, options);
      }
    </script>
  </head>

  <body>
    <!--Div that will hold the pie chart-->
    <div id="chart_div"></div>
  </body>
</html>

Andrew Gallant

unread,
Aug 27, 2014, 8:13:41 PM8/27/14
to google-visua...@googlegroups.com
Set the backgroundColor option to "transparent":

var options = {
    'title':'Effects',
    'width':400,
    'height':300,
    backgroundColor: 'transparent'
};

This does not work in IE8 and older, as the API does not support transparency in VML, which what IE8 uses to draw the charts.

Vincent Fraser

unread,
Aug 27, 2014, 8:21:59 PM8/27/14
to google-visua...@googlegroups.com

Thank you so much!

--
You received this message because you are subscribed to a topic in the Google Groups "Google Visualization API" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-visualization-api/wlmMEuJ62a8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-visualizati...@googlegroups.com.
To post to this group, send email to google-visua...@googlegroups.com.
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages