Skip to content

Instantly share code, notes, and snippets.

@zellyn
Created October 9, 2012 03:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zellyn/3856346 to your computer and use it in GitHub Desktop.
Save zellyn/3856346 to your computer and use it in GitHub Desktop.
just another inlet to tributary
{"editor_editor":{"coffee":false,"vim":false,"emacs":false,"width":614,"height":872,"hide":false},"endpoint":"tributary","public":true}
var svg = d3.select("svg");
var width = 400,
height = 300,
xextent = d3.extent([-1, 1]),
yextent = d3.extent([-1, 1]);
var x = d3.scale.linear().domain(xextent).range([0, width]),
y = d3.scale.linear().domain(yextent).range([height, 0]);
console.log("**")
console.log(x(0));
var data = d3.range(-1, 1.1, .1)
.map(function(d) {
return [d, d*d];
});
var line = d3.svg.line()
.interpolate("basis")
.x(function(d) { return x(d[0]); })
.y(function(d) { return y(d[1]); });
svg.selectAll("path")
.data([data])
.enter()
.append("path")
.attr({
d: line,
stroke: "black",
fill: "none",
});
xAxis = d3.svg.axis()
.scale(x);
yAxis = d3.svg.axis()
.scale(y)
.orient("left");
svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(" + [0, y(0)] + ")")
.call(xAxis);
svg.append("g")
.attr("class", "y axis")
.attr("transform", "translate(" + [x(0), 0] + ")")
.call(yAxis);
d3.select("head")
.append("style")
.attr("type", "text/css");
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