You have two problems;
You added Raphal.js twice
<script type="text/javascript" src="raphael.js"></script>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"></script>
Orusetheproductionversionorcdn.
ItestedyesterdayanddidnotseethiserrorUncaughtTypeError:Cannotreadproperty'x'ofundefined
untilcallingtheconstructortogenerateanSVG,whathappensisthatthepagehadnotfinishedloadingbeforerunningRaphal.js,youcandoitintwoways:
Usingwindow.onload
:
window.onload=function(){varpaper=Raphael("canvas", 640, 480);
paper.clear();
paper.circle(320, 240, 60);
};
-
Using jQuery.ready
:
$(function() {
var paper = Raphael("canvas", 640, 480);
paper.clear();
paper.circle(320, 240, 60);
});
Sample html code:
<!DOCTYPE html>
<html>
<head>
<title>Exemplo simples</title>
<script type="text/javascript" src="http://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"></script><scripttype="text/javascript">
window.onload = function() {
var paper = Raphael("canvas", 640, 480);
paper.clear();
paper.circle(320, 240, 60);
};
</script>
</head>
<body>
<div id="canvas"></div>
</body>
</html>