CSNW/d3.compose

View on GitHub
integration/components/legend.html

Summary

Maintainability
Test Coverage
<!doctype html>
<html>
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <title>d3.compose - legend</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" type="text/css" href="../../build/d3.compose.css">
  <style>
    .chart {
      float: left;
      width: 400px;
      margin-right: 10px;
      margin-bottom: 10px;
    }
    svg {
      border: solid 1px #ccc;
    }
  </style>
</head>
<body>
  <div id="charts"></div>

  <script src="../../node_modules/d3/d3.js"></script>
  <script src="../../build/d3.compose.js"></script>
  <script type="text/javascript">
    var charts = d3.select('#charts');
    var id = 1;
    function draw(props) {
      var chart = charts.append('div')
        .attr('id', 'chart-' + (id++))
        .attr('class', 'chart');
      var container = new d3c.Compose(chart);
      container.draw(d3c.legend(props));
    }

    var data = [
      {text: 'A', key: 'a'},
      {text: 'B', key: 'b'},
      {text: 'C', key: 'c'}
    ];

    draw({data: data});
  </script>
</body>
</html>