Skip to content

Instantly share code, notes, and snippets.

@ariaz
Created July 7, 2012 19:47
Show Gist options
  • Save ariaz/3067881 to your computer and use it in GitHub Desktop.
Save ariaz/3067881 to your computer and use it in GitHub Desktop.
just another inlet to tributary
var margin = 50,
width = 700,
height = 442;
trib.adjust_y_axes = 0;
trib.r = 2.7170631566236096;
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",trib.r);
var x_axis = d3.svg.axis().scale(x_scale);
var y_axis = d3.svg.axis().scale(y_scale).orient("left");
d3.select("svg")
.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + (height-margin) + ")")
.call(x_axis);
d3.select("svg")
.append("g")
.attr("class", "y axis")
.attr("transform", "translate(" + (margin + trib.adjust_y_axes) + "," + 6 + ")")
.call(y_axis);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment