Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.6/d3.min.js"></script>
<html ng-app="app">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width">
  <title>JS Bin</title>
</head>
<body>
<script src="https://rawgit.com/angular/bower-angular/master/angular.min.js"></script>
<div id="container1" ng-init="chart=[10, 20, 30]"> 
            <work-history chart-data="chart"></work-history>
        </div>
</body>
</html>
 
    angular
        .module('app', [])
        .directive('workHistory', workHistory);
    function workHistory()
    {
        var directive = 
            {
              restrict: 'EA',
              scope: {data: '=chartData'},
              replace:true,
              template: "<div style='width:100%'></div>",
              link: workHistoryLink,
            };
        return directive;
    }
    function workHistoryLink(scope, element/*, attrs, ctrl, tfn*/)
    {
      scope.$watch('data', function(){
        var chart = d3.select(element[0]);
        chart.append("div").attr("class", "chart")
          .selectAll('div')
          .data(scope.data).enter().append("div")
          .style('background', 'blue')
          .transition().ease("elastic")
          .style("width", function(d) { return d + "%"; })
          .text(function(d) { return d + "%"; })
          .exit().remove();
      }, true);
    } 
Output

This bin was created anonymously and its free preview time has expired (learn why). — Get a free unrestricted account

Dismiss x
public
Bin info
anonymouspro
0viewers