diff options
Diffstat (limited to 'pages/stats.inc')
-rw-r--r-- | pages/stats.inc | 172 |
1 files changed, 0 insertions, 172 deletions
diff --git a/pages/stats.inc b/pages/stats.inc index 19d4453..bd537f9 100644 --- a/pages/stats.inc +++ b/pages/stats.inc @@ -263,178 +263,6 @@ $switchesCloudburst = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . } }); </script> - - <br> - <h3>Time at front in the last 30 days</h3> - <canvas id="graph-01" style="width: 100%; height: 300px; max-height: 100%;"></canvas> - <script> - function toDuration(seconds, remainder) { - if (seconds > 60) { - if (seconds > 3600) { - if (seconds > 86400) { - if (remainder) { - return Math.floor(seconds / 86400) + " d. " + Math.floor((seconds / 3600) - Math.floor(seconds / 86400) * 24) + " hr. " + Math.floor((seconds - (Math.floor(seconds / 3600) * 3600)) / 60) + " min. " + Math.floor((seconds - (Math.floor(seconds / 3600) * 3600)) - (Math.floor((seconds - (Math.floor(seconds / 3600) * 3600)) / 60)) * 60) + " sec."; - } else { - return Math.round(seconds / 86400) + " d."; - } - } else { - if (remainder) { - return Math.floor(seconds / 3600) + " hr. " + Math.floor((seconds - (Math.floor(seconds / 3600) * 3600)) / 60) + " min. " + Math.floor((seconds - (Math.floor(seconds / 3600) * 3600)) - (Math.floor((seconds - (Math.floor(seconds / 3600) * 3600)) / 60)) * 60) + " sec."; - } else { - return Math.round(seconds / 3600) + " hr."; - } - } - } else { - if (remainder) { - return Math.round(seconds / 60) + " min. " + Math.floor((seconds - (Math.floor(seconds / 3600) * 3600)) - (Math.floor((seconds - (Math.floor(seconds / 3600) * 3600)) / 60)) * 60) + " sec."; - } else { - return Math.round(seconds / 60) + " min."; - } - } - } else { - return seconds + " sec."; - } - } - - const ctx1 = document.getElementById('graph-01').getContext('2d'); - window.graph01 = { - label: "Members", - data: JSON.parse(`<?= json_encode(array_map(function ($i) { - return $i["time"]; - }, array_values($members))) ?>`), - backgroundColor: JSON.parse(`<?= json_encode(array_map(function ($i) { - return "#" . $i["color"] . "33"; - }, array_values($members))) ?>`), - borderColor: JSON.parse(`<?= json_encode(array_map(function ($i) { - return "#" . $i["color"]; - }, array_values($members))) ?>`), - borderWidth: 1 - }; - const graph1 = new Chart(ctx1, { - type: 'bar', - data: { - labels: JSON.parse(`<?= json_encode(array_map(function ($i) { - return $i["name"]; - }, array_values($members))) ?>`), - datasets: [ - window.graph01 - ] - }, - options: { - animation: { - duration: 0 - }, - scales: { - y: { - beginAtZero: true, - ticks: { - callback: function(label) { - return toDuration(label); - } - } - }, - x: { - grid: { - color: "rgba(255,255,255,0.25)" - } - } - }, - elements: { - point:{ - radius: 0 - } - }, - plugins: { - legend: { - display: false - }, - tooltip: { - callbacks: { - label: function(tooltipItem) { - return toDuration(tooltipItem.raw, true); - } - } - } - } - } - }); - </script> - - <br> - <h3>Time at front per month</h3> - <canvas id="graph-02" style="width: 100%; height: 300px; max-height: 100%;"></canvas> - <script> - const ctx2 = document.getElementById('graph-02').getContext('2d'); - window.chart02 = JSON.parse(`<?= json_encode(array_values(array_map(function ($i) use ($frontersMonthMembers) { - $name = getMemberWithoutSystem(array_search($i, $frontersMonthMembers))["name"]; - $month = (int)implode("-", explode("-", array_search($i, $frontersMonthMembers))); - - $k = array_filter($i, function ($i) { - return isset($i["name"]) && isset($i["color"]); - }); - - if (count($k) > 0) { - return [ - "label" => $k[array_keys($k)[0]]["name"], - "data" => array_values(array_map(function ($j) use ($name, $month) { - return $name === "twilight" && $month < 202208 ? 0 : $j["duration"]; - }, $i)), - "borderColor" => "#" . $k[array_keys($k)[0]]["color"] - ]; - } else { - return [ - "label" => getMemberWithoutSystem(array_search($i, $frontersMonthMembers))["display_name"], - "data" => array_values(array_map(function ($j) { - return $j["duration"]; - }, $i)), - "borderColor" => "#" . getMemberWithoutSystem(array_search($i, $frontersMonthMembers))["color"] - ]; - } - }, $frontersMonthMembers))) ?>`); - console.log(JSON.parse(`<?= json_encode(array_map(function ($i) { - return date("M Y", strtotime($i . "-00T00:00:00.000Z")); - }, array_keys($frontersMonthRectified))) ?>`)); - const graph2 = new Chart(ctx2, { - type: 'line', - data: { - labels: JSON.parse(`<?= json_encode(array_map(function ($i) { - return date("M Y", strtotime($i . "-00T00:00:00.000Z")); - }, array_keys($frontersMonthRectified))) ?>`), - datasets: window.chart02 - }, - options: { - animation: { - duration: 0 - }, - scales: { - y: { - beginAtZero: true, - grid: { - color: "rgba(255,255,255,0.25)" - }, - ticks: { - callback: function(label) { - return toDuration(label); - } - } - } - }, - plugins: { - legend: { - display: false - }, - tooltip: { - intersect: false, - callbacks: { - label: function(tooltipItem) { - return tooltipItem.dataset.label + ": " + toDuration(tooltipItem.raw, true); - } - } - } - } - } - }); - </script> </div> </div> |