Added option for displaying gaps in graph data #534

This commit is contained in:
Rsl1122 2018-03-12 12:55:24 +02:00
parent a9e7260c92
commit e44fc781e4
8 changed files with 32 additions and 1 deletions

View File

@ -35,6 +35,7 @@ public enum Settings {
WEBSERVER_DISABLED("WebServer.DisableWebServer"), WEBSERVER_DISABLED("WebServer.DisableWebServer"),
FORMAT_DATE_RECENT_DAYS("Customization.Formatting.Dates.RecentDays"), FORMAT_DATE_RECENT_DAYS("Customization.Formatting.Dates.RecentDays"),
DISPLAY_PLAYER_IPS("Customization.Display.PlayerIPs"), DISPLAY_PLAYER_IPS("Customization.Display.PlayerIPs"),
DISPLAY_GAPS_IN_GRAPH_DATA("Customization.Display.GapsInGraphData"),
// Integer // Integer
WEBSERVER_PORT("WebServer.Port"), WEBSERVER_PORT("WebServer.Port"),

View File

@ -147,7 +147,7 @@ public class NetworkSettings {
Settings.MAX_PLAYERS_PLAYERS_PAGE, Settings.PLAYERTABLE_FOOTER, Settings.FORMAT_DATE_RECENT_DAYS, Settings.MAX_PLAYERS_PLAYERS_PAGE, Settings.PLAYERTABLE_FOOTER, Settings.FORMAT_DATE_RECENT_DAYS,
Settings.FORMAT_DATE_RECENT_DAYS_PATTERN, Settings.FORMAT_DATE_CLOCK, Settings.FORMAT_DATE_NO_SECONDS, Settings.FORMAT_DATE_RECENT_DAYS_PATTERN, Settings.FORMAT_DATE_CLOCK, Settings.FORMAT_DATE_NO_SECONDS,
Settings.FORMAT_DATE_FULL, Settings.DISPLAY_PLAYER_IPS, Settings.ACTIVE_LOGIN_THRESHOLD, Settings.FORMAT_DATE_FULL, Settings.DISPLAY_PLAYER_IPS, Settings.ACTIVE_LOGIN_THRESHOLD,
Settings.ACTIVE_PLAY_THRESHOLD Settings.ACTIVE_PLAY_THRESHOLD, Settings.DISPLAY_GAPS_IN_GRAPH_DATA
}; };
Log.debug("NetworkSettings: Adding Config Values.."); Log.debug("NetworkSettings: Adding Config Values..");
for (Settings setting : sameStrings) { for (Settings setting : sameStrings) {

View File

@ -5,9 +5,11 @@
*/ */
package com.djrapitops.plan.utilities.html.graphs.line; package com.djrapitops.plan.utilities.html.graphs.line;
import com.djrapitops.plan.system.settings.Settings;
import com.djrapitops.plan.utilities.html.graphs.HighChart; import com.djrapitops.plan.utilities.html.graphs.HighChart;
import com.djrapitops.plan.utilities.html.graphs.line.alg.DouglasPeuckerAlgorithm; import com.djrapitops.plan.utilities.html.graphs.line.alg.DouglasPeuckerAlgorithm;
import com.djrapitops.plan.utilities.html.graphs.line.alg.ReduceGapTriangles; import com.djrapitops.plan.utilities.html.graphs.line.alg.ReduceGapTriangles;
import com.djrapitops.plugin.api.TimeAmount;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
@ -45,10 +47,16 @@ public class AbstractLineGraph implements HighChart {
} }
int size = points.size(); int size = points.size();
Long lastX = null;
boolean addMissingPoints = Settings.DISPLAY_GAPS_IN_GRAPH_DATA.isTrue();
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
Point point = points.get(i); Point point = points.get(i);
Double y = point.getY(); Double y = point.getY();
long date = (long) point.getX(); long date = (long) point.getX();
if (addMissingPoints && lastX != null && date - lastX > TimeAmount.MINUTE.ms() * 3L) {
addMissingPoints(arrayBuilder, lastX, date);
}
lastX = date;
arrayBuilder.append("[").append(date).append(",").append(y).append("]"); arrayBuilder.append("[").append(date).append(",").append(y).append("]");
if (i < size - 1) { if (i < size - 1) {
arrayBuilder.append(","); arrayBuilder.append(",");
@ -59,6 +67,14 @@ public class AbstractLineGraph implements HighChart {
return arrayBuilder.toString(); return arrayBuilder.toString();
} }
private void addMissingPoints(StringBuilder arrayBuilder, Long lastX, long date) {
long iterate = lastX + TimeAmount.MINUTE.ms();
while (iterate < date) {
arrayBuilder.append("[").append(iterate).append(",null],");
iterate += TimeAmount.MINUTE.ms() * 30L;
}
}
public void reduceGapTriangles() { public void reduceGapTriangles() {
this.reduceGapTriangles = true; this.reduceGapTriangles = true;
} }

View File

@ -15,6 +15,10 @@ public class Point {
this.y = y; this.y = y;
} }
public Point(double x, double y) {
this(x, (Double) y);
}
public double getX() { public double getX() {
return x; return x;
} }

View File

@ -74,6 +74,7 @@ Customization:
MaxPlayersPlayersPage: 25000 MaxPlayersPlayersPage: 25000
PlayerTableFooter: true PlayerTableFooter: true
PlayerIPs: true PlayerIPs: true
GapsInGraphData: false
Formatting: Formatting:
DecimalPoints: '#.##' DecimalPoints: '#.##'
Dates: Dates:

View File

@ -88,6 +88,7 @@ Customization:
MaxPlayersPlayersPage: 25000 MaxPlayersPlayersPage: 25000
PlayerTableFooter: true PlayerTableFooter: true
PlayerIPs: true PlayerIPs: true
GapsInGraphData: false
Formatting: Formatting:
DecimalPoints: '#.##' DecimalPoints: '#.##'
# Dates settings use Java SimpleDateFormat. # Dates settings use Java SimpleDateFormat.

View File

@ -23,6 +23,10 @@ function playersChart(id, playersOnlineSeries, sel) {
text: 'All' text: 'All'
}] }]
}, },
yAxis: {
softMax: 2,
softMin: 0
},
title: {text: ''}, title: {text: ''},
plotOptions: { plotOptions: {
areaspline: { areaspline: {

View File

@ -26,6 +26,10 @@ function playersChartNoNav(id, playersOnlineSeries) {
navigator: { navigator: {
enabled: false enabled: false
}, },
yAxis: {
softMax: 2,
softMin: 0
},
title: {text: ''}, title: {text: ''},
plotOptions: { plotOptions: {
areaspline: { areaspline: {