The following selects all the elements from the array connections. I just want a particular one.
var route = vis.selectAll("line.route")
.data(connections)
.enter().append("svg:line")
.attr("class", "route")
.attr("stroke", function(d) { return '#'+routesById[d.line].colour; })
.attr("stroke-linecap", 'round')
.attr("x1", function(d) { return x(d.station1.longitude); })
.attr("y1", function(d) { return y(d.station1.latitude); })
.attr("x2", function(d) { return x(d.station2.longitude); })
.attr("y2", function(d) { return y(d.station2.latitude); })
connections is an array(i think) and on the console is defined as
[Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object, Object…]
However I only want to select an element at a particular index. I tried to use the filter but it did not work?
.data(connections.filter(function(d) { return d[23] }))