'; $str .= '
';
}
$str .= '
';
}
$str .= '';
return new HtmlString($str);
}
protected function getFilters(): ?array
{
return [
'gls' => 'Goals',
'crn' => 'Corner',
'fls' => 'Committed Fouls',
'ofs' => 'Offsides',
'crd' => 'Cards',
'snt' => 'Shots on target',
'tsh' => 'TotalShots',
];
}
protected function getData(): array
{
$activeFilter = $this->filter;
$res = StatistikoEvent::where('league_id', $this->record['competition_group_id'])
->where('home_id', $this->record['home_id'])
->where('away_id', $this->record['away_id'])
->get();
switch ($activeFilter) {
case 'crn':
$h = 'crn_h';
$a = 'crn_a';
break;
case 'fls':
$h = 'fls_h';
$a = 'fls_a';
break;
case 'ofs':
$h = 'ofs_h';
$a = 'ofs_a';
break;
case 'crd':
$h = 'crd_h';
$a = 'crd_a';
break;
case 'snt':
$h = 'snt_h';
$a = 'snt_a';
break;
case 'tsh':
$h = 'tsh_h';
$a = 'tsh_a';
break;
default:
$h = 'gls_h';
$a = 'gls_a';
break;
}
$starttimes = [];
$data_home = [];
$data_away = [];
foreach ($res as $event) {
$data_home[] = $event[$h];
$data_away[] = $event[$a];
$starttimes[] = $event['starttime']->format('d.m.Y');
}
return [
'datasets' => [
[
'label' => $this->record->home->name,
'data' => $data_home,
'backgroundColor' => '#155dfc',
'borderColor' => '#2b7fff',
],
[
'label' => $this->record->away->name,
'data' => $data_away,
'backgroundColor' => '#00a63e',
'borderColor' => '#00c950',
],
],
'labels' => $starttimes,
'scales' => $this->getOptions(),
];
}
protected function getOptions(): array
{
return [
'scales' => [
'y' => [
'ticks' => [
'precision' => 0, // Forces integers
'beginAtZero' => true,
],
],
],
];
}
protected function getType(): string
{
return 'line';
}
}