Skip to content

Instantly share code, notes, and snippets.

@mbecica
Created December 2, 2012 08:45
Show Gist options
  • Save mbecica/4187749 to your computer and use it in GitHub Desktop.
Save mbecica/4187749 to your computer and use it in GitHub Desktop.
Lif
{"description":"Lif","endpoint":"","display":"svg","public":true,"require":[],"tab":"edit","display_percent":0.7,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01}
var i = 0.03,
g = 0.06,
Ra = 70,
Da = 100,
Na = 25,
start = 15000,
legacy = 2000000,
loss = 100000;
var save = ((Da - Ra) * loss) + legacy,
gain = save / (Ra - Na);
var h = 261,
w = 650;
var x = d3.scale.linear()
.range([0, w])
.domain([Na, Da]);
var y = d3.scale.log()
.range([h, 0])
.domain([start, save]);
var xAxis = d3.svg.axis()
.scale(x)
.orient("bottom");
var yAxis = d3.svg.axis()
.scale(y)
.orient("left")
.tickFormat(d3.format(",.0f"));
var svg = d3.select("svg")
.append("g")
.attr("transform", "translate(100,100)");
//Axis
svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + h + ")")
.call(xAxis);
svg.append("g")
.attr("class", "y axis")
.call(yAxis)
// Start
svg.append("circle")
.attr("r", 3)
.attr("cx", x(Na))
.attr("cy", y(start))
.style("fill","#fff")
.style("stroke","#333")
.style("stroke-weight", 4);
// Save
svg.append("circle")
.attr("r", 3)
.attr("cx", x(Ra))
.attr("cy", y(save))
.style("fill","#fff")
.style("stroke","#333")
.style("stroke-weight", 4);
// Die
svg.append("circle")
.attr("r", 3)
.attr("cx", x(Da))
.attr("cy", y(legacy))
.style("fill","#fff")
.style("stroke","#333")
.style("stroke-weight", 4);
.axis path,
.axis line {
fill: none;
stroke: #999999;
shape-rendering: crispEdges;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment