Ping graph and ping graph colors

This commit is contained in:
Rsl1122 2018-07-16 15:23:49 +03:00
parent ead8024ca5
commit 6282862438
15 changed files with 150 additions and 7 deletions

View File

@ -119,6 +119,9 @@ public class AnalysisContainer extends DataContainer {
putRawData(AnalysisKeys.WORLD_MAP_LOW_COLOR, Theme.getValue(ThemeVal.WORLD_MAP_LOW));
putRawData(AnalysisKeys.WORLD_MAP_HIGH_COLOR, Theme.getValue(ThemeVal.WORLD_MAP_HIGH));
putRawData(AnalysisKeys.WORLD_PIE_COLORS, Theme.getValue(ThemeVal.GRAPH_WORLD_PIE));
putRawData(AnalysisKeys.AVG_PING_COLOR, Theme.getValue(ThemeVal.GRAPH_AVG_PING));
putRawData(AnalysisKeys.MAX_PING_COLOR, Theme.getValue(ThemeVal.GRAPH_MAX_PING));
putRawData(AnalysisKeys.MIN_PING_COLOR, Theme.getValue(ThemeVal.GRAPH_MIN_PING));
}
private void addPlayerSuppliers() {
@ -330,7 +333,15 @@ public class AnalysisContainer extends DataContainer {
putSupplier(geolocationBarChart, () -> new GeolocationBarGraph(getUnsafe(AnalysisKeys.PLAYERS_MUTATOR)));
putSupplier(AnalysisKeys.COUNTRY_CATEGORIES, () -> getUnsafe(geolocationBarChart).toHighChartsCategories());
putSupplier(AnalysisKeys.COUNTRY_SERIES, () -> getUnsafe(geolocationBarChart).toHighChartsSeries());
Key<PingGraph> pingGraph = new Key<>(PingGraph.class, "PING_GRAPH");
putSupplier(pingGraph, () -> new PingGraph(
PingMutator.forContainer(serverContainer).mutateToByMinutePings().all()
));
putSupplier(AnalysisKeys.AVG_PING_SERIES, () -> getUnsafe(pingGraph).toAvgSeries());
putSupplier(AnalysisKeys.MAX_PING_SERIES, () -> getUnsafe(pingGraph).toMaxSeries());
putSupplier(AnalysisKeys.MIN_PING_SERIES, () -> getUnsafe(pingGraph).toMinSeries());
putSupplier(AnalysisKeys.CALENDAR_SERIES, () -> new ServerCalendar(
getUnsafe(AnalysisKeys.PLAYERS_MUTATOR),
getUnsafe(AnalysisKeys.UNIQUE_PLAYERS_PER_DAY),

View File

@ -41,8 +41,12 @@ public class AnalysisKeys {
public static final PlaceholderKey<String> TPS_HIGH_COLOR = new PlaceholderKey<>(String.class, "tpsHighColor");
public static final PlaceholderKey<String> TPS_MEDIUM_COLOR = new PlaceholderKey<>(String.class, "tpsMediumColor");
public static final PlaceholderKey<String> TPS_LOW_COLOR = new PlaceholderKey<>(String.class, "tpsLowColor");
public static final PlaceholderKey<String> AVG_PING_COLOR = new PlaceholderKey<>(String.class, "avgPingColor");
public static final PlaceholderKey<String> MIN_PING_COLOR = new PlaceholderKey<>(String.class, "minPingColor");
public static final PlaceholderKey<String> MAX_PING_COLOR = new PlaceholderKey<>(String.class, "maxPingColor");
public static final PlaceholderKey<String> WORLD_MAP_HIGH_COLOR = CommonPlaceholderKeys.WORLD_MAP_HIGH_COLOR;
public static final PlaceholderKey<String> WORLD_MAP_LOW_COLOR = CommonPlaceholderKeys.WORLD_MAP_LOW_COLOR;
// Tables & other structures
public static final PlaceholderKey<String> PLAYERS_TABLE = new PlaceholderKey<>(String.class, "tablePlayerlist");
public static final PlaceholderKey<String> SESSION_ACCORDION_HTML = new PlaceholderKey<>(String.class, "accordionSessions");
@ -129,6 +133,9 @@ public class AnalysisKeys {
public static final PlaceholderKey<String> CALENDAR_SERIES = new PlaceholderKey<>(String.class, "calendarSeries");
public static final PlaceholderKey<String> UNIQUE_PLAYERS_SERIES = new PlaceholderKey<>(String.class, "uniquePlayersSeries");
public static final PlaceholderKey<String> NEW_PLAYERS_SERIES = new PlaceholderKey<>(String.class, "newPlayersSeries");
public static final PlaceholderKey<String> AVG_PING_SERIES = new PlaceholderKey<>(String.class, "avgPingSeries");
public static final PlaceholderKey<String> MAX_PING_SERIES = new PlaceholderKey<>(String.class, "maxPingSeries");
public static final PlaceholderKey<String> MIN_PING_SERIES = new PlaceholderKey<>(String.class, "minPingSeries");
public static final PlaceholderKey<String> COUNTRY_CATEGORIES = CommonPlaceholderKeys.COUNTRY_CATEGORIES;
public static final PlaceholderKey<String> COUNTRY_SERIES = CommonPlaceholderKeys.COUNTRY_SERIES;
// Variables used only during analysis

View File

@ -1,5 +1,6 @@
package com.djrapitops.plan.data.store.keys;
import com.djrapitops.plan.data.container.Ping;
import com.djrapitops.plan.data.container.PlayerKill;
import com.djrapitops.plan.data.container.Session;
import com.djrapitops.plan.data.container.TPS;
@ -34,6 +35,7 @@ public class ServerKeys {
public static final Key<Integer> PLAYER_COUNT = new Key<>(Integer.class, "player_count");
public static final Key<List<Session>> SESSIONS = CommonKeys.SESSIONS;
public static final Key<List<Ping>> PING = CommonKeys.PING;
public static final Key<WorldTimes> WORLD_TIMES = CommonKeys.WORLD_TIMES;
public static final Key<List<PlayerKill>> PLAYER_KILLS = CommonKeys.PLAYER_KILLS;

View File

@ -245,4 +245,11 @@ public class PlayersMutator {
return players.stream()
.filter(player -> player.getValue(PlayerKeys.OPERATOR).orElse(false)).collect(Collectors.toList());
}
public List<Ping> pings() {
return players.stream()
.map(player -> player.getValue(PlayerKeys.PING).orElse(new ArrayList<>()))
.flatMap(Collection::stream)
.collect(Collectors.toList());
}
}

View File

@ -60,6 +60,7 @@ public class SQLFetchOps extends SQLOps implements FetchOperations {
container.putSupplier(ServerKeys.PLAYER_COUNT, () -> container.getUnsafe(ServerKeys.PLAYERS).size());
container.putSupplier(ServerKeys.TPS, () -> tpsTable.getTPSData(serverUUID));
container.putSupplier(ServerKeys.PING, () -> PlayersMutator.forContainer(container).pings());
container.putSupplier(ServerKeys.ALL_TIME_PEAK_PLAYERS, () -> {
Optional<TPS> allTimePeak = tpsTable.getAllTimePeak(serverUUID);
if (allTimePeak.isPresent()) {

View File

@ -51,6 +51,9 @@ public enum ThemeVal {
GRAPH_GM_PIE("GraphColors.GMDrilldown", "\"#438c99\", \"#639A67\", \"#D8EBB5\", \"#D9BF77\""),
GRAPH_ACTIVITY_PIE("GraphColors.ActivityPie", "\"#4CAF50\", \"#8BC34A\", \"#CDDC39\", \"#FFC107\", \"#607D8B\""),
GRAPH_SERVER_PREF_PIE("GraphColors.ServerPreferencePie", "\"#0099C6\", \"#66AA00\", \"#316395\", \"#994499\", \"#22AA99\", \"#AAAA11\", \"#6633CC\", \"#E67300\", \"#329262\", \"#5574A6\""),
GRAPH_AVG_PING("GraphColors.Ping.Avg", "#ffc107"),
GRAPH_MAX_PING("GraphColors.Ping.Max", "#ffa000"),
GRAPH_MIN_PING("GraphColors.Ping.Min", "#ffd54f"),
WORLD_MAP_HIGH("GraphColors.WorldMap_High", "#267f00"),
WORLD_MAP_LOW("GraphColors.WorldMap_Low", "#EEFFEE"),

View File

@ -50,7 +50,8 @@ public class AnalysisPage implements Page {
WORLD_PIE_COLORS, GM_PIE_COLORS, ACTIVITY_PIE_COLORS,
PLAYERS_GRAPH_COLOR, TPS_HIGH_COLOR, TPS_MEDIUM_COLOR,
TPS_LOW_COLOR, WORLD_MAP_HIGH_COLOR, WORLD_MAP_LOW_COLOR
TPS_LOW_COLOR, WORLD_MAP_HIGH_COLOR, WORLD_MAP_LOW_COLOR,
AVG_PING_COLOR, MAX_PING_COLOR, MIN_PING_COLOR
);
playersTable(placeholderReplacer);
sessionStructures(placeholderReplacer);
@ -158,7 +159,8 @@ public class AnalysisPage implements Page {
WORLD_MAP_SERIES, ACTIVITY_STACK_SERIES, ACTIVITY_STACK_CATEGORIES,
ACTIVITY_PIE_SERIES, CALENDAR_SERIES,
UNIQUE_PLAYERS_SERIES, NEW_PLAYERS_SERIES,
COUNTRY_CATEGORIES, COUNTRY_SERIES
COUNTRY_CATEGORIES, COUNTRY_SERIES,
AVG_PING_SERIES, MAX_PING_SERIES, MIN_PING_SERIES
);
Benchmark.stop(DEBUG, DEBUG + " Chart Series");
}

View File

@ -0,0 +1,49 @@
package com.djrapitops.plan.utilities.html.graphs.line;
import com.djrapitops.plan.data.container.Ping;
import java.util.ArrayList;
import java.util.List;
public class PingGraph {
private final AbstractLineGraph maxGraph;
private final AbstractLineGraph minGraph;
private final AbstractLineGraph avgGraph;
/**
* Constructor.
*
* @param pings List of Ping values:
* List should be filtered so that only a single entry for each date exists.
*/
public PingGraph(List<Ping> pings) {
List<Point> max = new ArrayList<>();
List<Point> min = new ArrayList<>();
List<Point> avg = new ArrayList<>();
for (Ping ping : pings) {
long date = ping.getDate();
max.add(new Point(date, ping.getMax()));
min.add(new Point(date, ping.getMin()));
avg.add(new Point(date, ping.getAverage()));
}
maxGraph = new AbstractLineGraph(max);
minGraph = new AbstractLineGraph(min);
avgGraph = new AbstractLineGraph(avg);
}
public String toMaxSeries() {
return maxGraph.toHighChartsSeries();
}
public String toMinSeries() {
return minGraph.toHighChartsSeries();
}
public String toAvgSeries() {
return avgGraph.toHighChartsSeries();
}
}

View File

@ -52,6 +52,10 @@ GraphColors:
ServerPreferencePie: '"#707070", "#828282", "#595959", "#676767", "#7F7F7F", "#989898", "#535353", "#888888", "#6F6F6F", "#707070"'
WorldMap_High: "#555555"
WorldMap_Low: "#DDDDDD"
Ping:
Max: '#707070'
Avg: '#828282'
Min: '#595959'
# Leave blank "" for white
ParsedElements:

View File

@ -52,6 +52,10 @@ GraphColors:
ServerPreferencePie: '"#2A89A5", "#709B31", "#0075FE", "#865186", "#459A8F", "#A3A344", "#5F3F9E", "#C27B33", "#4A8567", "#5F7291"'
WorldMap_High: "#386F21"
WorldMap_Low: "#EEFFEE"
Ping:
Max: '#ffa000'
Avg: '#ffc107'
Min: '#ffd54f'
# Leave blank "" for white
ParsedElements:

View File

@ -52,6 +52,10 @@ GraphColors:
ServerPreferencePie: '"#00E0FF", "#35EF00", "#0075FE", "#F007F0", "#00F5C6", "#C9C900", "#8700FF", "#FF4E00", "#00CF4C", "#267BFF"'
WorldMap_High: "#00C800"
WorldMap_Low: "#EEFFEE"
Ping:
Max: '#ffa000'
Avg: '#ffc107'
Min: '#ffd54f'
# Leave blank "" for white
ParsedElements:

View File

@ -52,6 +52,10 @@ GraphColors:
ServerPreferencePie: '"#84705F", "#948271", "#6D5948", "#7B6755", "#917F6E", "#A89889", "#675342", "#9A8877", "#836F5D", "#84705F"'
WorldMap_High: "#695544"
WorldMap_Low: "#FFFFFF"
Ping:
Max: '#ffa000'
Avg: '#ffc107'
Min: '#ffd54f'
# Leave blank "" for white
ParsedElements:

View File

@ -52,6 +52,10 @@ GraphColors:
ServerPreferencePie: '"#00869B", "#79AC00", "#25455D", "#8D3472", "#33A887", "#C5BC24", "#492176", "#EA7C00", "#307F4C", "#516681"'
WorldMap_High: "#267f00"
WorldMap_Low: "#EEFFEE"
Ping:
Max: '#ffa000'
Avg: '#ffc107'
Min: '#ffd54f'
# Leave blank "" for white
ParsedElements:

View File

@ -52,6 +52,10 @@ GraphColors:
ServerPreferencePie: '"#0099C6", "#66AA00", "#316395", "#994499", "#22AA99", "#AAAA11", "#6633CC", "#E67300", "#329262", "#5574A6"'
WorldMap_High: "#267f00"
WorldMap_Low: "#EEFFEE"
Ping:
Max: '#ffa000'
Avg: '#ffc107'
Min: '#ffd54f'
# Leave blank "" for white
ParsedElements:

View File

@ -819,7 +819,7 @@
tabindex="0" data-trigger="focus" data-toggle="popover" data-placement="left"
data-container="body" data-html="true"
data-original-title="Performance Charts"
data-content="Charts of different performance metrics, recorded by TPS task.
data-content="Charts of different performance metrics, recorded by TPS task & Ping task.
<br><br>TPS task starts 50 seconds after Plan enables and records Maximum player count & Average of other metrics for each minute.
<br><br>Any dataset can be hidden by clicking the name in the legend.
<br><br>Note: Due to JVM performance restraints CPU usage may be unavailable on some Machines."
@ -835,6 +835,9 @@
<li role="presentation"><a href="#world" data-toggle="tab"><i
class="fa fa-map"></i>
WORLD LOAD</a></li>
<li role="presentation"><a href="#ping" data-toggle="tab"><i
class="fa fa-signal"></i>
PING</a></li>
</ul>
</div>
</div>
@ -853,6 +856,9 @@
<div role="tabpanel" class="tab-pane fade" id="world">
<div id="worldGraph" style="height: 500px;"></div>
</div>
<div role="tabpanel" class="tab-pane fade" id="ping">
<div id="pingGraph" style="height: 500px;"></div>
</div>
</div>
</div>
</div>
@ -1160,7 +1166,10 @@
chunks: '#b58310',
geolocationsLow: '${worldMapColLow}',
geolocationsHigh: '${worldMapColHigh}',
punchCard: '#222'
punchCard: '#222',
maxPing: '${maxPingColor}',
minPing: '${minPingColor}',
avgPing: '${avgPingColor}'
},
values: {
tpsMed: ${tpsMedium},
@ -1186,7 +1195,10 @@
healthIndex: ${healthIndex},
calendar: ${calendarSeries},
countryCategories: ${countryCategories},
country: ${countrySeries}
country: ${countrySeries},
avgPing: ${avgPingSeries},
maxPing: ${maxPingSeries},
minPing: ${minPingSeries}
}
};
@ -1200,7 +1212,10 @@
cpu: 'CPU Usage (%)',
ram: 'RAM Usage (MB)',
entities: 'Loaded Entities',
chunks: 'Loaded Chunks'
chunks: 'Loaded Chunks',
maxPing: 'Highest Ping',
minPing: 'Lowest Ping',
avgPing: 'Average Ping'
},
tooltip: {
twoDecimals: {
@ -1236,6 +1251,27 @@
color: v.colors.playersOnline,
yAxis: 0
},
avgPing: {
name: s.name.avgPing,
type: s.type.spline,
tooltip: s.tooltip.twoDecimals,
data: v.data.avgPing,
color: v.colors.avgPing
},
maxPing: {
name: s.name.maxPing,
type: s.type.spline,
tooltip: s.tooltip.zeroDecimals,
data: v.data.maxPing,
color: v.colors.maxPing
},
minPing: {
name: s.name.minPing,
type: s.type.spline,
tooltip: s.tooltip.zeroDecimals,
data: v.data.minPing,
color: v.colors.minPing
},
uniquePlayers: {
name: s.name.uniquePlayers,
type: s.type.spline,
@ -1395,6 +1431,7 @@
healthGauge('healthGauge', [v.data.healthIndex]);
onlineActivityCalendar('#calendar', v.data.calendar, v.values.firstDay);
horizontalBarChart('countryBarChart', v.data.countryCategories, [series.country], 'Players');
lineChart('pingGraph', [series.avgPing, series.maxPing, series.minPing]);
${sessionTabGraphViewFunctions}
/**/