Skip to content

Commit 83ba64b

Browse files
committed
added stats graph for FPS
1 parent 205a17d commit 83ba64b

File tree

5 files changed

+98
-1
lines changed

5 files changed

+98
-1
lines changed

SkyNX-Streamer/css/styles.css

+13
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,17 @@ label {
3030
}
3131
#consoleInput:focus {
3232
outline: none;
33+
}
34+
35+
.chartpanel{
36+
margin: 8px;
37+
padding: 8px;
38+
background: rgba(39, 39, 39, 0.9);
39+
border-radius: 6px;
40+
overflow: hidden;
41+
color: white;
42+
box-shadow: 4px 4px 14px 0px rgba(0,0,0,0.7);
43+
}
44+
.chartTitle{
45+
margin-left: 8px;
3346
}

SkyNX-Streamer/index.html

+12-1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
<div id="navBar" class="customScroll rainbowScrollColor">
2828
<button id="main-btn" class="navBar-btns" data-toggle="tooltip" data-placement="right" data-html="true"
2929
title="Streamer"><i class="fas fa-desktop"></i></button>
30+
<button id="stats-btn" class="navBar-btns" data-toggle="tooltip" data-placement="right" data-html="true"
31+
title="Stats"><i class="fas fa-chart-pie"></i></button>
3032
<button id="settings-btn" class="navBar-btns" data-toggle="tooltip" data-placement="right" data-html="true"
3133
title="Settings"><i class="fas fa-cogs"></i></button>
3234
<button id="console-btn" class="navBar-btns" data-toggle="tooltip" data-placement="right" data-html="true"
@@ -51,7 +53,14 @@
5153
<label>More Settings coming soon..</label>
5254
</div>
5355
</div>
54-
56+
</div>
57+
<div id="stats" class="contentArea contentAreaScrollable customScroll" style="display: none;">
58+
<div class="chartpanel">
59+
<h5 class="chartTitle">FPS</h5>
60+
<div style="width: 100%; height: 150px;">
61+
<canvas id="fpsChart"></canvas>
62+
</div>
63+
</div>
5564
</div>
5665
<div id="settings" class="contentArea contentAreaScrollable customScroll" style="display: none;">
5766
<div class="form-group">
@@ -113,6 +122,7 @@ <h1 style="color:rgb(206, 206, 206); font-size: 16px;">
113122
</div>
114123
</div>
115124
<script src="js/fontawesome-all.min.js"></script>
125+
<script src="js/Chart.min.js"></script>
116126
<script>
117127
let $ = require('jquery');
118128
require('popper.js');
@@ -125,6 +135,7 @@ <h1 style="color:rgb(206, 206, 206); font-size: 16px;">
125135
<script src="./js/window.js"></script>
126136
<script src="./js/main.js"></script>
127137
<script src="./js/settings.js"></script>
138+
<script src="./js/stats.js"></script>
128139
<script src="./js/console.js"></script>
129140
</body>
130141

SkyNX-Streamer/js/Chart.min.js

+7
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

SkyNX-Streamer/js/console.js

+8
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ ipcRenderer.on('log', function (event, genHtml) {
66
var fps = genHtml.split("fps= ")[1].split(" ")[0];
77
var bitrate = genHtml.split("bitrate=")[1].split(" ")[0];
88
$("#statusbartext").html("Framrate: " + fps + " Bitrate: " + bitrate);
9+
fpsChartData.datasets[0].data.push(parseInt(fps));
10+
if (fpsChartData.datasets[0].data.length > 20) {
11+
fpsChartData.datasets[0].data.shift();
12+
}
13+
if ($("#stats").is(":visible")) {
14+
fpsChartData.labels = genrateLabelList("FPS", fpsChartData.datasets[0].data.length);
15+
fpsChart.update(0);
16+
}
917
} else if (genHtml.includes("Connection timed out") || genHtml.includes("Waiting for connection")) {
1018
$("#statusbartext").html("Waiting for connection...");
1119
} else if (genHtml.includes("streamerProcess process exited")) {

SkyNX-Streamer/js/stats.js

+58
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
function genrateLabelList(label, length) {
2+
var labels = [];
3+
while (length > 0) {
4+
labels.push(label);
5+
length--;
6+
}
7+
return labels;
8+
}
9+
var fpsChartData = {
10+
labels: ['FPS', 'FPS', 'FPS', 'FPS', 'FPS', 'FPS', 'FPS', 'FPS', 'FPS', 'FPS', 'FPS', 'FPS', 'FPS', 'FPS', 'FPS', 'FPS', 'FPS', 'FPS', 'FPS', 'FPS'],
11+
datasets: [{
12+
label: 'FPS',
13+
data: [0],
14+
backgroundColor: 'rgba(0, 0, 255, 0.8)',
15+
borderColor: 'rgba(255, 255, 255, 0)',
16+
fillOpacity: .3,
17+
fill: true,
18+
borderWidth: 0
19+
}]
20+
};
21+
22+
var fpsChartctx = document.getElementById('fpsChart').getContext('2d');
23+
var fpsChart = new Chart(fpsChartctx, {
24+
type: 'line',
25+
data: fpsChartData,
26+
options: {
27+
maintainAspectRatio: false,
28+
legend: {
29+
display: false
30+
},
31+
elements: {
32+
point: {
33+
radius: 0
34+
}
35+
},
36+
scales: {
37+
yAxes: [{
38+
ticks: {
39+
beginAtZero: true,
40+
max: 60
41+
}
42+
}],
43+
xAxes: [{
44+
gridLines: {
45+
display: false
46+
},
47+
ticks: {
48+
display: false //this will remove only the label
49+
}
50+
}]
51+
}
52+
}
53+
});
54+
$("#stats-btn").click(function () {
55+
$(".contentArea").hide();
56+
$("#stats").fadeIn(400);
57+
$('#stats-btn').tooltip('hide');
58+
});

0 commit comments

Comments
 (0)