让Chart.js在IE 8中工作

时间:2013-07-20 05:03:09

标签: javascript charts

我正在浏览Chart.js并希望通过使用excanvas.js(http://www.chartjs.org/docs/#generalIssues-browserSupport)来检查如何在IE上启用它。该代码在支持html5的现代浏览器上运行良好。

然而,我似乎无法让它发挥作用。任何人都可以指出我在哪里做错了。

<!DOCTYPE html>
<html>
<head>
        <!--[if lte IE 8]>
        <script src="site/assets/excanvas.js"></script>
    <![endif]-->
    <script src="Chart.min.js" type="text/javascript"></script>
</head>
<body>
    <canvas id="myChart" width="400" height="400"></canvas>
    <script>
        var data = {
            labels : ["January","February","March","April","May","June","July"],
            datasets : [
                {
                    fillColor : "rgba(220,220,220,0.5)",
                    strokeColor : "rgba(220,220,220,1)",
                    pointColor : "rgba(220,220,220,1)",
                    pointStrokeColor : "#fff",
                    data : [65,59,90,81,56,55,40]
                },
                {
                    fillColor : "rgba(151,187,205,0.5)",
                    strokeColor : "rgba(151,187,205,1)",
                    pointColor : "rgba(151,187,205,1)",
                    pointStrokeColor : "#fff",
                    data : [28,48,40,19,96,27,100]
                }
            ]
        }

        var ctx = document.getElementById("myChart").getContext("2d");
        new Chart(ctx).Line(data,{});
    </script>
</body>
</html>

1 个答案:

答案 0 :(得分:0)

创建ctx var后,需要输入以下行:

“G_vmlCanvasManager.initElement(CTX);”

此声明使用excanvas.js lib初始化画布对象。