尝试使用Dojo创建图表

时间:2012-11-26 19:49:11

标签: dojo

我正在尝试使用Dojo 1.8.1创建图表,但浏览器窗口中没有显示任何内容(我正在使用IE 8)。

这是我到目前为止所拥有的:

<html>
<head>
    <title>Dojo Charting Example</title>
    <script src="http://ajax.googleapis.com/ajax/libs/dojo/1.8.1/dojo/dojo.js"></script>
    <script>
        require(["dojox/charting/Chart", "dojox/charting/axis2d/Default", "dojox/charting/plot2d/Lines", "dojo/ready"],
            function(Chart, Default, Lines, ready) {
            ready(function() {
                var chart1 = new dojox.charting.Chart2D("simplechart");
                chart1.addPlot("default", {type: Lines});
                chart1.addAxis("x");
                chart1.addAxis("y", {vertical: true});
                chart1.addSeries("Series 1", [1, 2, 2, 3, 4, 5, 5, 7]);
                chart1.render();
            });
        });
    </script>
</head>

<body>
    <div id="simplechart" style="width: 250px; height: 150px; margin: 5px auto 0px auto;"></div>
</body>

以下是我收到的JavaScript错误消息:

Webpage error details

User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; chromeframe/23.0.1271.64; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; InfoPath.2; MS-RTC LM 8; .NET4.0E)
Timestamp: Mon, 26 Nov 2012 20:03:05 UTC


Message: Object expected
Line: 9
Char: 6
Code: 0
URI: http://localhost:8084/ReferenceManager/dojoChartingExample2.html


Message: Object doesn't support this property or method
Line: 2
Char: 1
Code: 0
URI: http://ajax.googleapis.com/ajax/libs/dojo/1.8.1/dojox//charting/plot2d/Base.js

1 个答案:

答案 0 :(得分:0)

重要的是new dojox.charting.Chart2D

您必须更改为new Chart [More info]

图表来自您所需的function(Chart, Default, Lines, ready)

Here is an example.