mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-15 05:41:51 +08:00
Added option for displaying gaps in graph data #534
This commit is contained in:
parent
a9e7260c92
commit
e44fc781e4
@ -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"),
|
||||||
|
@ -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) {
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
@ -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:
|
||||||
|
@ -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.
|
||||||
|
@ -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: {
|
||||||
|
@ -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: {
|
||||||
|
Loading…
Reference in New Issue
Block a user