JavaScript 未按预期工作
我想在我的 VC++ 程序中绘制漂亮的图表,因此决定通过 HTML 和 JavaScript 来实现。
如图所示,我下载了一个 Javascript 库并按照其网站中所述使用它。
如何使用?
下载 raphael.js 并将其包含到您的 HTML 页面中,然后使用它,如下简单:
// Creates canvas 320 × 200 at 10, 50
var paper = Raphael(10, 50, 320, 200);
// Creates circle at x = 50, y = 40, with radius 10
var circle = paper.circle(50, 40, 10);
// Sets the fill attribute of the circle to red (#f00)
circle.attr("fill", "#f00");
// Sets the stroke attribute of the circle to white
circle.attr("stroke", "#fff");
我包含了如下所示的 javascript 文件:
<head>
<script type="text/javascript" src="raphael.js"></script>
<script type="text/javascript">
ABOVE CODE
</script>
如果您尝试使用它,它将无法工作。我试图让它发挥作用,但失败了。我有一个问题。我怎样才能在不复制演示的另存为页面中的内容的情况下工作?当然,它包括文档,但它是参考。
它如何简单地工作?谢谢!
I want to draw chart that is beautiful in my VC++ program and so decided to implement in by HTML and JavaScript.
As it show, I downloaded a Javascript lib and used it as it said in its site.
How to use it?
Download and include raphael.js into your HTML page, then use it as simple as:
// Creates canvas 320 × 200 at 10, 50
var paper = Raphael(10, 50, 320, 200);
// Creates circle at x = 50, y = 40, with radius 10
var circle = paper.circle(50, 40, 10);
// Sets the fill attribute of the circle to red (#f00)
circle.attr("fill", "#f00");
// Sets the stroke attribute of the circle to white
circle.attr("stroke", "#fff");
I included javascript file like below:
<head>
<script type="text/javascript" src="raphael.js"></script>
<script type="text/javascript">
ABOVE CODE
</script>
If you try it, it won't work. I tried to make it work, but could not. I have a question. How can I do it work without copying things from save as page of their demo? Of course, it includes documentation, but it is reference.
How does it work simply? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
检查对 Raphael 库的引用,然后尝试以下代码:
这对我有用,请确保您的引用良好。
JSFiddle
Check the reference to the Raphael library, and then try this code:
This works for me, make sure your reference is good.
JSFiddle