#8 -- fix x-axis dates

This commit is contained in:
Anton Romanov 2022-10-08 14:40:49 +04:00
parent e267e0c55c
commit 9d0a862feb
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) { 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());