Created
January 11, 2012 18:32
-
-
Save ZJONSSON/1596053 to your computer and use it in GitHub Desktop.
Internalizing chart variables (mod)
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
<html> | |
<head><script type="text/javascript" src="https://raw.github.com/gist/1595803/d3mod.js"></script></head> | |
<body> | |
<script type="text/javascript"> | |
d3.select("body") | |
.append("svg:svg") | |
.property("__chart__",function() { | |
return { | |
X:d3.scale.linear() | |
.domain([50,60]) | |
.range([0,this.parentNode.offsetWidth]), | |
Y:d3.scale.linear() | |
.domain([1,100]) | |
.range([this.parentNode.offsetHeight,0]) | |
} | |
}) | |
.selectAll(".series") | |
.data([{x:51,y:23},{x:55,y:55},{x:52,y:83}]) | |
.enter() | |
.append("svg:circle") | |
.attr("cx",function(d) { return this.__chart__.X(d.x)}) | |
.attr("cy",function(d) { return this.__chart__.Y(d.y)}) | |
.attr("r",10) | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment