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"),
FORMAT_DATE_RECENT_DAYS("Customization.Formatting.Dates.RecentDays"),
DISPLAY_PLAYER_IPS("Customization.Display.PlayerIPs"),
DISPLAY_GAPS_IN_GRAPH_DATA("Customization.Display.GapsInGraphData"),
// Integer
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.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.ACTIVE_PLAY_THRESHOLD
Settings.ACTIVE_PLAY_THRESHOLD, Settings.DISPLAY_GAPS_IN_GRAPH_DATA
};
Log.debug("NetworkSettings: Adding Config Values..");
for (Settings setting : sameStrings) {

View File

@ -5,9 +5,11 @@
*/
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.line.alg.DouglasPeuckerAlgorithm;
import com.djrapitops.plan.utilities.html.graphs.line.alg.ReduceGapTriangles;
import com.djrapitops.plugin.api.TimeAmount;
import java.util.ArrayList;
import java.util.Collection;
@ -45,10 +47,16 @@ public class AbstractLineGraph implements HighChart {
}
int size = points.size();
Long lastX = null;
boolean addMissingPoints = Settings.DISPLAY_GAPS_IN_GRAPH_DATA.isTrue();
for (int i = 0; i < size; i++) {
Point point = points.get(i);
Double y = point.getY();
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("]");
if (i < size - 1) {
arrayBuilder.append(",");
@ -59,6 +67,14 @@ public class AbstractLineGraph implements HighChart {
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() {
this.reduceGapTriangles = true;
}

View File

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

View File

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

View File

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

View File

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

View File

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