Merge pull request '#8 -- fix x-axis dates' (#9) from 8-bug-dates into master

Reviewed-on: #9
This commit is contained in:
romanov73 2022-10-08 14:42:17 +04:00
commit 35d88d4aa6
2 changed files with 6 additions and 4 deletions

View File

@ -99,11 +99,10 @@ public class IndexController {
}
private List<String> getDatesForChart(TimeSeries timeSeries, TimeSeries forecast) {
return Stream.concat(timeSeries.getValues().stream(), forecast.getValues().stream())
return Stream.concat(timeSeries.getValues().stream(), forecast.getValues().stream().skip(1))
.map(TimeSeriesValue::getDate)
.sorted()
.map(date -> date.format(DateTimeFormatter.ofLocalizedDate(FormatStyle.SHORT)))
.distinct()
.collect(Collectors.toList());
}

View File

@ -16,6 +16,7 @@ import java.lang.reflect.InvocationTargetException;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
@ -51,7 +52,8 @@ class MethodParamBruteForce {
}
Map<LocalDateTime, Double> tsValues = timeSeries.getValues().stream()
.collect(Collectors.toMap(TimeSeriesValue::getDate, TimeSeriesValue::getValue));
.collect(Collectors.toMap(TimeSeriesValue::getDate, TimeSeriesValue::getValue,
(oldValue, newValue) -> oldValue, LinkedHashMap::new));
for (Method method : methods) {
List<List<MethodParamValue>> availableParametersValues = getAvailableParametersValues(timeSeries, method.getAvailableParameters());
@ -134,7 +136,8 @@ class MethodParamBruteForce {
List<ModelingResult> results2 = new CopyOnWriteArrayList<>();
Map<LocalDateTime, Double> tsValues = timeSeries.getValues().stream()
.collect(Collectors.toMap(TimeSeriesValue::getDate, TimeSeriesValue::getValue));
.collect(Collectors.toMap(TimeSeriesValue::getDate, TimeSeriesValue::getValue,
(oldValue, newValue) -> oldValue, LinkedHashMap::new));
for (Method method : methods) {
List<List<MethodParamValue>> availableParametersValues = getAvailableParametersValues(timeSeries, method.getAvailableParameters());