From afe1aa406edc1d4f44ff5cd4d64e7bcec9d7127d Mon Sep 17 00:00:00 2001 From: Amineta Lo Date: Thu, 24 Aug 2017 09:28:26 -0400 Subject: [PATCH] fix(pfTrendsChart): Updated trend chart and trend card with right label config --- src/card/examples/card-trend.js | 17 +++++++++++-- src/charts/charts.less | 4 +-- src/charts/trends/trends-chart.component.js | 27 ++++++++++++++++----- src/charts/trends/trends-chart.html | 4 +-- test/charts/trends/trends-chart.spec.js | 12 +++++++++ 5 files changed, 52 insertions(+), 12 deletions(-) diff --git a/src/card/examples/card-trend.js b/src/card/examples/card-trend.js index 994638b83..2c33c5b78 100644 --- a/src/card/examples/card-trend.js +++ b/src/card/examples/card-trend.js @@ -38,6 +38,9 @@ + + + @@ -57,7 +60,7 @@ 'callBackFn': function () { alert("Footer Callback Fn Called"); } - } + }; $scope.filterConfig = { 'filters' : [{label:'Last 30 Days', value:'30'}, @@ -67,7 +70,7 @@ alert("Filter Callback Fn Called for '" + f.label + "' value = " + f.value); }, 'defaultFilter' : '1' - } + }; var today = new Date(); var dates = ['dates']; @@ -84,6 +87,16 @@ 'tooltipType' : 'percentage' }; + $scope.configRightLabel = { + 'chartId' : 'exampleRightLabelTrendsChart', + 'title' : 'Storage Capacity', + 'layout' : 'compact', + 'valueType' : 'actual', + 'units' : 'TB', + 'tooltipType' : 'percentage', + 'compactLabelPosition' : 'right' + }; + $scope.dataSingle = { 'total': '250', 'xData': dates, diff --git a/src/charts/charts.less b/src/charts/charts.less index 58450da63..0c807b087 100644 --- a/src/charts/charts.less +++ b/src/charts/charts.less @@ -64,10 +64,10 @@ pf-c3-chart { } .trend-card-compact-pf { - .col-sm-2 { + .col-sm-2:not(.col-sm-push-10) { padding-right: 0; } - .col-sm-10 { + .col-sm-10:not(.col-sm-pull-2) { padding-left: 0; } } diff --git a/src/charts/trends/trends-chart.component.js b/src/charts/trends/trends-chart.component.js index 14256fba2..3254beabf 100644 --- a/src/charts/trends/trends-chart.component.js +++ b/src/charts/trends/trends-chart.component.js @@ -15,6 +15,7 @@ *
  • .chartId - the unique id of this trends chart *
  • .title - (optional) title of the Trends chart *
  • .layout - (optional) the layout and sizes of titles and chart. Values are 'large' (default), 'small', 'compact', and 'inline' + *
  • .compactLabelPosition - (optional) the trend label positioning when the layout value is 'compact'. Values are 'left' (default) or 'right' *
  • .trendLabel - (optional) the trend label used in the 'inline' layout *
  • .timeFrame - (optional) the time frame for the data in the pfSparklineChart, ex: 'Last 30 Days' *
  • .units - unit label for values, ex: 'MHz','GB', etc.. @@ -44,7 +45,7 @@
    -
    +

    -
    - +
    +
    +
    +
    +
    +
    + + +
    +
    +
    @@ -125,7 +139,8 @@ valueType : 'actual', timeFrame : 'Last 15 Minutes', units : 'MHz', - tooltipType : 'percentage' + tooltipType : 'percentage', + compactLabelPosition : 'left' }; $scope.footerConfig = { @@ -134,7 +149,7 @@ callBackFn: function () { alert("Footer Callback Fn Called"); } - } + }; $scope.filterConfig = { filters : [{label:'Last 30 Days', value:'30'}, @@ -143,7 +158,7 @@ callBackFn: function (f) { alert("Filter Callback Fn Called for '" + f.label + "' value = " + f.value); } - } + }; $scope.layouts = [ { diff --git a/src/charts/trends/trends-chart.html b/src/charts/trends/trends-chart.html index d70d2f9d2..7281f2612 100644 --- a/src/charts/trends/trends-chart.html +++ b/src/charts/trends/trends-chart.html @@ -19,7 +19,7 @@
    -
    +
    {{$ctrl.getLatestValue()}} @@ -32,7 +32,7 @@ {{$ctrl.config.title}}
    -
    +
    diff --git a/test/charts/trends/trends-chart.spec.js b/test/charts/trends/trends-chart.spec.js index 7664d24a1..b621042d2 100644 --- a/test/charts/trends/trends-chart.spec.js +++ b/test/charts/trends/trends-chart.spec.js @@ -95,6 +95,18 @@ describe('Directive: pfTrendsChart', function() { expect(trendCard.length).toBe(1); }); + it("should push/pull label to the right when compactLabelPosition is 'right'", function() { + $scope.config.layout = 'compact'; + $scope.config.compactLabelPosition = 'right'; + $scope.$digest(); + + trendCard = element.find('.col-sm-2'); + expect(trendCard.hasClass('col-sm-push-10')).toEqual(true); + + trendCard = element.find('.col-sm-10'); + expect(trendCard.hasClass('col-sm-pull-2')).toEqual(true); + }); + it("should show inline card layout", function() { $scope.config.layout = 'inline'; $scope.$digest();