D3
OG
Old school D3 from simpler times
All examples
By author
By category
About
ZJONSSON
Full window
Github gist
Internalizing chart variables (mod)
<code> <!DOCTYPE html> <html> <head> <script type="text/javascript" src="d3mod.js"></script> </head> <body> <script type="text/javascript"> svg=d3.select("body") .append("svg:svg") svg.property("__chart__",{ X:d3.scale.linear() .domain([2012,2045]) .range([0,svg[0][0].parentNode.offsetWidth]), Y:d3.scale.linear() .domain([1,100]) .range([svg[0][0].parentNode.offsetHeight,0]) }) data = [ {x:2015,y:23},{x:2024,y:55},{x:2034,y:12}] svg.selectAll(".series").data(data) .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> <\code>