#8 -- fix x-axis dates #9

Merged
romanov73 merged 1 commits from 8-bug-dates into master 2022-10-08 14:42:17 +04:00
2 changed files with 6 additions and 4 deletions
Showing only changes of commit 9d0a862feb - Show all commits

View File

@ -99,11 +99,10 @@ public class IndexController {
} }
private List<String> getDatesForChart(TimeSeries timeSeries, TimeSeries forecast) { 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) .map(TimeSeriesValue::getDate)
.sorted() .sorted()
.map(date -> date.format(DateTimeFormatter.ofLocalizedDate(FormatStyle.SHORT))) .map(date -> date.format(DateTimeFormatter.ofLocalizedDate(FormatStyle.SHORT)))
.distinct()
.collect(Collectors.toList()); .collect(Collectors.toList());
} }

View File

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