Created
May 2, 2012 05:10
-
-
Save webmonarch/2573961 to your computer and use it in GitHub Desktop.
area-d3-raphael-example.html.diff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- area.html 2012-05-01 19:55:06.396469296 -0700 | |
+++ area-raphael.html 2012-05-01 19:55:06.396469296 -0700 | |
@@ -13,7 +13,8 @@ | |
} | |
.area { | |
- fill: lightsteelblue; | |
+ stroke: none; | |
+ fill: lightsteelblue; | |
} | |
.line { | |
@@ -30,6 +31,11 @@ | |
</style> | |
<body> | |
+<!--[if lte IE 8]> | |
+<script type="text/javascript" src="../../lib/sizzle/sizzle.js"></script> | |
+<script type="text/javascript" src="../../lib/ie8/compat.js"></script> | |
+<![endif]--> | |
+<script type="text/javascript" src="../../lib/raphael/raphael.js"></script> | |
<script src="../../d3.v2.js"></script> | |
<script> | |
@@ -37,7 +43,7 @@ | |
return {x: i / 39, y: (Math.sin(i / 3) + 2) / 4}; | |
}); | |
-var margin = {top: 10, right: 10, bottom: 20, left: 40}, | |
+var margin = {top: 10.5, right: 10.5, bottom: 20.5, left: 40.5}, | |
width = 960 - margin.left - margin.right, | |
height = 500 - margin.top - margin.bottom; | |
@@ -49,11 +55,12 @@ | |
.domain([0, 1]) | |
.range([height, 0]); | |
-var xAxis = d3.svg.axis() | |
+var xAxis = d3.raphael.axis() | |
+ .top(height) | |
.scale(x) | |
.orient("bottom"); | |
-var yAxis = d3.svg.axis() | |
+var yAxis = d3.raphael.axis() | |
.scale(y) | |
.orient("left"); | |
@@ -66,23 +73,21 @@ | |
.y1(line.y()) | |
.y0(y(0)); | |
-var svg = d3.select("body").append("svg") | |
- .datum(data) | |
- .attr("width", width + margin.left + margin.right) | |
- .attr("height", height + margin.top + margin.bottom) | |
- .append("g") | |
- .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); | |
+var paper = new Raphael(document.body, width + margin.left + margin.right, height + margin.top + margin.bottom); | |
+var svg = d3.raphael(paper) | |
+ .datum(data); | |
+paper.setStart(); | |
svg.append("path") | |
.attr("class", "area") | |
.attr("d", area); | |
-svg.append("g") | |
+svg.append("path") | |
.attr("class", "x axis") | |
.attr("transform", "translate(0," + height + ")") | |
.call(xAxis); | |
-svg.append("g") | |
+svg.append("path") | |
.attr("class", "y axis") | |
.call(yAxis); | |
@@ -98,4 +103,6 @@ | |
.attr("cy", line.y()) | |
.attr("r", 3.5); | |
+paper.setFinish().transform(['t', margin.left, margin.top]); | |
+ | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment