Javascript 我的代码使用的是JSFIDLE,而不是html

Javascript 我的代码使用的是JSFIDLE,而不是html,javascript,html,onload,jsfiddle,cdata,Javascript,Html,Onload,Jsfiddle,Cdata,我有一个代码,它使用raphael.js绘制圆环图,它在jsfiddle上工作,但在我的html中不工作,即使我用onload和CDATA包装这段代码 `//<![CDATA[ window.onload = function donutChart(total, goal, avg){ var paper = Raphael("canvas", 400, 400); paper.customAttributes.arc = function (xloc, yloc, v

我有一个代码,它使用raphael.js绘制圆环图,它在jsfiddle上工作,但在我的html中不工作,即使我用onload和CDATA包装这段代码

`//<![CDATA[
  window.onload = function donutChart(total, goal, avg){
    var paper = Raphael("canvas", 400, 400);
    paper.customAttributes.arc = function (xloc, yloc, value, total, R) {
        var alpha = 360 / total * value,
        a = (90 - alpha) * Math.PI / 180,
        x = xloc + R * Math.cos(a),
        y = yloc - R * Math.sin(a),
        path;
        if (total == value) {
            path = [
                ["M", xloc, yloc - R],
                ["A", R, R, 0, 1, 1, xloc - 0.01, yloc - R]
            ];
        } else {
            path = [
                ["M", xloc, yloc - R],
                ["A", R, R, 0, +(alpha > 180), 1, x, y]
            ];
        }
        return {
            path: path
        };
    };
    var backCircle = paper.circle(100, 100, 40).attr({
    "stroke": "#7BC2E5",
        "stroke-width": 14
    });
    var theArc = paper.path().attr({
        "stroke": "#f5f5f5",
        "stroke-width": 14,
        arc: [100, 100, 0, 100, 40]
    });
    //event fired on each animation frame
    eve.on("raphael.anim.frame.*", onAnimate);

    //text in the middle
    theText = paper.text(100, 100, "0%").attr({
        "font-size": 18,
        "fill": "#f5f5f5",
        "font-weight": "bold"
    });

    //the animated arc
    theArc.rotate(0, 100, 100).animate({
        arc: [100, 100, ((total/goal) * 100), 100, 40]
    }, 1900);

    //on each animation frame we change the text in the middle
    function onAnimate() {
        var howMuch = theArc.attr("arc");
        theText.attr("text", Math.floor(howMuch[2]) + "%");
    }
    };
    donutChart(80, 140, 40);
    //]]> `

您确定加载了正确的库吗?你在浏览器开发工具中看到控制台消息了吗?你的页面上包括raphael.js了吗?是的@sanki我添加了raphel.js,只是由于JSFIDDLOK的onload扩展出现了一些问题。我发现了问题,正在向onload函数发送参数,这是y,,,