shorten emty events at the end
This commit is contained in:
1 parent
23022a7266
commit
57c695c247
1 file changed
+32
@@ -361,6 +361,8 @@ class LoadEvents
|
|||||||
$label2 = 'Against';
|
$label2 = 'Against';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
self::shortenEnding($labels, $dataset_home, $dataset_away);
|
||||||
|
|
||||||
$data = [
|
$data = [
|
||||||
'datasets' => [
|
'datasets' => [
|
||||||
[
|
[
|
||||||
@@ -406,4 +408,34 @@ class LoadEvents
|
|||||||
|
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static function shortenEnding(array &$labels, array &$homes, array &$aways)
|
||||||
|
{
|
||||||
|
if (! isset($homes['all'])) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$count_home = 0;
|
||||||
|
$count_away = 0;
|
||||||
|
for ($i = \count($homes) - 1; $i > 0; $i--) {
|
||||||
|
if ($homes[$i] == null) {
|
||||||
|
$count_home++;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for ($i = \count($aways) - 1; $i > 0; $i--) {
|
||||||
|
if ($aways[$i] == null) {
|
||||||
|
$count_away++;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$keeps = count($homes['all']) - min($count_home, $count_away) - 1;
|
||||||
|
|
||||||
|
$homes = array_slice($homes, 0, $keeps);
|
||||||
|
$aways = array_slice($aways, 0, $keeps);
|
||||||
|
$labels = array_slice($labels, 0, $keeps);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user