Skip to content

Instantly share code, notes, and snippets.

@ariaz
Created July 7, 2012 19:20
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 ariaz/3067735 to your computer and use it in GitHub Desktop.
Save ariaz/3067735 to your computer and use it in GitHub Desktop.
just another inlet to tributary
var margin = 50,
width = 700,
height = 300;
d3.json('/static/bus_perf.json', draw);
function draw(data){
d3.select("svg")
.attr("width", width)
.attr("height", height)
.selectAll("circle")
.data(data)
.enter()
.append("circle");
x_extent = d3.extent(data, function(d){return d.collision_with_injury});
var x_scale = d3.scale.linear()
.range([margin,width-margin])
.domain(x_extent);
y_extent = d3.extent(data, function(d){return d.dist_between_fail});
var y_scale = d3.scale.linear()
.range([height-margin, margin])
.domain(y_extent);
d3.selectAll("circle")
.attr("cx", function(d){return x_scale(d.collision_with_injury)})
.attr("cy", function(d){return y_scale(d.dist_between_fail)});
d3.selectAll("circle")
.attr("r",5);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment