本文整理汇总了PHP中app\models\Task::getTaskBetweenDate方法的典型用法代码示例。如果您正苦于以下问题:PHP Task::getTaskBetweenDate方法的具体用法?PHP Task::getTaskBetweenDate怎么用?PHP Task::getTaskBetweenDate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类app\models\Task
的用法示例。
在下文中一共展示了Task::getTaskBetweenDate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getChartData
public function getChartData()
{
/*echo('getChartDateFromTo<pre>');
print_r($this->getChartDateFromTo());
echo('</pre>');
echo('$this->device_id: ' . $this->device_id) . '<br/>' . PHP_EOL;
echo('$this->action_id: ' . $this->action_id) . '<br/>' . PHP_EOL;
echo('$this->getChartIntervalGroupBy(): ' . $this->getChartIntervalGroupBy()) . '<br/>' . PHP_EOL;*/
/*$tasks = Task::find()
->select([
'id',
'from_device_id',
'to_device_id',
'action_id',
'data',
'created_at',
"SUBSTRING_INDEX(data, ';', 1) AS temp",
"SUBSTRING_INDEX(SUBSTRING_INDEX(data, ';', 2), ';', -1) AS hum",
"AVG(SUBSTRING_INDEX(data, ';', 1)) AS avgTemp",
"AVG(SUBSTRING_INDEX(SUBSTRING_INDEX(data, ';', 2), ';', -1)) AS avgHum",
])
->where([
'from_device_id' => '1',
'to_device_id' => $this->device_id,
'action_id' => $this->action_id,
])
->andwhere(['between', 'created_at', $this->getChartDateFromTo()['from'], $this->getChartDateFromTo()['to']])
->groupBy($this->getChartIntervalGroupBy())
->orderBy('created_at')
->asArray()
->all();*/
$taskmodel = new Task();
$devicemodel = new Device();
$tasks = $taskmodel->getTaskBetweenDate($this->getChartDateFromTo(), $devicemodel->getDeviceMaster()[0]['id'], $this->device_id, $this->action_id);
/*echo('$tasks: <pre>');
print_r($tasks);
echo('</pre>');*/
//echo('date(Y-m-d 00:00:00);: ' . date('Y-m-d')) . '<br/>' . PHP_EOL;
/*echo('$this->getChartDateFromTo():<pre>');
print_r($this->getChartDateFromTo());
echo('</pre>');*/
//SUBSTRING_INDEX(`data`, `;`, 1) as temp)
/*echo('$tasks<pre>');
print_r($tasks);
echo('</pre>');*/
/*
* chart: {
type: 'line'
},
title: {
text: 'Fruit Consumption'
},
xAxis: {
categories: ['Apples', 'Bananas', 'Oranges']
},
yAxis: {
title: {
text: 'Fruit eaten'
}
},
series: [{
name: 'Jane',
data: [1, 0, 4]
}, {
name: 'John',
data: [5, 7, 3]
}]
*/
$chart = ['chart' => ['type' => $this->chart_type], 'title' => ['text' => 'Temperature / Humidity ' . $this->getChartDate()[$this->chart_date]]];
$xAxis = [];
$yAxis = [['title' => ['text' => 'Temperature'], 'labels' => ['format' => '{value}']], ['title' => ['text' => 'Humidity'], 'labels' => ['format' => '{value}'], 'opposite' => true]];
/*echo('$yAxis<pre>');
print_r($yAxis);
echo('</pre>');*/
$series = [];
//$series[] = ['name' => 'Temperature', 'data' => []];
//$series[] = ['name' => 'Humidity', 'data' => []];
$series = [['yAxis' => 0, 'name' => 'Temperature', 'data' => array()], ['yAxis' => 1, 'name' => 'Humidity', 'data' => array()]];
foreach ($tasks as $key => $task) {
$xAxis['categories'][] = date('H', strtotime($task['created_at']));
//$series[0]['data'][] = $task['avgTemp'];
$series[0]['data'][] = number_format((double) $task['data']['t'], 2, '.', '');
//$series[1]['data'][] = $task['avgHum'];
$series[1]['data'][] = number_format((double) $task['data']['h'], 2, '.', '');
}
// create from the data a string (for highcharts to read the values good, its a javascript thing)
//$series[0]['data'] = '[' . implode(',', $series[0]['data']) . ']';
//$series[1]['data'] = '[' . implode(',', $series[1]['data']) . ']';
/*echo('$xAxis<pre>');
print_r($xAxis);
echo('</pre>');*/
/*echo('$series<pre>');
print_r($series);
echo('</pre>');*/
/*$options = array_merge($chart, array('xAxis' => $xAxis), array('yAxis' => $yAxis), array('series' => $series));
echo('$options<pre>');
print_r($options);
echo('</pre>');*/
return [$chart, $xAxis, $yAxis, $series];
}