Aditional changes

This commit is contained in:
JonatanRek 2020-10-05 21:32:23 +02:00
parent e3b7e866f0
commit b5d7904a61

View File

@ -59,15 +59,18 @@ class WidgetApi extends ApiController{
$labels = []; $labels = [];
$values = []; $values = [];
foreach ($events as $key => $event) { foreach ($events as $key => $event) {
$labels[] = $event['value']; $labels[] = (new DateTime($event['time']))->format('H:i');
$values[] = $event['time']; $values[] = [
$event['time'],
$event['value'],
];
} }
$response = [ $response = [
'records'=> $events, 'records'=> $events,
'graph'=> [ 'graph'=> [
'labels' => $values, 'labels' => $labels,
'values' => $labels, 'values' => $values,
'min' => RANGES[$subDeviceData['type']]['min'], 'min' => RANGES[$subDeviceData['type']]['min'],
'max' => RANGES[$subDeviceData['type']]['max'], 'max' => RANGES[$subDeviceData['type']]['max'],
'scale' => RANGES[$subDeviceData['type']]['scale'], 'scale' => RANGES[$subDeviceData['type']]['scale'],