Commit ebc4c709 authored by Jasin's avatar Jasin

Stats on Mainpage

parent 8e0db099
......@@ -19,6 +19,8 @@
<link href="css/freelancer.min.css" rel="stylesheet">
<link href="css/dataSection.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.min.css">
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-84269579-2"></script>
<script>
......@@ -191,6 +193,23 @@
</div>
</section>
<!-- About Section -->
<section class="bg-primary text-white mb-0" id="stats">
<div class="container">
<h2 class="text-center text-uppercase text-white">Statistik</h2>
<hr class="star-light mb-5">
<div class="row">
<canvas class="mainChart" id="myChart"></canvas>
</div>
<div class="text-center mt-4">
<a class="btn btn-xl btn-outline-light" href="https://rnv-monitor.de/public/stats">
<i class="far fa-chart-bar mr-2"></i>
Statistik zu Ihrer Verbindung
</a>
</div>
</div>
</section>
<!-- About Section -->
<section class="bg-primary text-white mb-0" id="about">
<div class="container">
......@@ -368,6 +387,15 @@
<script src="js/freelancer.min.js"></script>
<script src="js/dataLoader.js"></script>
<script src="js/chart.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.8.0/Chart.min.js"></script>
<script>
$( document ).ready(function()
{
statsDataLoader();
});
</script>
</body>
</html>
var myChart;
function addDataSet(delays, name)
{
let color = "##18bc9c;";
let Dataset =
{
label: name,
backgroundColor: color,
borderColor: color,
data: delays,
fill: false
};
chartConfig.data.datasets.push(Dataset);
window.myChart.update();
}
function initChart(config)
{
const ctx = document.getElementById('myChart').getContext('2d');
myChart = new Chart(ctx, config);
}
let chartConfig =
{
type: 'line',
data: {
labels: [],
datasets: []
},
options:
{
title:
{
display: true
}
}
};
function statsDataLoader()
{
let settings =
{
"async": true,
"crossDomain": true,
"url": "https://rnv-monitor.de/public/server/getGeneralStats.php",
"method": "GET"
};
$.ajax(settings)
.done(function (response)
{
//Get Information
response = JSON.parse(response);
console.log(response);
let dataDelays = [];
for(let i = 0; i < response.length; i++)
{
dataDelays.push(response[i].delays);
}
let labels = [];
for(let e = 0; e < amount; e++)
{
labels.push(response[e].created);
}
chartConfig.data.labels = labels;
initChart(chartConfig);
addDataSet(dataDelays, lineLabel);
});
}
\ No newline at end of file
......@@ -38,12 +38,12 @@ let chartConfig =
datasets: []
},
options:
{
title:
{
display: true
}
}
{
title:
{
display: true
}
}
};
function dataLoader(lineLabel, amount, first)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment