Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
50 lines (43 sloc) 2.06 KB
<html>
<head>
<title>gRaphaël Pie Chart - a simple piechart example</title>
<script type="text/javascript" src="../raphael-min.js"></script>
<script type="text/javascript" src="../../g.raphael.js"></script>
<script type="text/javascript" src="../../g.pie.js"></script>
<script type="text/javascript">
window.onload = function() {
// Creates canvas 640 × 480 at 10, 50
var r = Raphael(10, 50, 640, 480);
// Creates donut chart with center at 320, 200,
// radius 100 and data: [55, 20, 13, 32, 5, 1, 2]
var pie = r.piechart(320, 240, 100, [50, 20, 13, 32, 7], {donut : true, legend: ["Chrome", "Firefox", "Internet Explorer", "Safari", "Other"], legendpos: "east"});
r.text(320, 100, "Interactive Donut Chart").attr({ font: "20px sans-serif" });
pie.hover(function () {
var that = this.sector;
this.sector.stop();
this.sector.scale(1.1, 1.1, this.cx, this.cy);
pie.each(function() {
if(this.sector.id === that.id) {
console.log(pie)
tooltip = r.text(320, 240, this.sector.value.value).attr({"font-size": 35, "fill":"#000"});
}
});
if (this.label) {
this.label[0].stop();
this.label[0].attr({ r: 7.5 });
this.label[1].attr({ "font-weight": 800 });
}
}, function () {
this.sector.animate({ transform: 's1 1 ' + this.cx + ' ' + this.cy }, 500, "bounce");
tooltip.remove();
if (this.label) {
this.label[0].animate({ r: 5 }, 500, "bounce");
this.label[1].attr({ "font-weight": 400 });
}
});
}
</script>
</head>
<body>
</body>
</html>