From e077f9ee1845e1a551084e0239a65209ad395cae Mon Sep 17 00:00:00 2001 From: David Hudson Date: Fri, 30 Sep 2016 21:34:03 +0200 Subject: [PATCH] [Timeline] Fix logic error Issue #1185. Also removed direct modification of domain object. --- .../timeline/src/capabilities/GraphCapability.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/platform/features/timeline/src/capabilities/GraphCapability.js b/platform/features/timeline/src/capabilities/GraphCapability.js index 4e9cce0c8c..181c909f79 100644 --- a/platform/features/timeline/src/capabilities/GraphCapability.js +++ b/platform/features/timeline/src/capabilities/GraphCapability.js @@ -37,7 +37,8 @@ define( // Build graphs for this group of utilizations function buildGraphs(utilizations) { var utilizationMap = {}, - result = {}; + result = {}, + startingSOC; // Bucket utilizations by type utilizations.forEach(function (u) { @@ -55,14 +56,14 @@ define( if (domainObject.getModel().type === 'timeline' && result.power && domainObject.getModel().capacity > 0) { - domainObject.getModel().startingSOC = - parseFloat(domainObject.getModel().startingSOC) || 100; + startingSOC = isNaN(parseFloat(domainObject.getModel().startingSOC)) ? + 100 : parseFloat(domainObject.getModel().startingSOC); result.battery = new CumulativeGraph( result.power, 0, domainObject.getModel().capacity, // Watts - (domainObject.getModel().startingSOC / 100) * domainObject.getModel().capacity, + (startingSOC / 100) * domainObject.getModel().capacity, 1 / 3600000 // millis-to-hour (since units are watt-hours) ); }