1

我正在研究 SugarCRM 框架,我在 iframe 中调用 html 文件。iframe 调用了 google chart api。它可以在所有其他网络浏览器中加载,但不能在 ie8 中加载

请让我哪里出错了

<html>
<head>
<script type='text/javascript' src='https://www.google.com/jsapi'></script>
<script type='text/javascript' src="sample.js"></script>

<script type='text/javascript'>
//document.write("hi");
 var or=window.location.href;
//alert(or);
  var or1=or.split("=");
  var id=or1[1];
//alert(id);
  google.load('visualization', '1', {packages:['corechart']});
  google.load("visualization", "1.0", {packages:["imagechart"]});
  google.setOnLoadCallback(drawChart);
   function drawChart() {
 // var jsona=<?php echo $jsonarr; ?>;
var jsona = $.ajax({
    url:"index.php?entryPoint=surveychart&id="+id+"&mode=1",
    dataType:"array",
    async:false
    }).responseText;
    var some= eval('(' + jsona + ')');
    //alert(jsona);
var data = google.visualization.arrayToDataTable(some);


     var options = {
      title: 'Survey Result',
      hAxis: {title: 'Questions', titleTextStyle: {color: 'red'}}
      };

    var chart = new        google.visualization.ColumnChart(document.getElementById('chart_div'));
    chart.draw(data, options);


 google.visualization.events.addListener(chart, 'select',
        function() {

 var selection = chart.getSelection();
var message = '';
for (var i = 0; i < selection.length; i++) {
  var item = selection[i];
  if (item.row != null && item.column != null) {
    var str = data.getFormattedValue(item.row, item.column);
    message += '{row:' + item.row + ',column:' + item.column + '} = ' + str + '\n';
  } else if (item.row != null) {
    var str = data.getFormattedValue(item.row, 0);
    message += '{row:' + item.row + ', column:none}; value (col 0) = ' + str + '\n';
  } else if (item.column != null) {
    var str = data.getFormattedValue(0, item.column);
    message += '{row:none, column:' + item.column + '}; value (row 0) = ' + str + '\n';
  }
}
if (message == '') {
  message = 'nothing';
}
   //alert('You selected ' + message); 

 var dataTable = new google.visualization.DataTable();
    dataTable.addColumn('string');
    dataTable.addColumn('number');
  var dataTable1 = new google.visualization.DataTable();
    dataTable1.addColumn('string');
    dataTable1.addColumn('number');     
  var jsonage = $.ajax({
    url:"index.php?entryPoint=surveychart&id="+id+"&mode=2&col="+item.column+"&row="+item.row,
    dataType:"array",
    async:false
    }).responseText;
    //alert(jsonage);
    var jsongen = $.ajax({
     url:"index.php?entryPoint=surveychart&id="+id+"&mode=3&col="+item.column+"& row="+item.row,
    dataType:"array",
    async:false
    }).responseText;
    var someage= eval('(' + jsonage + ')');
    var somegen= eval('(' + jsongen + ')');
//  alert(somegen);
    dataTable.addRows(someage);
    dataTable1.addRows(somegen);

     var options1 = {cht: 'p', title: 'Answer By Age', chp: 0.628, chs:  '400x200',
      colors:['#3399CC','#00FF00','#0000FF']};
      var options2 = {cht: 'p', title: 'Answer By Gender', chp: 0.628, chs: '400x200',
      colors:['#3399CC','#00FF00','#0000FF']};

 if(str!='')
 {
       var chart1 = new    google.visualization.ImageChart(document.getElementById('pie_div'));
     chart1.draw(dataTable, options1);
    var chart2 = new  google.visualization.ImageChart(document.getElementById('pie_div1'));
     chart2.draw(dataTable1, options2);
     }

      }
      );
   }
    </script>
    </head>

     <body>
     <table><tr><td><div id='chart_div' style='width: 400px; height: 400px;'></div> </td></tr><tr><td><div id='pie_div' style='width: 400px; height:200px;' ></div>  </td><td><div id='pie_div1' style='width: 400px; height: 200px;'></div></td></tr></table>

      </body>
       </html>
4

0 回答 0