Detail chart
This commit is contained in:
parent
e39b6655e3
commit
3047ead205
@ -59,10 +59,11 @@ class WidgetApi extends ApiController{
|
|||||||
$labels = [];
|
$labels = [];
|
||||||
$values = [];
|
$values = [];
|
||||||
foreach ($events as $key => $event) {
|
foreach ($events as $key => $event) {
|
||||||
$labels[] = (new DateTime($event['time']))->format('H:i');
|
$recordDatetime = new DateTime($event['time']);
|
||||||
|
$labels[] = $recordDatetime->format('H:i');
|
||||||
$values[] = [
|
$values[] = [
|
||||||
$event['time'],
|
'y' => $event['value'],
|
||||||
$event['value'],
|
't' => $recordDatetime->getTimestamp()*1000,
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,11 +71,31 @@ class WidgetApi extends ApiController{
|
|||||||
'records'=> $events,
|
'records'=> $events,
|
||||||
'graph'=> [
|
'graph'=> [
|
||||||
'labels' => $labels,
|
'labels' => $labels,
|
||||||
'values' => $values,
|
'data' => [
|
||||||
|
'dataset' => $values
|
||||||
|
],
|
||||||
|
'scales' => [
|
||||||
|
'xAxis' => [
|
||||||
|
'type' => 'time',
|
||||||
|
'distribution' => 'linear',
|
||||||
|
],
|
||||||
|
'yAxes' => [
|
||||||
|
'ticks' => [
|
||||||
'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'],
|
'steps' => RANGES[$subDeviceData['type']]['scale'],
|
||||||
'graph' => RANGES[$subDeviceData['type']]['graph'],
|
]
|
||||||
|
]
|
||||||
|
],
|
||||||
|
'legend' => [
|
||||||
|
'display' => false
|
||||||
|
],
|
||||||
|
'tooltips' => [
|
||||||
|
'enabled' => true
|
||||||
|
],
|
||||||
|
'hover' => [
|
||||||
|
'mode' => true
|
||||||
|
],
|
||||||
],
|
],
|
||||||
'comError' => $connectionError,
|
'comError' => $connectionError,
|
||||||
'lastConnectionTime' => (empty($niceTime) ? "00:00" : $niceTime),
|
'lastConnectionTime' => (empty($niceTime) ? "00:00" : $niceTime),
|
||||||
|
Loading…
Reference in New Issue
Block a user