Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!doctype html>
<html>
    <head>
        <title>Editor</title>
        <meta http-equiv="x-ua-compatible" content="ie=9"/>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
        <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.js"></script>
        <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
        <link rel="stylesheet" href="<%=request.getContextPath()%>/style.css" />
        <script type="text/javascript">
            window.onload = function ()
            {
                var svgContainer = d3.select("body").append("svg")
                        .attr("width", 800)
                        .attr("height", 803);
                //Draw the Circle
                var circle = svgContainer.append("circle")
                        .attr("cx", 35)
                        .attr("cy", 145)
                        .attr("r", 25)
                        .style("stroke-opacity", .9)
                        .style("stroke", "green")
                        .style("stroke-width", 2)
                        .style('cursor', 'move')
                        .style("fill", "white");
                function move() {
                    d3.select(this)
                            .attr('x', d3.event.x)
                            .attr('y', d3.event.y);
                };
                var drag = d3.behavior.drag()
                        .origin(function ()
                        {
                            var t = d3.select(this);
                            return {x: t.attr("x"), y: t.attr("y")};
                        })
                        .on('dragend', function (d) {
                            var mouseCoordinates = d3.mouse(this);
                            if (mouseCoordinates[0] > 170) {
                                //Append new element
                                var newCircle = d3.select("svg").append("circle")
                                        .classed("drg", true)
                                        .attr("cx", 100)
                                        .attr("cy", 100)
                                        .attr("r", 20)
                                        .attr("cx", mouseCoordinates[0])
                                        .attr("cy", mouseCoordinates[1])
                                        .style("fill", "white")
                                        .style("stroke-width", 2)
                                        .style("stroke", "#CDB483")
                                        .call(
                                                d3.behavior.drag()
                                                .on('drag', move).origin(function () {
                                            var t = d3.select(this);
                                            return {x: t.attr("cx"), y: t.attr("cy")};
                                        }));
                                ;
                            }
                        });
                circle.call(drag);
            };
        </script>
    </head>
    <body>
        <div id="container">
            <div id="header" style="margin-bottom: 0;">
                <h1 id="title">Editor</h1>
                <div id="footer"></div>
            </div>
        </div>
    </body>
</html>
Output

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
anonymouspro
0viewers