Add Chunk & Entity Graphs

Remove New Players Graph from visualization

Filter out 0s from some TPS data averages
This commit is contained in:
Rsl1122 2017-07-28 14:42:11 +03:00
parent b371f0fb1e
commit 36373968a7
4 changed files with 309 additions and 119 deletions

View File

@ -5,6 +5,7 @@ import main.java.com.djrapitops.plan.data.TPS;
import main.java.com.djrapitops.plan.ui.html.graphs.CPUGraphCreator;
import main.java.com.djrapitops.plan.ui.html.graphs.RamGraphCreator;
import main.java.com.djrapitops.plan.ui.html.graphs.TPSGraphCreator;
import main.java.com.djrapitops.plan.ui.html.graphs.WorldLoadGraphCreator;
import main.java.com.djrapitops.plan.utilities.FormatUtils;
import main.java.com.djrapitops.plan.utilities.MiscUtils;
import main.java.com.djrapitops.plan.utilities.analysis.MathUtils;
@ -41,37 +42,47 @@ public class TPSPart extends RawData<TPSPart> {
String tpsScatterDay = TPSGraphCreator.buildScatterDataStringTPS(day, TimeAmount.DAY.ms());
String tpsScatterWeek = TPSGraphCreator.buildScatterDataStringTPS(week, TimeAmount.WEEK.ms());
String cpuScatterDay = CPUGraphCreator.buildScatterDataString(day, TimeAmount.DAY.ms());
String cpuScatterWeek = CPUGraphCreator.buildScatterDataString(week, TimeAmount.WEEK.ms());
String ramScatterDay = RamGraphCreator.buildScatterDataString(day, TimeAmount.DAY.ms());
String ramScatterWeek = RamGraphCreator.buildScatterDataString(week, TimeAmount.WEEK.ms());
String entityScatterDay = WorldLoadGraphCreator.buildScatterDataStringEntities(day, TimeAmount.DAY.ms());
String entityScatterWeek = WorldLoadGraphCreator.buildScatterDataStringEntities(week, TimeAmount.WEEK.ms());
String chunkScatterDay = WorldLoadGraphCreator.buildScatterDataStringChunks(day, TimeAmount.DAY.ms());
String chunkScatterWeek = WorldLoadGraphCreator.buildScatterDataStringChunks(week, TimeAmount.WEEK.ms());
addValue("tpsscatterday", tpsScatterDay);
addValue("tpsscatterweek", tpsScatterWeek);
addValue("cpuscatterday", cpuScatterDay);
addValue("cpuscatterweek", cpuScatterWeek);
addValue("ramscatterday", ramScatterDay);
addValue("ramscatterweek", ramScatterWeek);
addValue("entityscatterday", entityScatterDay);
addValue("entityscatterweek", entityScatterWeek);
addValue("chunkscatterday", chunkScatterDay);
addValue("chunkscatterweek", chunkScatterWeek);
Runtime runtime = Runtime.getRuntime();
addValue("maxram", runtime.maxMemory() / 1000000);
double averageTPSWeek = MathUtils.averageDouble(week.stream().map(TPS::getTps));
double averageTPSDay = MathUtils.averageDouble(day.stream().map(TPS::getTps));
double averageCPUWeek = MathUtils.averageDouble(week.stream().map(TPS::getCPUUsage));
double averageCPUDay = MathUtils.averageDouble(day.stream().map(TPS::getCPUUsage));
double averageCPUWeek = MathUtils.averageDouble(week.stream().map(TPS::getCPUUsage).filter(i -> i == 0));
double averageCPUDay = MathUtils.averageDouble(day.stream().map(TPS::getCPUUsage).filter(i -> i == 0));
long averageUsedMemoryWeek = MathUtils.averageLong(week.stream().map(TPS::getUsedMemory));
long averageUsedMemoryDay = MathUtils.averageLong(day.stream().map(TPS::getUsedMemory));
long averageUsedMemoryWeek = MathUtils.averageLong(week.stream().map(TPS::getUsedMemory).filter(i -> i == 0));
long averageUsedMemoryDay = MathUtils.averageLong(day.stream().map(TPS::getUsedMemory).filter(i -> i == 0));
double averageEntityCountWeek = MathUtils.averageInt(week.stream().map(TPS::getEntityCount));
double averageEntityCountDay = MathUtils.averageInt(day.stream().map(TPS::getEntityCount));
double averageEntityCountWeek = MathUtils.averageInt(week.stream().map(TPS::getEntityCount).filter(i -> i == 0));
double averageEntityCountDay = MathUtils.averageInt(day.stream().map(TPS::getEntityCount).filter(i -> i == 0));
double averageChunksLoadedWeek = MathUtils.averageInt(week.stream().map(TPS::getChunksLoaded));
double averageChunksLoadedDay = MathUtils.averageInt(day.stream().map(TPS::getChunksLoaded));
double averageChunksLoadedWeek = MathUtils.averageInt(week.stream().map(TPS::getChunksLoaded).filter(i -> i == 0));
double averageChunksLoadedDay = MathUtils.averageInt(day.stream().map(TPS::getChunksLoaded).filter(i -> i == 0));
addValue("averagetps", FormatUtils.cutDecimals(averageTPSWeek)); //Staying for backwards compatibility
addValue("averagetpsweek", FormatUtils.cutDecimals(averageTPSWeek));

View File

@ -7,7 +7,22 @@ import main.java.com.djrapitops.plan.utilities.analysis.Point;
import java.util.List;
import java.util.stream.Collectors;
/**
* Class for creating scatter graph data from RAM Usage snapshots with TPS task.
*
* @author Rsl1122
* @since 3.6.0
* @see main.java.com.djrapitops.plan.data.listeners.TPSCountTimer
*/
public class RamGraphCreator {
/**
* Creates a scatter data string from given data.
*
* @param tpsData TPS Data collected by TPSCountTimer, one data point for each minute.
* @param scale Time span this graph resides within. (Milliseconds)
* @return Scatter Graph data string for ChartJs
*/
public static String buildScatterDataString(List<TPS> tpsData, long scale) {
long now = MiscUtils.getTime();
List<Point> points = tpsData.stream()

View File

@ -1,5 +1,50 @@
package main.java.com.djrapitops.plan.ui.html.graphs;
import main.java.com.djrapitops.plan.data.TPS;
import main.java.com.djrapitops.plan.utilities.MiscUtils;
import main.java.com.djrapitops.plan.utilities.analysis.Point;
import java.util.List;
import java.util.stream.Collectors;
/**
* Class for creating scatter graph data from Chunk & Entity load snapshots with TPS task.
*
* @author Rsl1122
* @since 3.6.0
* @see main.java.com.djrapitops.plan.data.listeners.TPSCountTimer
*/
public class WorldLoadGraphCreator {
// TODO
/**
* Creates scatter graph data of entity load.
*
* @param tpsData TPS Data collected by TPSCountTimer, one data point for each minute.
* @param scale Time span this graph resides within. (Milliseconds)
* @return Scatter Graph data string for ChartJs
*/
public static String buildScatterDataStringEntities(List<TPS> tpsData, long scale) {
long now = MiscUtils.getTime();
List<Point> entityPoints = tpsData.stream()
.filter(tps -> tps.getDate() >= now - scale)
.map(tps -> new Point(tps.getDate(), tps.getEntityCount()))
.collect(Collectors.toList());
return ScatterGraphCreator.scatterGraph(entityPoints, true);
}
/**
* Creates scatter graph data of chunk load.
*
* @param tpsData TPS Data collected by TPSCountTimer, one data point for each minute.
* @param scale Time span this graph resides within. (Milliseconds)
* @return Scatter Graph data string for ChartJs
*/
public static String buildScatterDataStringChunks(List<TPS> tpsData, long scale) {
long now = MiscUtils.getTime();
List<Point> chunkPoints = tpsData.stream()
.filter(tps -> tps.getDate() >= now - scale)
.map(tps -> new Point(tps.getDate(), tps.getChunksLoaded()))
.collect(Collectors.toList());
return ScatterGraphCreator.scatterGraph(chunkPoints, true);
}
}

View File

@ -677,56 +677,51 @@
<div class="row">
<div class="box column">
<div class="headerbox">
<div class="header-icon" style="width: 50%">
<div class="header-label"><i class="fa fa-tachometer" aria-hidden="true"></i><span
class="header-text"> TPS - 7d</span></div>
</div>
<div class="infobox" style="width: 40%;">
<div class="info-icon">
<i class="fa fa-tachometer" aria-hidden="true"></i>
</div>
<div class="info-text" style="width: 70%;">
<div class="info-number">
%averagetps%
</div>
<div class="info-label">
Average 7d
</div>
</div>
<div class="header-icon">
<div class="header-label"><i class="fa fa-cogs" aria-hidden="true"></i><span
class="header-text"> Performance 7d</span></div>
</div>
</div>
<p>
<i class="fa fa-tachometer" aria-hidden="true"></i> Average TPS: %averagetpsweek%<br>
<i class="fa fa-building-o" aria-hidden="true"></i> Average CPU: %averagecpuweek%%<br>
<i class="fa fa-microchip" aria-hidden="true"></i> Average RAM: %averagememoryweek%Mb<br>
<i class="fa fa-umbrella" aria-hidden="true"></i> Avg. Entities: %averageentitiesweek%<br>
<i class="fa fa-tree" aria-hidden="true"></i> Average Chunks: %averagechunksweek%
</p>
</div>
<div class="box column">
<canvas id="tps7d" width="1000" height="600" style="width: 95%;"></canvas>
</div>
<div class="box column">
<canvas id="cpu7d" width="1000" height="600" style="width: 95%;"></canvas>
</div>
<div class="box column">
<canvas id="world7d" width="1000" height="600" style="width: 95%;"></canvas>
</div>
</div>
<div class="row">
<div class="box column">
<div class="headerbox">
<div class="header-icon" style="width: 50%">
<div class="header-label"><i class="fa fa-tachometer" aria-hidden="true"></i><span
class="header-text"> TPS - 24h</span></div>
</div>
<div class="infobox" style="width: 40%;">
<div class="info-icon">
<i class="fa fa-tachometer" aria-hidden="true"></i>
</div>
<div class="info-text" style="width: 70%;">
<div class="info-number">
%averagetpsday%
</div>
<div class="info-label">
Average 24h
</div>
</div>
<div class="header-icon">
<div class="header-label"><i class="fa fa-cogs" aria-hidden="true"></i><span
class="header-text"> Performance 24h</span></div>
</div>
</div>
<p><i class="fa fa-tachometer" aria-hidden="true"></i> Average TPS: %averagetpsday%<br>
<i class="fa fa-building-o" aria-hidden="true"></i> Average CPU: %averagecpuday%%<br>
<i class="fa fa-microchip" aria-hidden="true"></i> Average RAM: %averagememoryday%Mb<br>
<i class="fa fa-umbrella" aria-hidden="true"></i> Avg. Entities: %averageentitiesday%<br>
<i class="fa fa-tree" aria-hidden="true"></i> Average Chunks: %averagechunksday%</p>
</div>
<div class="box column">
<canvas id="tps24h" width="1000" height="600" style="width: 95%;"></canvas>
</div>
<div class="box column">
<canvas id="cpu24h" width="1000" height="600" style="width: 95%;"></canvas>
<p>If Graph displays '-1' usage is not available for this platform.</p>
</div>
<div class="box column">
<canvas id="world24h" width="1000" height="600" style="width: 95%;"></canvas>
</div>
</div>
</div>
@ -957,29 +952,7 @@
pointHitRadius: 10,
spanGaps: false,
data: %datascatterday%
},
{
label: "New Players",
fill: true,
lineTension: 0.1,
backgroundColor: "#fff",
borderColor: "#7dcc24",
borderCapStyle: 'butt',
borderDash: [],
borderDashOffset: 0.0,
borderJoinStyle: 'miter',
pointBorderColor: "#7dcc24",
pointBackgroundColor: "#fff",
pointBorderWidth: 1,
pointHoverRadius: 5,
pointHoverBackgroundColor: "#7dcc24",
pointHoverBorderColor: "#8fabc6",
pointHoverBorderWidth: 2,
pointRadius: 1,
pointHitRadius: 10,
spanGaps: false,
data: %npdataday%
}]
}]
}
var dataweek = {
datasets: [
@ -1004,29 +977,7 @@
pointHitRadius: 10,
spanGaps: false,
data: %datascatterweek% ,
},
{
label: "New Players",
fill: true,
lineTension: 0.1,
backgroundColor: "#fff",
borderColor: "#7dcc24",
borderCapStyle: 'butt',
borderDash: [],
borderDashOffset: 0.0,
borderJoinStyle: 'miter',
pointBorderColor: "#7dcc24",
pointBackgroundColor: "#fff",
pointBorderWidth: 1,
pointHoverRadius: 5,
pointHoverBackgroundColor: "#7dcc24",
pointHoverBorderColor: "#8fabc6",
pointHoverBorderWidth: 2,
pointRadius: 1,
pointHitRadius: 10,
spanGaps: false,
data: %npdataweek%
}]
}]
}
var datamonth = {
datasets: [
@ -1051,29 +1002,7 @@
pointHitRadius: 10,
spanGaps: false,
data: %datascattermonth% ,
},
{
label: "New Players",
fill: true,
lineTension: 0.1,
backgroundColor: "#fff",
borderColor: "#7dcc24",
borderCapStyle: 'butt',
borderDash: [],
borderDashOffset: 0.0,
borderJoinStyle: 'miter',
pointBorderColor: "#7dcc24",
pointBackgroundColor: "#fff",
pointBorderWidth: 1,
pointHoverRadius: 5,
pointHoverBackgroundColor: "#7dcc24",
pointHoverBorderColor: "#8fabc6",
pointHoverBorderWidth: 2,
pointRadius: 1,
pointHitRadius: 10,
spanGaps: false,
data: %npdatamonth%
}]
}]
}
var playersChartDay = new Chart(ctxday, {
type: 'scatter',
@ -1187,8 +1116,6 @@
}
}
});
</script>
<script>
// TPS Graph 7d
@ -1389,7 +1316,7 @@
</script>
<script>
// CPU Graph 24h
// CPU & RAM Graph 24h
var ctxcpu = document.getElementById("cpu24h");
var datacpu = {
datasets: [
@ -1447,7 +1374,7 @@
var newDate = new Date();
newDate.setTime(tooltipItems.xLabel);
dateString = newDate.toUTCString();
return dateString+ ': '+ tooltipItems.yLabel + '%';
return dateString+ ': '+ tooltipItems.yLabel;
}
}
},
@ -1488,7 +1415,7 @@
</script>
<script>
// CPU Graph 7d
// CPU & RAM Graph 7d
var ctxcpu = document.getElementById("cpu7d");
var datacpu = {
datasets: [
@ -1533,7 +1460,7 @@
pointRadius: 1,
pointHitRadius: 10,
spanGaps: false,
data: %ramscatterday%
data: %ramscatterweek%
}]
};
var cpuChart = new Chart(ctxcpu, {
@ -1546,7 +1473,7 @@
var newDate = new Date();
newDate.setTime(tooltipItems.xLabel);
dateString = newDate.toUTCString();
return dateString+ ': '+ tooltipItems.yLabel + '%';
return dateString+ ': '+ tooltipItems.yLabel;
}
}
},
@ -1584,6 +1511,198 @@
}
});
</script>
<script>
// Entity & Chunk Graph 24h
var ctxworld = document.getElementById("world24h");
var dataworld = {
datasets: [
{
label: "Entity Count",
yAxisID: 'A',
fill: false,
lineTension: 0.1,
borderColor: "#ac69ef",
borderCapStyle: 'butt',
borderDash: [],
borderDashOffset: 0.0,
borderJoinStyle: 'miter',
pointBorderColor: "#ac69ef",
pointBackgroundColor: "#ac69ef",
pointBorderWidth: 1,
pointHoverRadius: 5,
pointHoverBackgroundColor: "#ac69ef",
pointHoverBorderColor: "#8fabc6",
pointHoverBorderWidth: 2,
pointRadius: 1,
pointHitRadius: 10,
spanGaps: false,
data: %entityscatterday%
}, {
label: "Chunks Loaded",
yAxisID: 'B',
fill: false,
lineTension: 0.1,
borderColor: "#b58310",
borderCapStyle: 'butt',
borderDash: [],
borderDashOffset: 0.0,
borderJoinStyle: 'miter',
pointBorderColor: "#b58310",
pointBackgroundColor: "#b58310",
pointBorderWidth: 1,
pointHoverRadius: 5,
pointHoverBackgroundColor: "#b58310",
pointHoverBorderColor: "#8fabc6",
pointHoverBorderWidth: 2,
pointRadius: 1,
pointHitRadius: 10,
spanGaps: false,
data: %chunkscatterday%
}]
};
var worldChart = new Chart(ctxworld, {
type: 'scatter',
data: dataworld,
options: {
tooltips: {
callbacks: {
label: function(tooltipItems, data) {
var newDate = new Date();
newDate.setTime(tooltipItems.xLabel);
dateString = newDate.toUTCString();
return dateString+ ': '+ tooltipItems.yLabel;
}
}
},
scales: {
yAxes: [{
id: 'A',
type: 'linear',
position: 'left',
ticks: {
suggestedMin: 0
},
scaleLabel: {
display: true,
labelString: 'Entity Count'
}
}, {
id: 'B',
type: 'linear',
position: 'right',
ticks: {
suggestedMin: 0
},
scaleLabel: {
display: true,
labelString: 'Chunks Loaded'
}
}],
xAxes: [{
type: 'linear',
display: false
}]
}
}
});
</script>
<script>
// Entity & Chunk Graph 7d
var ctxworld = document.getElementById("world7d");
var dataworld = {
datasets: [
{
label: "Entity Count",
yAxisID: 'A',
fill: false,
lineTension: 0.1,
borderColor: "#ac69ef",
borderCapStyle: 'butt',
borderDash: [],
borderDashOffset: 0.0,
borderJoinStyle: 'miter',
pointBorderColor: "#ac69ef",
pointBackgroundColor: "#ac69ef",
pointBorderWidth: 1,
pointHoverRadius: 5,
pointHoverBackgroundColor: "#ac69ef",
pointHoverBorderColor: "#8fabc6",
pointHoverBorderWidth: 2,
pointRadius: 1,
pointHitRadius: 10,
spanGaps: false,
data: %entityscatterweek%
}, {
label: "Chunks Loaded",
yAxisID: 'B',
fill: false,
lineTension: 0.1,
borderColor: "#b58310",
borderCapStyle: 'butt',
borderDash: [],
borderDashOffset: 0.0,
borderJoinStyle: 'miter',
pointBorderColor: "#b58310",
pointBackgroundColor: "#b58310",
pointBorderWidth: 1,
pointHoverRadius: 5,
pointHoverBackgroundColor: "#b58310",
pointHoverBorderColor: "#8fabc6",
pointHoverBorderWidth: 2,
pointRadius: 1,
pointHitRadius: 10,
spanGaps: false,
data: %chunkscatterweek%
}]
};
var worldChart = new Chart(ctxworld, {
type: 'scatter',
data: dataworld,
options: {
tooltips: {
callbacks: {
label: function(tooltipItems, data) {
var newDate = new Date();
newDate.setTime(tooltipItems.xLabel);
dateString = newDate.toUTCString();
return dateString+ ': '+ tooltipItems.yLabel;
}
}
},
scales: {
yAxes: [{
id: 'A',
type: 'linear',
position: 'left',
ticks: {
suggestedMin: 0
},
scaleLabel: {
display: true,
labelString: 'Entity Count'
}
}, {
id: 'B',
type: 'linear',
position: 'right',
ticks: {
suggestedMin: 0
},
scaleLabel: {
display: true,
labelString: 'Chunks Loaded'
}
}],
xAxes: [{
type: 'linear',
display: false
}]
}
}
});
</script>
<script>
// ActivityPie Graph