-
-
Save ptvans/3805708 to your computer and use it in GitHub Desktop.
just another inlet to tributary
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
{"editor_editor":{"coffee":false,"vim":false,"emacs":false,"width":601,"height":546,"hide":false},"endpoint":"tributary","public":true} |
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
//these are your variables - click and drag to change | |
var time = 310; | |
var base = 201969; | |
var conv = 0.016; | |
var invite = 7.5; | |
var cycle = 67; | |
var k = conv * invite; | |
var di = 0.15; | |
var data = d3.range(0, time); | |
//we want to map our x values to pixel values | |
var xscale = d3.scale.linear() | |
.domain([d3.min(data), d3.max(data)]) //scale range of chart | |
.range([0, 555]); //width of chart | |
//we want to map our y values to pixel values | |
var yscale = d3.scale.linear() | |
.domain([base,247887]) //scale range of chart | |
.range([379, 0]) //height of chart | |
var line = d3.svg.line() | |
.x(function(d) { | |
//for each x value we map it to the pixel value | |
return xscale(d); | |
}) | |
.y(function(d,i) { | |
//this is the math for NEW USERS = base * (k^(t/cycle +1) -1) / (k-1) | |
var pow = Math.pow(k, d/cycle + 1);//this returns k to the power of d/cycle +1 | |
console.log(base * (pow - 1) / (k - 1)) | |
return yscale(base * (pow - 1) / (k - 1)); | |
}); | |
var svg = d3.select("svg"); | |
var path = svg.append("path") | |
.data([data]) | |
.attr("d", line) //this calls the line function with this element's data | |
.style("fill", "none") | |
.style("stroke", "#4B8FB6") | |
.style("stroke-width",2) | |
.attr("transform", "translate(" + [84, 31] + ")") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment