Accepted answer

What SVG element is focus? I think it must be a g to work with multiple text elements.

For the formatting, d3 has a neat function:

var format = d3.time.format('%H:%M');
// ...'text').text(function(d) {return format(d.time);});

Edit: Working jsfiddle demo, showing two texts elements inside a group:


I had a similar issue recently when I wanted to create 4 rectangles with different properties. I solved this with HTML ids and selectAll. Here is an example:

var van = road.selectAll('#van').data([5]).enter() 
.attr('x', function(d) { return 300})
.attr('y', function(d) { return 100})
.attr('width', 30)
.attr('height', 15)
.style('fill', 'brown');

Time formatting in D3:

Related Query

More Query from same tag