increase type of output graphs.

This commit is contained in:
2021-10-28 14:42:00 +09:00
parent 3674880f07
commit d79f1aa172
2 changed files with 17 additions and 7 deletions

View File

@ -135,21 +135,22 @@ class Temperature
* output graph.
*
* @param string $type output graph type
* @param int $num output period of graph type
* @param string $fpath output image file path
*
* @return bool false if failure
*/
public function outputGraph(string $type, string $fpath): bool
public function outputGraph(string $type, int $num, string $fpath): bool
{
static $colors = [
'#FF0000', '#00FF00', '#0000FF', '#FFFF00', '#00FFFF', '#FF00FF',
'#FF9999', '#99FF99', '#9999FF', '#FFFF99', '#99FFFF', '#FF99FF',
];
static $types = ['hour', 'day', 'week', 'month', 'year', '3year'];
static $types = ['hour', 'day', 'week', 'month', 'year'];
if (!in_array($type, $types)) {
return false;
}
$start = '3year' == $type ? '-3year' : '-1'.$type;
$start = sprintf('-%u%s', $num, $type);
$options = [
'--imgformat', 'PNG',
'--lower-limit', '10',
@ -160,7 +161,7 @@ class Temperature
'--height', '200',
'--units-exponent', '0',
'--vertical-label', "Temperature [\xc2\xb0C]",
'--title', 'Server Room Temperature - by '.$type,
'--title', 'Server Room Temperature - by '.$num.$type.'(s)',
];
$idlen = 0;
foreach ($this->sensorIds as $key => $id) {