nick34992
3/11/2017 - 12:35 AM

D3byEX 9.10: Symbols (Adapted to D3.js v4)

D3byEX 9.10: Symbols (Adapted to D3.js v4)

<!DOCTYPE html>
<html><meta charset=utf-8>
<head>
    <meta name="description" content="D3.js v4, built-in symbol array" />
</head>

<body>
    <script src="http://d3js.org/d3.v4.min.js"></script>
    <script src="https://d3js.org/d3-selection-multi.v1.min.js"></script>
    <script>

        var svg = d3.select('body')
                    .append('svg')
                    .attrs({ width: 500, height: 250 }); // v4

        svg.selectAll('path')
           .data(d3.symbols) // v4
           .enter()
           .append('path')
           .attrs({ // v4
               d: d3.symbol().type(function (d) { return d; }),
               transform: function (d, i) {
                   return 'translate(' + (i * 20 + 10) + ',10)';
               }
           });

    </script>
</body>
</html>