Skip to content

Instantly share code, notes, and snippets.

@ramnathv
Created January 30, 2015 18:33
Show Gist options
  • Save ramnathv/b0a1ccb9d029f15334dd to your computer and use it in GitHub Desktop.
Save ramnathv/b0a1ccb9d029f15334dd to your computer and use it in GitHub Desktop.
Tributary inlet
path {
fill: none;
stroke: black;
}
{"description":"Tributary inlet","endpoint":"","display":"svg","public":true,"require":[],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"inlet.coffee":{"default":true,"vim":false,"emacs":false,"fontSize":12},"app.css":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"pingpong","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01,"ajax-caching":true}
# set plot dimensions
margin = {top: 20, left: 20, right: 20, bottom: 20}
width = 600
height = 400
W = width + margin.left + margin.right
H = height + margin.top + margin.bottom
# initialize scales
x = d3.scale.linear().range([0, width])
y = d3.scale.linear().range([height, 0])
line = d3.svg.line()
.x((d) -> x(d.x))
.y((d) -> y(d.y))
xAxis = d3.svg.axis().scale(x).orient("bottom")
data = d3.range(10).map (d, i) ->
{x: i, y: i}
console.log d3.extent(data, (d) -> d.y)
# update scales
x.domain d3.extent(data, (d) -> d.x)
y.domain d3.extent(data, (d) -> d.y)
svg = d3.select("svg")
.attr("width", W)
.attr("height", H)
.append("g")
.attr("transform", "translate(#{margin.left}, #{margin.top})")
line = svg.append("path")
.datum(data)
.attr("d", line)
focus = svg.append("circle")
.style("display", "none")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment