add home and away to graphic
This commit is contained in:
1 parent
3bc956e0b9
commit
06dbeb1ed8
4 files changed
+87
-46
No files matched your search
@@ -7,20 +7,23 @@ class HelperMoveingAverage
|
||||
public static function get(&$data)
|
||||
{
|
||||
|
||||
$arr = $data['datasets'][0]['data'];
|
||||
// $arr = $data['datasets'][0]['data'];#
|
||||
|
||||
$data['labels'] = array_slice($data['labels'], 2);
|
||||
|
||||
$new = [];
|
||||
$last = count($arr);
|
||||
foreach ($arr as $key => $value) {
|
||||
if ($key == 1 && $last > 2) {
|
||||
$new[] = round(($arr[0] + $value + $arr[2]) / 3, 1);
|
||||
} elseif ($key > 1 && $key < $last - 1) {
|
||||
$new[] = round(($arr[$key - 1] + $value + $arr[$key + 1]) / 3, 1);
|
||||
$datasets = $data['datasets'];
|
||||
foreach ($datasets as $k => $dataset) {
|
||||
$arr = $dataset['data'];
|
||||
$new = [];
|
||||
$last = count($arr);
|
||||
foreach ($arr as $key => $value) {
|
||||
if ($key == 1 && $last > 2) {
|
||||
$new[] = round(($arr[0] + $value + $arr[2]) / 3, 1);
|
||||
} elseif ($key > 1 && $key < $last - 1) {
|
||||
$new[] = round(($arr[$key - 1] + $value + $arr[$key + 1]) / 3, 1);
|
||||
}
|
||||
}
|
||||
$data['datasets'][$k]['data'] = $new;
|
||||
}
|
||||
$data['datasets'][0]['borderColor'] = '#00a63e';
|
||||
$data['datasets'][0]['data'] = $new;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user