CAKE-168 | fixed getHeightByDate method

This commit is contained in:
OleksandrSobol 2020-11-12 21:12:58 +02:00
parent 70467b1fe7
commit d682f6504b

View file

@ -98,14 +98,14 @@ int getHeigthByDate({DateTime date}) {
startHeight = dates.values.toList()[dates.length - 2]; startHeight = dates.values.toList()[dates.length - 2];
endHeight = dates.values.toList()[dates.length - 1]; endHeight = dates.values.toList()[dates.length - 1];
final heightPerDay = (endHeight - startHeight) / 31; final heightPerDay = (endHeight - startHeight) / 31;
final daysHeight = (heightCoefficient * date.day * heightPerDay).round(); final daysHeight = (heightCoefficient * (date.day - 1) * heightPerDay).round();
height = endHeight + daysHeight; height = endHeight + daysHeight;
} else { } else {
startHeight = dates[raw]; startHeight = dates[raw];
final index = dates.values.toList().indexOf(startHeight); final index = dates.values.toList().indexOf(startHeight);
endHeight = dates.values.toList()[index + 1]; endHeight = dates.values.toList()[index + 1];
final heightPerDay = (endHeight - startHeight) / 31; final heightPerDay = (endHeight - startHeight) / 31;
final daysHeight = date.day * heightPerDay.round(); final daysHeight = (date.day - 1) * heightPerDay.round();
height = startHeight + daysHeight; height = startHeight + daysHeight;
} }