(function() { window.main = function() { /* obtain a reference to the SVG */ var vis; vis = d3.select('svg'); /* when the user clicks the SVG */ return vis.on('click', function() { /* retrieve mouse coordinates */ var p; p = d3.mouse(this); /* create a new circle at point p */ return vis.append('circle').attr('class', 'node').attr('r', 20).attr('cx', p[0]).attr('cy', p[1]); }); }; }).call(this);