summaryrefslogtreecommitdiff
path: root/test/g.raphael/examples/piechart
diff options
context:
space:
mode:
Diffstat (limited to 'test/g.raphael/examples/piechart')
-rw-r--r--test/g.raphael/examples/piechart/piechart_basic.html24
-rw-r--r--test/g.raphael/examples/piechart/piechart_each.html28
-rw-r--r--test/g.raphael/examples/piechart/piechart_hover.html28
-rw-r--r--test/g.raphael/examples/piechart/piechart_hover_adv.html41
-rw-r--r--test/g.raphael/examples/piechart/piechart_rotate.html28
-rw-r--r--test/g.raphael/examples/piechart/piechart_with_legend.html20
6 files changed, 169 insertions, 0 deletions
diff --git a/test/g.raphael/examples/piechart/piechart_basic.html b/test/g.raphael/examples/piechart/piechart_basic.html
new file mode 100644
index 0000000..54cc4bb
--- /dev/null
+++ b/test/g.raphael/examples/piechart/piechart_basic.html
@@ -0,0 +1,24 @@
+<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-min.js"></script>
+ <script type="text/javascript" src="../../g.pie-min.js"></script>
+ <script type="text/javascript">
+ window.onload = function() {
+ // Creates canvas 640 × 480 at 10, 50
+ var r = Raphael(10, 50, 640, 480);
+ // Creates pie chart at with center at 320, 200,
+ // radius 100 and data: [55, 20, 13, 32, 5, 1, 2]
+ var pie = r.g.piechart(320, 240, 100, [55, 20, 13, 32, 5, 1, 2]);
+
+ // add a click event to the pie chart
+ pie.click(function() {
+ alert("You clicked on the pie chart!");
+ });
+ }
+ </script>
+ </head>
+ <body>
+ </body>
+</html> \ No newline at end of file
diff --git a/test/g.raphael/examples/piechart/piechart_each.html b/test/g.raphael/examples/piechart/piechart_each.html
new file mode 100644
index 0000000..e66be8d
--- /dev/null
+++ b/test/g.raphael/examples/piechart/piechart_each.html
@@ -0,0 +1,28 @@
+<html>
+ <head>
+ <title>gRaphaël Pie Chart - iterating through sectors using .each()</title>
+ <script type="text/javascript" src="../raphael-min.js"></script>
+ <script type="text/javascript" src="../../g.raphael-min.js"></script>
+ <script type="text/javascript" src="../../g.pie-min.js"></script>
+ <script type="text/javascript">
+ window.onload = function() {
+ // Creates canvas 640 × 480 at 10, 50
+ var r = Raphael(10, 50, 640, 480);
+ // Creates pie chart at with center at 320, 200,
+ // radius 100 and data: [55, 20, 13, 32, 5, 1, 2]
+ var pie = r.g.piechart(320, 240, 100, [55, 20, 13, 32, 5, 1, 2]);
+
+ // revealing the value of each sector by iterating through the piechart with .each
+
+ // simple callback that logs each sector received
+ var callback = function() {
+ console.log(this.sector);
+ };
+
+ pie.each(callback);
+ }
+ </script>
+ </head>
+ <body>
+ </body>
+</html>
diff --git a/test/g.raphael/examples/piechart/piechart_hover.html b/test/g.raphael/examples/piechart/piechart_hover.html
new file mode 100644
index 0000000..f3a62a8
--- /dev/null
+++ b/test/g.raphael/examples/piechart/piechart_hover.html
@@ -0,0 +1,28 @@
+<html>
+ <head>
+ <title>gRaphaël Pie Chart - a .hover() example</title>
+ <script type="text/javascript" src="../raphael-min.js"></script>
+ <script type="text/javascript" src="../../g.raphael-min.js"></script>
+ <script type="text/javascript" src="../../g.pie-min.js"></script>
+ <script type="text/javascript">
+ window.onload = function() {
+ // Creates canvas 640 × 480 at 10, 50
+ var r = Raphael(10, 50, 640, 480);
+ // Creates pie chart at with center at 320, 200,
+ // radius 100 and data: [55, 20, 13, 32, 5, 1, 2]
+ var pie = r.g.piechart(320, 240, 100, [55, 20, 13, 32, 5, 1, 2]).attr({fill:"#666"});
+
+ // add a hover event to the pie chart
+ pie.hover(function() {
+ // when mouse hovers over sector
+ this.sector.attr({fill:"#FAA"});
+ }, function() {
+ // when mouse hovers out
+ this.sector.attr({fill:"#666"});
+ });
+ }
+ </script>
+ </head>
+ <body>
+ </body>
+</html> \ No newline at end of file
diff --git a/test/g.raphael/examples/piechart/piechart_hover_adv.html b/test/g.raphael/examples/piechart/piechart_hover_adv.html
new file mode 100644
index 0000000..ce41d3a
--- /dev/null
+++ b/test/g.raphael/examples/piechart/piechart_hover_adv.html
@@ -0,0 +1,41 @@
+<html>
+ <head>
+ <title>gRaphaël Pie Chart - a more complex .hover() example</title>
+ <script type="text/javascript" src="../raphael-min.js"></script>
+ <script type="text/javascript" src="../../g.raphael-min.js"></script>
+ <script type="text/javascript" src="../../g.pie-min.js"></script>
+ <script type="text/javascript">
+ window.onload = function() {
+ // Creates canvas 640 × 480 at 10, 50
+ var r = Raphael(10, 50, 640, 480);
+ // Creates pie chart at with center at 320, 200,
+ // radius 100 and data: [55, 20, 13, 32]
+ var pie = r.g.piechart(320, 240, 100, [55, 20, 13, 32]).attr({"fill":"#666"});
+
+ var tooltip;
+ // add a hover event to the pie chart
+ pie.hover(function() {
+ // we store the sector that's being hovered
+ var that = this.sector;
+ // loop through the pie and highlight the hovered sector while dimming the rest
+ // also show the value of the hovered sector
+ pie.each(function() {
+ if(this.sector.id === that.id) {
+ this.sector.attr({fill:"#666"});
+ tooltip = r.g.text(this.x, this.y, this.sector.value.value).attr({"font-size": 15, "fill":"#FFF"});
+
+ } else {
+ this.sector.animate({"opacity":0.25}, 1000);
+ }
+ });
+ }, function() {
+ // when mouse hovers out, restore pie to original color
+ tooltip.remove();
+ pie.animate({"opacity":1, "fill":"#666"}, 1000);
+ });
+ }
+ </script>
+ </head>
+ <body>
+ </body>
+</html> \ No newline at end of file
diff --git a/test/g.raphael/examples/piechart/piechart_rotate.html b/test/g.raphael/examples/piechart/piechart_rotate.html
new file mode 100644
index 0000000..1ee3a24
--- /dev/null
+++ b/test/g.raphael/examples/piechart/piechart_rotate.html
@@ -0,0 +1,28 @@
+<html>
+ <head>
+ <title>gRaphaël Pie Chart - rotate your piechart</title>
+ <script type="text/javascript" src="../raphael-min.js"></script>
+ <script type="text/javascript" src="../../g.raphael-min.js"></script>
+ <script type="text/javascript" src="../../g.pie-min.js"></script>
+ <script type="text/javascript">
+ window.onload = function() {
+ // Creates canvas 640 × 480 at 10, 50
+ var r = Raphael(10, 50, 640, 480);
+ // Creates pie chart at with center at 320, 240,
+ // radius 100 and data: [55, 20, 13, 32, 5, 1, 2]
+ var pie = r.g.piechart(320, 240, 100, [55, 20, 13, 32, 5, 1, 2]);
+ var orientation = r.g.line(100, 50, 20).attr({"fill":"#333"});
+ // add a click event to the pie chart and rotate pie
+ // note: after click event is triggered, the pie no longer seems clickable?
+ pie.click(function() {
+ pie.each(function(){
+ this.sector.animate({"opacity": 0,"rotation": "180 320 240"}, 2000, ">");
+ });
+ orientation.animate({"stroke-opacity":0.25, "opacity":0.5, "rotation": "180 100 50"}, 2000, ">");
+ });
+ }
+ </script>
+ </head>
+ <body>
+ </body>
+</html> \ No newline at end of file
diff --git a/test/g.raphael/examples/piechart/piechart_with_legend.html b/test/g.raphael/examples/piechart/piechart_with_legend.html
new file mode 100644
index 0000000..721656a
--- /dev/null
+++ b/test/g.raphael/examples/piechart/piechart_with_legend.html
@@ -0,0 +1,20 @@
+<html>
+ <head>
+ <title>gRaphaël Pie Chart - a piechart with legend example</title>
+ <script type="text/javascript" src="../raphael-min.js"></script>
+ <script type="text/javascript" src="../../g.raphael-min.js"></script>
+ <script type="text/javascript" src="../../g.pie-min.js"></script>
+ <script type="text/javascript">
+ window.onload = function() {
+ // Creates canvas 640 × 480 at 10, 50
+ var r = Raphael(10, 50, 640, 480);
+ // Creates pie chart at with center at 320, 200,
+ // radius 100 and data: [55, 20, 13, 32, 5, 1, 2]
+ // Add legend to piechart.
+ var pie = r.g.piechart(320, 240, 100, [10,20,30,40], {legend:['%% apples', '%% bananas', '%% cherries', '%% durians'], legendmark:"*", legendpos: "south"});
+ }
+ </script>
+ </head>
+ <body>
+ </body>
+</html> \ No newline at end of file