add interval for seconds for bar charts

This commit is contained in:
2020-09-27 17:15:02 +02:00
parent 10155f9cdb
commit 2f4d1f701b
6 changed files with 15 additions and 3 deletions

View File

@@ -36,6 +36,7 @@
<mat-label>Intervals (only bar chart):</mat-label>
<mat-select [(value)]="intervalUnit">
<mat-option value="NO_INTERVAL">-</mat-option>
<mat-option value="SECOND">second</mat-option>
<mat-option value="MINUTE">minute</mat-option>
<mat-option value="HOUR">hour</mat-option>
<mat-option value="DAY">day</mat-option>

View File

@@ -28,6 +28,8 @@ public class Interval {
private String toDateFormatForBucketer(final IntervalTimeUnit intervalTimeUnit) {
switch (intervalTimeUnit) {
case SECOND:
return "yyyy-MM-dd'\\n'HH:mm:ss";
case MINUTE:
return "yyyy-MM-dd'\\n'HH:mm";
case HOUR:

View File

@@ -3,7 +3,7 @@ package org.lucares.pdb.plot.api;
import org.lucares.utils.DateBucketUnit;
public enum IntervalTimeUnit {
MINUTE, HOUR, DAY, WEEK, MONTH, YEAR;
SECOND, MINUTE, HOUR, DAY, WEEK, MONTH, YEAR;
public static boolean isValid(final String value) {
for (final IntervalTimeUnit e : values()) {
@@ -16,6 +16,8 @@ public enum IntervalTimeUnit {
public DateBucketUnit toChronoUnit() {
switch (this) {
case SECOND:
return DateBucketUnit.SECOND;
case MINUTE:
return DateBucketUnit.MINUTE;
case HOUR:

View File

@@ -19,6 +19,10 @@ public class BeginningOfNextInterval implements TemporalAdjuster {
result = result.with(startOfInterval);
switch (unit) {
case SECOND: {
result = result.plus(1, ChronoUnit.SECONDS);
break;
}
case MINUTE: {
result = result.plus(1, ChronoUnit.MINUTES);
break;

View File

@@ -1,5 +1,5 @@
package org.lucares.utils;
public enum DateBucketUnit {
MINUTE, HOUR, DAY, WEEK, MONTH, YEAR;
SECOND, MINUTE, HOUR, DAY, WEEK, MONTH, YEAR;
}

View File

@@ -18,7 +18,6 @@ public class StartOfInterval implements TemporalAdjuster {
result = result.with(ChronoField.NANO_OF_SECOND, 0);
result = result.with(ChronoField.MICRO_OF_SECOND, 0);
result = result.with(ChronoField.MILLI_OF_SECOND, 0);
result = result.with(ChronoField.SECOND_OF_MINUTE, 0);
for (final DateBucketUnit dateBucketUnit : DateBucketUnit.values()) {
if (dateBucketUnit.compareTo(unit) >= 0) {
@@ -26,6 +25,10 @@ public class StartOfInterval implements TemporalAdjuster {
}
switch (dateBucketUnit) {
case SECOND: {
result = result.with(ChronoField.SECOND_OF_MINUTE, 0);
break;
}
case MINUTE: {
result = result.with(ChronoField.MINUTE_OF_HOUR, 0);
break;