InvalidStateError when using google api in xsl stylesheet

Discuss how to use and promote Web standards with the Mozilla Gecko engine.
Posts: 1
Joined: May 26th, 2015, 12:51 pm

Post Posted May 26th, 2015, 1:05 pm

Hi guys,

When trying to display a Google pie chart using xsl, InvalidStateError will be thrown.
1. in the below example I used hardcoded values for the Google chart data (normally, I would take data from a valid xml file-this is just to ease the analysis)
2. the 2 files (xsl and xml) need to run locally (they won't be placed on a websever)
3. the same below code works on IE
1. xml file: test.xml (just a dummy xml)
Code: Select all
<?xml-stylesheet type="text/xsl" href="stylesheet.xsl"?>

  <node2 name="content">

  <node3 name="conten1">

2. xsl file: stylesheet.xsl - code taken dirrectly from Google examples

Code: Select all
<xsl:stylesheet version="1.0"
  <xsl:output method="html"/>
    <xsl:template match="/">
    <script type="text/javascript" src=""></script>
    <script type="text/javascript">
      google.load("visualization", "1", {packages:["corechart"]});
      function drawChart() {

        var data = google.visualization.arrayToDataTable([
          ['Task', 'Hours per Day'],
          ['Work',     11],
          ['Eat',      2],
          ['Commute',  2],
          ['Watch TV', 2],
          ['Sleep',    7]

        var options = {
          title: 'My Daily Activities'

        var chart = new google.visualization.PieChart(document.getElementById('piechart'));

        chart.draw(data, options);
    <div id="piechart" style="width: 900px; height: 500px;"></div>


Can someone please tell me why I get this error, and most important, how can I solve it?

Thanks a lot,

Return to Web Development / Standards Evangelism

Who is online

Users browsing this forum: No registered users and 1 guest