maisons-phenix
clone your own copy | download snapshot

Snapshots | iceberg

No images in this repository’s iceberg at this time

Inside this repository

index.html
text/html

Download raw (1.7 KB)

<!DOCTYPE html>
<html>
<head>
    <script src="http://code.jquery.com/jquery-latest.min.js"></script>
    <script src="http://mbostock.github.com/d3/d3.js"></script>
</head>
<body>
    <script>
    var dataset = [
        [5, 20], [480, 90], [250, 50], [100, 33], [330, 95],
        [410, 12], [475, 44], [25, 67], [85, 21], [220, 88]
    ];
    var dataset2 = [
        [410, 12], [475, 44], [25, 67], [85, 21], [220, 88],
        [5, 20], [480, 90], [250, 50], [100, 33], [330, 95]
    ];

    
    function randomInt(n) {
        return Math.floor(Math.random() * n)
    }


    function randomDataset() {
        var data = [],
            i;

        for (i = 0; i < 100; i++) {
            data.push([randomInt(w), randomInt(h)]);
        }

        return data;
    }
    
    var svg; 

    function redraw() {
        svg.selectAll("circle")
                .data(randomDataset())
            .transition()
                .duration(1000)
                .attr("cx", function(d, i) {
                    return d[0];
                })
                .attr("cy", function(d, i) {
                    return d[1];
                });
    }

    var w, h;


    jQuery(document).ready(function () {
        w = $(window).width() - 25;
        h = $(window).height() - 25;

        svg = d3.select("body")
            .append("svg")
            .attr("width", w)
            .attr("height", h);

        var circles = svg.selectAll("circle")
                 .data(randomDataset())
                 .enter()
                 .append("circle");

        circles.attr("cx", function(d, i) {
                return d[0];
            })
            .attr("cy", function(d, i) {
                return d[1];
            })
            .attr("r", 5);
    });
    </script>
</body>
</html>