From 4c78bb92718145fd89fa91396844dc6d2bb92d34 Mon Sep 17 00:00:00 2001 From: Rsl1122 Date: Thu, 7 Sep 2017 19:55:29 +0300 Subject: [PATCH] Combined Performance graphs to a single chart for #249 --- .../plan/utilities/analysis/Analysis.java | 2 +- .../utilities/html/graphs/SeriesCreator.java | 14 ++- .../html/tables/SessionsTableCreator.java | 2 +- Plan/src/main/resources/html/server.html | 95 ++++++++----------- .../src/main/resources/js/performanceGraph.js | 32 +++++++ 5 files changed, 80 insertions(+), 65 deletions(-) create mode 100644 Plan/src/main/resources/js/performanceGraph.js diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java index 3de7c6935..3dc91fa6c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java @@ -289,7 +289,7 @@ public class Analysis { playerCount.addOPs(userInfo.stream().filter(UserInfo::isOpped).map(UserInfo::getUuid).collect(Collectors.toSet())); Map activeSessions = plugin.getDataCache().getActiveSessions(); - Map> sessions = db.getSessionsTable().getSessionInfoOfServer(); + Map> sessions = db.getSessionsTable().getAllSessions(true).get(Plan.getServerUUID()); joinInfo.addActiveSessions(activeSessions); joinInfo.addSessions(sessions); diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/SeriesCreator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/SeriesCreator.java index 0abd24959..542011e8b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/SeriesCreator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/graphs/SeriesCreator.java @@ -5,9 +5,7 @@ */ package main.java.com.djrapitops.plan.utilities.html.graphs; -import main.java.com.djrapitops.plan.utilities.analysis.DouglasPeuckerAlgorithm; import main.java.com.djrapitops.plan.utilities.analysis.Point; -import main.java.com.djrapitops.plan.utilities.analysis.ReduceGapTriangles; import java.util.List; @@ -33,13 +31,13 @@ public class SeriesCreator { public static String seriesGraph(List points, boolean reduceGapTriangles, boolean reducePoints) { StringBuilder arrayBuilder = new StringBuilder("["); - if (reducePoints) { - points = DouglasPeuckerAlgorithm.reducePoints(points, 0); - } +// if (reducePoints) { +// points = DouglasPeuckerAlgorithm.reducePoints(points, 0); +// } - if (reduceGapTriangles) { - points = ReduceGapTriangles.reduce(points); - } +// if (reduceGapTriangles) { +// points = ReduceGapTriangles.reduce(points); +// } int size = points.size(); for (int i = 0; i < size; i++) { diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/SessionsTableCreator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/SessionsTableCreator.java index 4b3d2297c..345a0e29c 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/SessionsTableCreator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/html/tables/SessionsTableCreator.java @@ -93,7 +93,7 @@ public class SessionsTableCreator { } } - double percentage = longest * 1.0 / total; + double percentage = longest * 100.0 / total; return theWorld + " (" + FormatUtils.cutDecimals(percentage) + "%)"; } diff --git a/Plan/src/main/resources/html/server.html b/Plan/src/main/resources/html/server.html index 73b982d84..793479693 100644 --- a/Plan/src/main/resources/html/server.html +++ b/Plan/src/main/resources/html/server.html @@ -18,7 +18,8 @@
- +

Player Analytics v.${version}

@@ -71,7 +72,8 @@
-

${playersOnline}/${playersMax} Players Online
${playersNewDay} New Players Today
+

${playersOnline}/${playersMax} Players Online
${playersNewDay} New Players + Today

${playersActive} Active Players
${playersTotal} Total Players
@@ -85,16 +87,16 @@

Averages:
- • Session Length: ${sessionAverage}
- • Players / Day: ${playersAverage}
- • New Players / Day: ${playersNewAverage}
-
- Total:
- • Playtime: ${playtimeTotal}
- • Sessions: ${sessionCount}
- • Kills: ${killCount}
- • Mob Kills: ${mobKillCount}
- • Deaths: ${deathCount}

+ • Session Length: ${sessionAverage}
+ • Players / Day: ${playersAverage}
+ • New Players / Day: ${playersNewAverage}
+
+ Total:
+ • Playtime: ${playtimeTotal}
+ • Sessions: ${sessionCount}
+ • Kills: ${killCount}
+ • Mob Kills: ${mobKillCount}
+ • Deaths: ${deathCount}

@@ -214,34 +216,16 @@
-
-
-
-

Ticks Per Second

-
- -
-
-
-

Resource Usage

-
- -
-
-
+
-

World Load

+

Performance

-
+

Last 24 Hours

@@ -348,6 +332,7 @@ +
diff --git a/Plan/src/main/resources/js/performanceGraph.js b/Plan/src/main/resources/js/performanceGraph.js new file mode 100644 index 000000000..8796a31f9 --- /dev/null +++ b/Plan/src/main/resources/js/performanceGraph.js @@ -0,0 +1,32 @@ +function performanceChart(id, playersOnlineSeries, tpsSeries, cpuSeries, ramSeries, entitySeries, chunkSeries) { + Highcharts.stockChart(id, { + rangeSelector: { + selected: 2, + buttons: [{ + type: 'hour', + count: 12, + text: '12h' + },{ + type: 'hour', + count: 24, + text: '24h' + },{ + type: 'day', + count: 7, + text: '7d' + },{ + type: 'month', + count: 1, + text: '30d' + },{ + type: 'all', + text: 'All' + }] + }, + title: {text: ''}, + legend: { + enabled: true, + }, + series: [playersOnlineSeries, tpsSeries, cpuSeries, ramSeries, entitySeries, chunkSeries] + }); +} \ No newline at end of file