Skip to content

Instantly share code, notes, and snippets.

@ariaz
Created July 7, 2012 22:32
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/3068341 to your computer and use it in GitHub Desktop.
Save ariaz/3068341 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 = 5.075832270615535;
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);
d3.selectAll(".axis path")
.attr("fill","none")
.attr("stroke","black");
d3.selectAll(".axis")
.attr("font-size","8pt")
.attr("font-family","sans-serif");
d3.selectAll(".tick")
.attr("fill","none")
.attr("stroke","black");
d3.selectAll("circle")
.attr("stroke-width","0.5px")
.attr("stroke","black")
.attr("opacity","0.5")
.attr("fill","RoyalBlue");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment