Skip to content
Snippets Groups Projects
Commit ffb12cca authored by David Siegfried's avatar David Siegfried
Browse files

add more stats

parent 7a964a0c
No related branches found
No related tags found
No related merge requests found
......@@ -20,15 +20,46 @@ class StatisticsController extends Controller
Navigation::activateItem('simplebbbconnector/statistics/index');
PageLayout::setTitle(_('Statistik'));
$current_month_complete = Metric::getStatistics('current_month');
$current_week_complete = Metric::getStatistics('current_week');
$last_week_complete = Metric::getStatistics('last_week');
$today_complete = Metric::getStatistics('today');
$data = ['labels' => array_keys($current_month_complete)];
$data['datasets'][] = $this->buildDataSet(strftime('%B'), $current_month_complete, 'red', 'redDark');
$data['datasets'][] = $this->buildDataSet(_('Diese Woche'), Metric::getStatistics('current_week'), 'blue', 'blueDark');
$data['datasets'][] = $this->buildDataSet(_('Letzte Woche'), Metric::getStatistics('last_week'), 'green', 'greenDark');
$data['datasets'][] = $this->buildDataSet(_('Heute'), Metric::getStatistics('today'), 'yellow', 'yellowDark');
$data['datasets'][] = $this->buildDataSet(_('Gestern'), Metric::getStatistics('yesterday'), 'purple', 'purpleDark');
$this->dataset = json_encode($data);
$this->biggest_meetings = Metric::getStatistics('current_month', 'all', 10);
}
public function buildDataSet($label, $data, $border_color, $background_color)
{
$set = [
'label' => $label,
'data' => array_map('intval', array_values($data)),
'borderWidth' => 1
];
$this->labels = json_encode(array_keys($current_month_complete));
$this->current_month_complete = json_encode(array_map('intval', array_values($current_month_complete)));
$this->current_week_complete = json_encode(array_map('intval', array_values($current_week_complete)));
$this->last_week_complete = json_encode(array_map('intval', array_values($last_week_complete)));
$this->today_complete = json_encode(array_map('intval', array_values($today_complete)));
$this->biggest_meetings = Metric::getStatistics('current_month', 'all', 10);
for ($i = 0; $i < count($data); $i++) {
$set['borderColor'][] = $this->getColor($border_color);
$set['backgroundColor'][] = $this->getColor($background_color);
}
return $set;
}
private function getColor($color)
{
$colors = ['redDark' => 'rgba(255, 99, 132, 0.2)',
'red' => 'rgba(255, 99, 132, 1)',
'blueDark' => 'rgba(54, 162, 235, 0.2)',
'blue' => 'rgba(54, 162, 235, 1)',
'yellowDark' => 'rgba(255, 206, 86, 0.2)',
'yellow' => 'rgba(255, 206, 86, 1)',
'greenDark' => 'rgba(75, 192, 192, 0.2)',
'green' => 'rgba(75, 192, 192, 1)',
'purpleDark' => 'rgba(153, 102, 255, 0.2)',
'purple' => 'rgba(153, 102, 255, 1)',
'brownDark' => 'rgba(255, 159, 64, 0.2)',
'brown' => 'rgba(255, 159, 64, 1)'];
return $colors[$color];
}
}
\ No newline at end of file
......@@ -144,10 +144,6 @@ class Metric extends SimpleORMap
$result[] = date(self::BBB_DATETIME_FORMAT, strtotime('first day of this month 00:00:00'));
$result[] = date(self::BBB_DATETIME_FORMAT, strtotime('first day of next month 00:00:00'));
}
if ($filter === 'today') {
$result[] = date(self::BBB_DATETIME_FORMAT, strtotime('today 00:00:00'));
$result[] = date(self::BBB_DATETIME_FORMAT, strtotime('next day 00:00:00'));
}
if ($filter === 'current_week') {
$result[] = date(self::BBB_DATETIME_FORMAT, strtotime('monday this week 00:00:00'));
$result[] = date(self::BBB_DATETIME_FORMAT, strtotime('sunday this week 00:00:00'));
......@@ -156,7 +152,14 @@ class Metric extends SimpleORMap
$result[] = date(self::BBB_DATETIME_FORMAT, strtotime('monday last week 00:00:00'));
$result[] = date(self::BBB_DATETIME_FORMAT, strtotime('sunday last week 00:00:00'));
}
if ($filter === 'today') {
$result[] = date(self::BBB_DATETIME_FORMAT, strtotime('today 00:00:00'));
$result[] = date(self::BBB_DATETIME_FORMAT, strtotime('next day 00:00:00'));
}
if ($filter === 'yesterday') {
$result[] = date(self::BBB_DATETIME_FORMAT, strtotime('yesterday 00:00:00'));
$result[] = date(self::BBB_DATETIME_FORMAT, strtotime('today 00:00:00'));
}
return $result;
}
}
\ No newline at end of file
<section class="bbb-metrics">
<? if (!empty($current_month_complete)) : ?>
<? if (!empty($dataset)) : ?>
<section class="contentbox">
<header>
<h1><?= sprintf(_('Statistik für %s'), strftime('%B')) ?></h1>
......@@ -8,115 +8,9 @@
<canvas id="bar-chart" style="width: 100%; height: 400px"></canvas>
<script>
var ctx = document.getElementById('bar-chart').getContext('2d')
window.chartColors = {
redDark: 'rgba(255, 99, 132, 0.2)',
red: 'rgba(255, 99, 132, 1)',
blueDark: 'rgba(54, 162, 235, 0.2)',
blue: 'rgba(54, 162, 235, 1)',
yellowDark: 'rgba(255, 206, 86, 0.2)',
yellow: 'rgba(255, 206, 86, 1)',
greenDark: 'rgba(75, 192, 192, 0.2)',
green:'rgba(75, 192, 192, 1)',
purpleDark: 'rgba(153, 102, 255, 0.2)',
purple:'rgba(153, 102, 255, 1)',
brownDark:'rgba(255, 159, 64, 0.2)',
brown:'rgba(255, 159, 64, 1)'
};
var myChart = new Chart(ctx, {
type: 'bar',
data: {
labels: <?= $labels ?>,
datasets: [{
label: '# <?= strftime('%B')?>',
data: <?= $current_month_complete ?>,
backgroundColor: [
window.chartColors.redDark,
window.chartColors.redDark,
window.chartColors.redDark,
window.chartColors.redDark,
window.chartColors.redDark,
window.chartColors.redDark,
window.chartColors.redDark,
],
borderColor: [
window.chartColors.red,
window.chartColors.red,
window.chartColors.red,
window.chartColors.red,
window.chartColors.red,
window.chartColors.red,
window.chartColors.red,
],
borderWidth: 1
}, {
label: '# <?= _('Heute')?>',
data: <?= $today_complete ?>,
backgroundColor: [
window.chartColors.blueDark,
window.chartColors.blueDark,
window.chartColors.blueDark,
window.chartColors.blueDark,
window.chartColors.blueDark,
window.chartColors.blueDark,
window.chartColors.blueDark,
],
borderColor: [
window.chartColors.blue,
window.chartColors.blue,
window.chartColors.blue,
window.chartColors.blue,
window.chartColors.blue,
window.chartColors.blue,
window.chartColors.blue,
],
borderWidth: 1
}, {
label: '# <?= _('Diese Woche')?>',
data: <?= $current_week_complete ?>,
backgroundColor: [
window.chartColors.greenDark,
window.chartColors.greenDark,
window.chartColors.greenDark,
window.chartColors.greenDark,
window.chartColors.greenDark,
window.chartColors.greenDark,
window.chartColors.greenDark,
],
borderColor: [
window.chartColors.green,
window.chartColors.green,
window.chartColors.green,
window.chartColors.green,
window.chartColors.green,
window.chartColors.green,
window.chartColors.green,
],
borderWidth: 1
}, {
label: '# <?= _('Letzte Woche')?>',
data: <?= $last_week_complete ?>,
backgroundColor: [
window.chartColors.yellowDark,
window.chartColors.yellowDark,
window.chartColors.yellowDark,
window.chartColors.yellowDark,
window.chartColors.yellowDark,
window.chartColors.yellowDark,
window.chartColors.yellowDark,
],
borderColor: [
window.chartColors.yellow,
window.chartColors.yellow,
window.chartColors.yellow,
window.chartColors.yellow,
window.chartColors.yellow,
window.chartColors.yellow,
window.chartColors.yellow,
],
borderWidth: 1
}
]
},
data: <?= $dataset?>,
options: {
scales: {
yAxes: [{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment