cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

Quick-add: + add another resource

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              <div ng-app="demo" ng-controller="MyCtrl">
  <breadcrumb paths="paths" go="go"></breadcrumb>
  <drill-table class="table"
    headers="['No', 'Period', 'Profile']"
    source="profits"
    drill-down="drillDown(profit)">
  </drill-table>
</div>
            
          
!
            
              a {
  text-decoration: none;
  color: #333;
  cursor: pointer;
}

a:hover {
  text-decoration: underline;
}

.breadcrumb {
  display: inline-block;
  line-height: 24px;
  z-index: 1;
  font-size: 14px;
}

.breadcrumb ul {
  padding-left: 4px;
}

.breadcrumb ul, .breadcrumb li {
  display: inline-block;
  list-style: none;
}

.breadcrumb li .ellipsis {
  display: inline-block;
  max-width: 160px;
  vertical-align: middle;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.breadcrumb .splitter {
  padding-left: 4px;
  padding-right: 4px;
  color: #666;
}

table, tbody, td, tfoot, th, thead, tr {
  border: 0;
  margin: 0;
  padding: 0;
}

table {
  display: table;
  background-color: transparent;
  border-spacing: 0;
  border-collapse: collapse;
}

.table {
  width: 100%;
  max-width: 100%;
  margin-bottom: 20px;
}

.table-bordered {
  border: 1px solid #ddd;
}

.table > tbody > tr > td, .table > tbody > tr > th,
.table > thead > tr > td, .table > thead > tr > th {
  padding: 8px;
  line-height: 1.42857143;
  vertical-align: top;
  border-top: 1px solid #ddd;
}

.table-bordered > tbody > tr > td, .table-bordered > tbody > tr > th,
.table-bordered > thead > tr > td, .table-bordered > thead > tr > th {
  border: 1px solid #ddd;
}

tr {
  display: table-row;
  vertical-align: inherit;
  border-color: inherit;
}

thead, tbody {
  display: table-header-group;
  vertical-align: middle;
  border-color: inherit;
}

th {
  text-align: left;
  background-color: #f8f8f8;
}

td, th {
  display: table-cell;
  padding: 0;
}

tbody {
  display: table-row-group;
  vertical-align: middle;
  border-color: inherit;
}
            
          
!
            
              angular
  .module('demo', [])
  .controller("MyCtrl", function($scope) {
    $scope.profits = [{
      name: '2014',
      value: 35400,
      data: [{
        name: 'Q1',
        value: 7500,
        data: [{
          name: 'Jan',
          value: 2000
        }, {
          name: 'Feb',
          value: 2500
        }, {
          name: 'Mar',
          value: 3000
        }]
      }, {
        name: 'Q2',
        value: 7600,
        data: [{
          name: 'Apr',
          value: 2600
        }, {
          name: 'May',
          value: 2800
        }, {
          name: 'Jun',
          value: 2200
        }]
      }, {
        name: 'Q3',
        value: 10400,
        data: [{
          name: 'Jul',
          value: 4000
        }, {
          name: 'Aug',
          value: 3600
        }, {
          name: 'Sep',
          value: 2800
        }]
      }, {
        name: 'Q4',
        value: 9900,
        data: [{
          name: 'Oct',
          value: 3200
        }, {
          name: 'Nov',
          value: 2900
        }, {
          name: 'Dec',
          value: 3800
        }]
      }]
    }, {
      name: '2015',
      value: 41200,
      data: [{
        name: 'Q1',
        value: 9400,
        data: [{
          name: 'Jan',
          value: 2300
        }, {
          name: 'Feb',
          value: 3500
        }, {
          name: 'Mar',
          value: 3600
        }]
      }, {
        name: 'Q2',
        value: 9600,
        data: [{
          name: 'Apr',
          value: 4600
        }, {
          name: 'May',
          value: 2800
        }, {
          name: 'Jun',
          value: 2100
        }]
      }, {
        name: 'Q3',
        value: 10500,
        data: [{
          name: 'Jul',
          value: 3000
        }, {
          name: 'Aug',
          value: 3800
        }, {
          name: 'Sep',
          value: 3700
        }]
      }, {
        name: 'Q4',
        value: 11700,
        data: [{
          name: 'Oct',
          value: 4200
        }, {
          name: 'Nov',
          value: 3900
        }, {
          name: 'Dec',
          value: 3600
        }]
      }]
    }, {
      name: '2016',
      value: 43300,
      data: [{
        name: 'Q1',
        value: 10000,
        data: [{
          name: 'Jan',
          value: 2500
        }, {
          name: 'Feb',
          value: 4500
        }, {
          name: 'Mar',
          value: 3000
        }]
      }, {
        name: 'Q2',
        value: 10700,
        data: [{
          name: 'Apr',
          value: 4800
        }, {
          name: 'May',
          value: 2700
        }, {
          name: 'Jun',
          value: 3200
        }]
      }, {
        name: 'Q3',
        value: 10600,
        data: [{
          name: 'Jul',
          value: 3500
        }, {
          name: 'Aug',
          value: 3600
        }, {
          name: 'Sep',
          value: 3500
        }]
      }, {
        name: 'Q4',
        value: 12000,
        data: [{
          name: 'Oct',
          value: 4500
        }, {
          name: 'Nov',
          value: 3600
        }, {
          name: 'Dec',
          value: 3900
        }]
      }]
    }];

    $scope.paths = ['All'];
    var profits = angular.copy($scope.profits);

    $scope.drillDown = function(profit) {
      if (profit.data) {
        $scope.profits = profit.data;
        $scope.paths.push(profit.name);
      }
    };

    $scope.go = function(path) {
      if (path == 'All') {
        $scope.paths = ['All'];
      } else {
        var index = $scope.paths.indexOf(path);
        $scope.paths = $scope.paths.slice(0, index + 1);
      }
      $scope.profits = downSearch(profits, path);
    };

    /**
     *  Downwards and recursively search
     * @param arr
     * @param searchKey
     * @returns {*}
     */
    function downSearch (arr, searchKey) {
      if (searchKey == 'All') {
        return arr;
      }
      for (var i in arr) {
        var item = arr[i];
        if (item.name == searchKey) {
          if (item.data) {
            return item.data;
          }
          return [];
        } else {
          downSearch(item.data, searchKey)
        }
      }
    }
  })
  /**
   * Define drillTable directive
   * @param headers {Array} th data provider
   * @param source {Array} td data provider
   * @param drillDown {Function} click to drill down
   */
  .directive('drillTable', function() {
    return {
      restrict: 'EA',
      replace: true,
      scope: {
        headers: '=',
        source: '=',
        drillDown: '&'
      },
      template: '<table class="table table-bordered">\n' +
      '  <thead ng-if="source && source.length > 0">\n' +
      '    <tr>\n' +
      '      <th ng-repeat="item in headers">{{item}}</th>\n' +
      '    </tr>\n' +
      '  </thead>\n' +
      '  <tbody>\n' +
      '    <tr ng-repeat="item in source"\n' +
      '      ng-init="hasData=item.data"\n' +
      '      ng-if="source && source.length > 0">\n' +
      '      <td>{{$index + 1}}</td>\n' +
      '      <td  title="{{hasData ? \'Drill Down\' : \'\'}}" ng-click="drillDown({profit: item})">\n' +
      '        {{item.name}} {{hasData ? \'...\' : \'\'}}\n' +
      '      </td>\n' +
      '      <td>{{item.value|number}}</td>\n' +
      '    </tr>\n' +
      '    <tr ng-if="source.length == 0">\n' +
      '      <td>No Data</td>\n' +
      '    <tr>\n' +
      '  </tbody>\n' +
      '</table>'
    };
  })
  /**
   * define breadcrumb directive
   * @param paths {Array} breadcrumb data provider
   * @param labelField {String} path field name
   * @param jump {Function} click to go to new view
   */
  .directive('breadcrumb', function() {
    return {
      restrict: 'EA',
      replace: true,

      scope: {
        paths: '=',
        labelField: '@',
        go: '&'
      },
      template: '<div class="breadcrumb" ng-show="paths.length > 1">\n' +
      '  <span class="back">\n' +
      '    <a ng-click="go()(paths[paths.length - 2])">上一级</a>\n' +
      '    <span class="splitter"> | </span>\n' +
      '  </span>\n' +
      '  <ul ng-repeat="item in paths">\n' +
      '    <li ng-init="path=(item[labelField] || item)">\n' +
      '      <a class="ellipsis" title="{{path}}" ng-click="go()(path)"\n' +
      '        ng-if="!$last">{{path}}</a>\n' +
      '      <span class="ellipsis" title="{{path}}" ng-if="$last">{{path}}</span>\n' +
      '      <span class="splitter" ng-if="!$last"> &gt; </span>\n' +
      '    </li>\n' +
      '  </ul>\n' +
      '</div>',
      compile: function(element, attr) {
        if (attr.labelField == undefined) {
          attr.labelField = 'name';
        }
      }
    }
  });
            
          
!
999px
Loading ..................

Console