Skip to content

Instantly share code, notes, and snippets.

/_.md

Created September 30, 2012 01:59
Show Gist options
  • Save anonymous/3805626 to your computer and use it in GitHub Desktop.
Save anonymous/3805626 to your computer and use it in GitHub Desktop.
just another inlet to tributary

No Previous Gist

{"editor_editor":{"coffee":false,"vim":false,"emacs":false,"width":628,"height":603,"hide":false},"endpoint":"tributary","public":true}
//this gives us 10 numbers, from 1 to 10
var data = d3.range(1, 15);
var b = 200000;
var c = 0.016;
var i = 7.5;
var ct = 78;
var k = c * i;
var di = 0.15;
//we want to map our x values to pixel values
var xscale = d3.scale.linear()
.domain([d3.min(data), d3.max(data)])
.range([0, 397]); //try changing 300
//we want to map our y values to pixel values
var yscale = d3.scale.linear()
.domain([0, 1])
.range([300, 0]) //svg corner starts at top left
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) {
//for each data point we perform our y function and then
//map that value to pixels
return yscale(1/d);
});
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(" + [100, 100] + ")")
Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment