wip order classes
This commit is contained in:
1 parent
fe4fa6e9cf
commit
7bf4258c4a
29 files changed
+140
-124
No files matched your search
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Widgets\Charts;
|
||||
|
||||
class HelperMoveingAverage
|
||||
{
|
||||
public static function get(&$data)
|
||||
{
|
||||
if (! $data) {
|
||||
return;
|
||||
}
|
||||
|
||||
$data['labels'] = array_slice($data['labels'], 2);
|
||||
|
||||
$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(((float) $arr[0] + (float) $value + (float) $arr[2]) / 3, 1);
|
||||
} elseif ($key > 1 && $key < $last - 1) {
|
||||
$new[] = round(((float) $arr[$key - 1] + (float) $value + (float) $arr[$key + 1]) / 3, 1);
|
||||
}
|
||||
}
|
||||
$data['datasets'][$k]['data'] = $new;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user