From f31b916230cc857f7aca9ecd2b68d0492e165757 Mon Sep 17 00:00:00 2001 From: Simon Vieille Date: Sun, 17 Jan 2021 18:58:55 +0100 Subject: [PATCH] add xtics --- .gitmodules | 3 --- src/Command/ChartHygrometryCommand.php | 8 +++++++- src/Command/ChartTemperatureCommand.php | 8 +++++++- 3 files changed, 14 insertions(+), 5 deletions(-) delete mode 100644 .gitmodules diff --git a/.gitmodules b/.gitmodules deleted file mode 100644 index 726443c..0000000 --- a/.gitmodules +++ /dev/null @@ -1,3 +0,0 @@ -[submodule "lib/eplot"] - path = lib/eplot - url = https://github.com/chriswolfvision/eplot diff --git a/src/Command/ChartHygrometryCommand.php b/src/Command/ChartHygrometryCommand.php index ab50afb..83fff5f 100644 --- a/src/Command/ChartHygrometryCommand.php +++ b/src/Command/ChartHygrometryCommand.php @@ -50,13 +50,17 @@ class ChartHygrometryCommand extends ContainerAwareCommand $table->setHeaders(['ID', 'Date', 'Value']); $max = (int) $this->params->get('hygrometry_trigger_max'); - $stats = ['Value,Max']; + $xtics = []; foreach ($entities as $i => $entity) { $stats1[] = $entity->getvalue(); $stats2[] = $max; + if ($i % 5 === 0) { + $xtics[] = sprintf('"%s" %d', $entity->getDate()->format('H:i'), $i); + } + $table->addRow([ $i, $entity->getDate()->format('d/m/Y H:i'), @@ -73,6 +77,8 @@ class ChartHygrometryCommand extends ContainerAwareCommand $process = new Process([ './lib/eplot/eplot', '-d', + '--xtics', + sprintf('(%s)', implode(', ', $xtics)), '-t', 'Max@Hygrometry', '-m', diff --git a/src/Command/ChartTemperatureCommand.php b/src/Command/ChartTemperatureCommand.php index a834270..b339b34 100644 --- a/src/Command/ChartTemperatureCommand.php +++ b/src/Command/ChartTemperatureCommand.php @@ -51,14 +51,18 @@ class ChartTemperatureCommand extends ContainerAwareCommand $perfect = (int) $this->params->get('temperature_trigger_max'); $min = (int) $this->params->get('temperature_trigger_min'); - $stats = ['Value,Perfect,Min']; + $xtics = []; foreach ($entities as $i => $entity) { $stats1[] = $entity->getvalue(); $stats2[] = (float) 27; $stats3[] = (float) $min; + if ($i % 5 === 0) { + $xtics[] = sprintf('"%s" %d', $entity->getDate()->format('H:i'), $i); + } + $table->addRow([ $i, $entity->getDate()->format('d/m/Y H:i'), @@ -77,6 +81,8 @@ class ChartTemperatureCommand extends ContainerAwareCommand $process = new Process([ './lib/eplot/eplot', '-d', + '--xtics', + sprintf('(%s)', implode(', ', $xtics)), '-r', '[0:45][10:35]', '-t',