Skip to content

Instantly share code, notes, and snippets.

@enjalot
Created March 16, 2013 05:47
Show Gist options
  • Save enjalot/5175164 to your computer and use it in GitHub Desktop.
Save enjalot/5175164 to your computer and use it in GitHub Desktop.
SF bus stops
{"description":"SF bus stops","endpoint":"","display":"svg","public":true,"require":[{"name":"topojson","url":"http://d3js.org/topojson.v0.min.js"}],"fileconfigs":{"inlet.js":{"default":true,"vim":false,"emacs":false,"fontSize":12},"world110.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"config.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"_.md":{"default":true,"vim":false,"emacs":false,"fontSize":12},"style.css":{"default":true,"vim":false,"emacs":false,"fontSize":12},"routes.json":{"default":true,"vim":false,"emacs":false,"fontSize":12},"stops.json":{"default":true,"vim":false,"emacs":false,"fontSize":12}},"fullscreen":false,"play":false,"loop":false,"restart":false,"autoinit":true,"pause":true,"loop_type":"period","bv":false,"nclones":15,"clone_opacity":0.4,"duration":3000,"ease":"linear","dt":0.01}
var svg = d3.select("svg");
var routes = tributary.routes;
var stops = tributary.stops;
console.log(stops);
var width = tributary.sw;
var height = tributary.sh;
var center = {
x: width/2,
y: height/2
}
var colorScale = d3.scale.category20();
var lonlat = [-122.4376, 37.77];
var projection = d3.geo.mercator()
.center(lonlat)
.scale(1811767)
.translate([width/2, height/2])
var xy = projection(lonlat);
var graticule = d3.geo.graticule()
var path = d3.geo.path()
.projection(projection);
svg.selectAll("path.routes")
.data(routes.features)
.enter()
.append("path")
.classed("routes", true)
.attr("d", path)
.style("stroke", function(d,i) { return colorScale(i)})
.style("fill", "none")
svg.selectAll("circle.stop")
.data(stops.features)
.enter()
.append("circle")
.classed("stop", true)
.attr({
r: 3.5,
cx: function(d,i) { return projection(d.geometry.coordinates)[0] },
cy: function(d,i) { return projection(d.geometry.coordinates)[1] }
})
.on("mouseover", function(d) {
d3.select(this)
.transition()
.attr("r", 10)
})
.on("mouseout", function(d) {
d3.select(this)
.transition()
.attr("r", 2.5)
})
.append("title")
.text(function(d) { return d.properties.STOPNAME })
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Display the source blob
Display the rendered blob
Raw
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View raw

(Sorry about that, but we can’t show files that are this big right now.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment