From a4b8b942a142e21dacac2d7cb68fba07e02a0ec9 Mon Sep 17 00:00:00 2001 From: Colin McLeod Date: Wed, 7 Oct 2015 02:16:00 -0700 Subject: [PATCH] Show warning when Power priority group 1 exceeds 50%. --- app/js/directives/directive-power-bands.js | 17 +++++++++++++++-- app/less/outfit.less | 21 +++++++++++++++++---- 2 files changed, 32 insertions(+), 6 deletions(-) diff --git a/app/js/directives/directive-power-bands.js b/app/js/directives/directive-power-bands.js index 8e2a124d..10b72008 100644 --- a/app/js/directives/directive-power-bands.js +++ b/app/js/directives/directive-power-bands.js @@ -38,7 +38,7 @@ angular.module('app').directive('powerBands', ['$window', '$translate', '$rootSc }); // Create Y Axis SVG Elements - vis.append('g').attr('class', 'watt axis'); + var wattAxisGroup = vis.append('g').attr('class', 'watt axis'); vis.append('g').attr('class', 'pct axis'); var retText = vis.append('text').attr('x', -3).style('text-anchor', 'end').attr('dy', '0.5em').attr('class', 'primary upp'); var depText = vis.append('text').attr('x', -3).style('text-anchor', 'end').attr('dy', '0.5em').attr('class', 'primary upp'); @@ -94,13 +94,26 @@ angular.module('app').directive('powerBands', ['$window', '$translate', '$rootSc retracted.selectAll('text').remove(); deployed.selectAll('rect').remove(); deployed.selectAll('text').remove(); + wattAxisGroup.selectAll('line.threshold').remove(); // Update X & Y Axis wattScale.range([0, w]).domain([0, maxPwr]).clamp(true); pctScale.range([0, w]).domain([0, maxPwr / available]).clamp(true); - vis.selectAll('.watt.axis').call(wattAxis); + wattAxisGroup.call(wattAxis); vis.selectAll('.pct.axis').attr('transform', 'translate(0,' + innerHeight + ')').call(pctAxis); + var pwrWarningClass = 'threshold' + (bands[0].retractedSum * 2 >= available ? ' exceeded' : '') ; + vis.selectAll('.pct.axis g:nth-child(6)').selectAll('line, text').attr('class', pwrWarningClass); + + wattAxisGroup.append('line') + .attr('x1', pctScale(0.5)) + .attr('x2', pctScale(0.5)) + .attr('y1', 0) + .attr('y2', innerHeight) + .attr('class', pwrWarningClass); + + + retText.attr('y', repY); depText.attr('y', depY); updateLabel(retLbl, w, repY, retBandsSelected, retBandsSelected ? retractedSum : maxBand.retractedSum, available); diff --git a/app/less/outfit.less b/app/less/outfit.less index 328c4a47..d35474f5 100755 --- a/app/less/outfit.less +++ b/app/less/outfit.less @@ -63,11 +63,11 @@ h1 { cursor: pointer; - } - .icon { - float: right; - margin: 0.1em 0.3em 0 0; + .icon { + float: right; + margin: 0.1em 0.3em 0 0; + } } .select { @@ -234,6 +234,19 @@ table.total { stroke-width: 1px; stroke: #000; } + +} + +svg g { + .threshold { + stroke: @secondary-disabled !important; + fill: @secondary-disabled !important; + + &.exceeded { + stroke: @warning !important; + fill: @warning !important; + } + } } #componentPriority {