Code coverage report for src/charts/empty-chart.component.js

Statements: 100% (10 / 10)      Branches: 75% (3 / 4)      Functions: 100% (3 / 3)      Lines: 100% (10 / 10)      Ignored: none     

All files » src/charts/ » empty-chart.component.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35                1             6   6 12 12 12         6   6 6 6          
/**
 *
 * @description
 *   Directive for rendering an empty chart. This is used by chart directives when the data
 *   available flag is set to false.
 *
 * @param {string=} chartHeight height of the chart (no units) - default: 40
 */
angular.module('patternfly.charts').component('pfEmptyChart', {
  bindings: {
    chartHeight: '<?'
  },
  templateUrl: 'charts/empty-chart.html',
  controller: function () {
    'use strict';
    var ctrl = this;
 
    ctrl.setSizeStyles = function () {
      var height = ctrl.chartHeight || 40;
      var topPadding = Math.min(Math.round((height - 40) / 2), 20);
      ctrl.sizeStyles = {
        height: height + 'px',
        'padding-top': topPadding + 'px'
      };
    };
    ctrl.setSizeStyles();
 
    ctrl.$onChanges =  function (changesObj) {
      Eif (changesObj.chartHeight) {
        ctrl.setSizeStyles();
      }
    };
  }
});