add interval for seconds for bar charts
This commit is contained in:
@@ -36,6 +36,7 @@
|
|||||||
<mat-label>Intervals (only bar chart):</mat-label>
|
<mat-label>Intervals (only bar chart):</mat-label>
|
||||||
<mat-select [(value)]="intervalUnit">
|
<mat-select [(value)]="intervalUnit">
|
||||||
<mat-option value="NO_INTERVAL">-</mat-option>
|
<mat-option value="NO_INTERVAL">-</mat-option>
|
||||||
|
<mat-option value="SECOND">second</mat-option>
|
||||||
<mat-option value="MINUTE">minute</mat-option>
|
<mat-option value="MINUTE">minute</mat-option>
|
||||||
<mat-option value="HOUR">hour</mat-option>
|
<mat-option value="HOUR">hour</mat-option>
|
||||||
<mat-option value="DAY">day</mat-option>
|
<mat-option value="DAY">day</mat-option>
|
||||||
|
|||||||
@@ -28,6 +28,8 @@ public class Interval {
|
|||||||
|
|
||||||
private String toDateFormatForBucketer(final IntervalTimeUnit intervalTimeUnit) {
|
private String toDateFormatForBucketer(final IntervalTimeUnit intervalTimeUnit) {
|
||||||
switch (intervalTimeUnit) {
|
switch (intervalTimeUnit) {
|
||||||
|
case SECOND:
|
||||||
|
return "yyyy-MM-dd'\\n'HH:mm:ss";
|
||||||
case MINUTE:
|
case MINUTE:
|
||||||
return "yyyy-MM-dd'\\n'HH:mm";
|
return "yyyy-MM-dd'\\n'HH:mm";
|
||||||
case HOUR:
|
case HOUR:
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package org.lucares.pdb.plot.api;
|
|||||||
import org.lucares.utils.DateBucketUnit;
|
import org.lucares.utils.DateBucketUnit;
|
||||||
|
|
||||||
public enum IntervalTimeUnit {
|
public enum IntervalTimeUnit {
|
||||||
MINUTE, HOUR, DAY, WEEK, MONTH, YEAR;
|
SECOND, MINUTE, HOUR, DAY, WEEK, MONTH, YEAR;
|
||||||
|
|
||||||
public static boolean isValid(final String value) {
|
public static boolean isValid(final String value) {
|
||||||
for (final IntervalTimeUnit e : values()) {
|
for (final IntervalTimeUnit e : values()) {
|
||||||
@@ -16,6 +16,8 @@ public enum IntervalTimeUnit {
|
|||||||
|
|
||||||
public DateBucketUnit toChronoUnit() {
|
public DateBucketUnit toChronoUnit() {
|
||||||
switch (this) {
|
switch (this) {
|
||||||
|
case SECOND:
|
||||||
|
return DateBucketUnit.SECOND;
|
||||||
case MINUTE:
|
case MINUTE:
|
||||||
return DateBucketUnit.MINUTE;
|
return DateBucketUnit.MINUTE;
|
||||||
case HOUR:
|
case HOUR:
|
||||||
|
|||||||
@@ -19,6 +19,10 @@ public class BeginningOfNextInterval implements TemporalAdjuster {
|
|||||||
result = result.with(startOfInterval);
|
result = result.with(startOfInterval);
|
||||||
|
|
||||||
switch (unit) {
|
switch (unit) {
|
||||||
|
case SECOND: {
|
||||||
|
result = result.plus(1, ChronoUnit.SECONDS);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case MINUTE: {
|
case MINUTE: {
|
||||||
result = result.plus(1, ChronoUnit.MINUTES);
|
result = result.plus(1, ChronoUnit.MINUTES);
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
package org.lucares.utils;
|
package org.lucares.utils;
|
||||||
|
|
||||||
public enum DateBucketUnit {
|
public enum DateBucketUnit {
|
||||||
MINUTE, HOUR, DAY, WEEK, MONTH, YEAR;
|
SECOND, MINUTE, HOUR, DAY, WEEK, MONTH, YEAR;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ public class StartOfInterval implements TemporalAdjuster {
|
|||||||
result = result.with(ChronoField.NANO_OF_SECOND, 0);
|
result = result.with(ChronoField.NANO_OF_SECOND, 0);
|
||||||
result = result.with(ChronoField.MICRO_OF_SECOND, 0);
|
result = result.with(ChronoField.MICRO_OF_SECOND, 0);
|
||||||
result = result.with(ChronoField.MILLI_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()) {
|
for (final DateBucketUnit dateBucketUnit : DateBucketUnit.values()) {
|
||||||
if (dateBucketUnit.compareTo(unit) >= 0) {
|
if (dateBucketUnit.compareTo(unit) >= 0) {
|
||||||
@@ -26,6 +25,10 @@ public class StartOfInterval implements TemporalAdjuster {
|
|||||||
}
|
}
|
||||||
|
|
||||||
switch (dateBucketUnit) {
|
switch (dateBucketUnit) {
|
||||||
|
case SECOND: {
|
||||||
|
result = result.with(ChronoField.SECOND_OF_MINUTE, 0);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case MINUTE: {
|
case MINUTE: {
|
||||||
result = result.with(ChronoField.MINUTE_OF_HOUR, 0);
|
result = result.with(ChronoField.MINUTE_OF_HOUR, 0);
|
||||||
break;
|
break;
|
||||||
|
|||||||
Reference in New Issue
Block a user