简体   繁体   English

谷歌饼图不显示在 IE <= 8

[英]Google Pie chart not displaying in IE <= 8

I need to execute this .php file for different IE versions but the following errors appear when I emulate to:我需要为不同的 IE 版本执行这个 .php 文件,但是当我模拟时出现以下错误:

  • IE 8:"gvjs_VL" is undefined. IE 8:“gvjs_VL”未定义。
  • IE <8: "JSON" is undefined. IE <8:“JSON”未定义。

I have tried also to use json2 when the IE version was <= 8 but it did not solve the issue.当 IE 版本 <= 8 时,我也尝试使用 json2 但它没有解决问题。 What could be happening?会发生什么?

Thank you in advance.先感谢您。 :) :)

<!DOCTYPE html>
<?php 
$chartData = array(array("Area" , "Number of people"),
                   array("A"    , 5000),
                   array("B"    , 8000),
                   array("C"    , 400),
                   array("D"    , 40000),
                   array("E"    , 1000),
                   array("F"    , 1400 ));  
?>

<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge" >
    <link rel="stylesheet" href="main.css">
</head>
<body>

<div class="chartContainer">
    <div id="piechart" class="piechart">
        <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>

        <script type="text/javascript">
        // Load google charts
        google.charts.load('current', {'packages':['corechart']});
        google.charts.setOnLoadCallback(drawChart);

        // Draw the chart and set the chart values
        function drawChart() {
          var data = google.visualization.arrayToDataTable( <?php echo json_encode($chartData, JSON_NUMERIC_CHECK); ?>);

          // Optional; add a title and set the width and height of the chart
          var options = {fontName:'Arial', legend:{position: 'labeled', maxLines:15, alignment:'start'}, 
                         textStyle: {color: 'black', fontSize: 30}, 
                         pieHole: 0.4, sliceVisibilityThreshold:0.0,
                         chartArea: {   
                                     width: "100%",
                                     top: "0%",
                                     left: "0%"},

                         };

          // Display the chart inside the div> element with id="piechart"
          var chart = new google.visualization.PieChart(document.getElementById('piechart'));
          chart.draw(data, options);
        }
    </script>
    </div>

</div>
</body>

I am not able to run your PHP code so I try to test the Google Charts Sample with JS.我无法运行您的 PHP 代码,因此我尝试使用 JS 测试 Google 图表示例。

 <!DOCTYPE html> <html lang="en-US"> <body> <h1>My Web Page</h1> <div id="piechart"></div> <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> <script type="text/javascript"> // Load google charts google.charts.load('current', {'packages':['corechart']}); google.charts.setOnLoadCallback(drawChart); // Draw the chart and set the chart values function drawChart() { var data = google.visualization.arrayToDataTable([ ['Task', 'Hours per Day'], ['Work', 8], ['Eat', 2], ['TV', 4], ['Gym', 2], ['Sleep', 8] ]); // Optional; add a title and set the width and height of the chart var options = {'title':'My Average Day', 'width':550, 'height':400}; // Display the chart inside the <div> element with id="piechart" var chart = new google.visualization.PieChart(document.getElementById('piechart')); chart.draw(data, options); } </script> </body> </html>

Output in IE browser: IE浏览器输出:

在此处输入图片说明

If you check the source code then you can notice that Google Charts using SVG in their charts.如果您查看源代码,就会注意到 Google Charts 在其图表中使用了SVG SVG is not supported in IE <= 8. IE <= 8 不支持SVG

在此处输入图片说明

Reference:参考:

SVG (basic support) SVG(基本支持)

This can be the one of the reason that it is not working in IE <=8 versions.这可能是它在 IE <=8 版本中不起作用的原因之一。

At present, IE 8 and earlier versions are not supported.目前不支持 IE 8 及更早版本。 It is recommended to upgrade to IE 11 browser.建议升级到IE 11浏览器。 It can help to avoid this issue.它可以帮助避免这个问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM