Skip to content

Commit e077f9e

Browse files
author
David Hudson
committed
[Timeline] Fix logic error
Issue #1185. Also removed direct modification of domain object.
1 parent e9f4db7 commit e077f9e

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

platform/features/timeline/src/capabilities/GraphCapability.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ define(
3737
// Build graphs for this group of utilizations
3838
function buildGraphs(utilizations) {
3939
var utilizationMap = {},
40-
result = {};
40+
result = {},
41+
startingSOC;
4142

4243
// Bucket utilizations by type
4344
utilizations.forEach(function (u) {
@@ -55,14 +56,14 @@ define(
5556
if (domainObject.getModel().type === 'timeline' &&
5657
result.power &&
5758
domainObject.getModel().capacity > 0) {
58-
domainObject.getModel().startingSOC =
59-
parseFloat(domainObject.getModel().startingSOC) || 100;
59+
startingSOC = isNaN(parseFloat(domainObject.getModel().startingSOC)) ?
60+
100 : parseFloat(domainObject.getModel().startingSOC);
6061

6162
result.battery = new CumulativeGraph(
6263
result.power,
6364
0,
6465
domainObject.getModel().capacity, // Watts
65-
(domainObject.getModel().startingSOC / 100) * domainObject.getModel().capacity,
66+
(startingSOC / 100) * domainObject.getModel().capacity,
6667
1 / 3600000 // millis-to-hour (since units are watt-hours)
6768
);
6869
}

0 commit comments

Comments
 (0)