From f84b7023616bc3cbcc7b145fc87358ec8f2caa75 Mon Sep 17 00:00:00 2001 From: Benjamin Renard <benjamin.renard@akka.eu> Date: Fri, 10 Feb 2023 09:09:40 +0000 Subject: [PATCH] Prevent exception when X parameter not defined for a histogram 2D --- src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php | 14 +++++++++----- src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotParamsNodeClass.php | 11 ++++++----- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php b/src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php index 9288181..9f133fd 100644 --- a/src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php +++ b/src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php @@ -713,14 +713,18 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass $histogram2DNodes = array(); if (count($indexes) == 0) { $histogram2DNode = $paramNode->addHistogram2DSerie($paramData->{'param-drawing-object'}->{'serie-yaxis'}, -1, $xId); - $histogram2DNode->setId($paramData->{'id'}); - $histogram2DNodes[] = $histogram2DNode; + if (isset($histogram2DNode)) { + $histogram2DNode->setId($paramData->{'id'}); + $histogram2DNodes[] = $histogram2DNode; + } } foreach ($indexes as $index) { $histogram2DNode = $paramNode->addHistogram2DSerie($paramData->{'param-drawing-object'}->{'serie-yaxis'}, $index, $xId); - if (count($indexes) == 1) - $histogram2DNode->setId($paramData->{'id'}); - $histogram2DNodes[] = $histogram2DNode; + if (isset($histogram2DNode)) { + if (count($indexes) == 1) + $histogram2DNode->setId($paramData->{'id'}); + $histogram2DNodes[] = $histogram2DNode; + } } // ranges diff --git a/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotParamsNodeClass.php b/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotParamsNodeClass.php index a1b7b0e..2e24b69 100644 --- a/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotParamsNodeClass.php +++ b/src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotParamsNodeClass.php @@ -102,11 +102,12 @@ class RequestOutputPlotParamNodeClass extends NodeClass public function addHistogram2DSerie($yAxis, $index, $xId = -1) { - if ($xId != -1) { - $histogram2dNode = new RequestOutputPlotHistogram2DSerieNodeClass(REQUESTOUTPUTPLOTHISTOGRAM2DSERIE_NAME); - $histogram2dNode->setXId($xId); - $histogram2dNode->setXAxisId(REQUESTOUTPUTPLOTELEMENTXY_XAXISID); - } + if ($xId == -1) { + return NULL; + } + $histogram2dNode = new RequestOutputPlotHistogram2DSerieNodeClass(REQUESTOUTPUTPLOTHISTOGRAM2DSERIE_NAME); + $histogram2dNode->setXId($xId); + $histogram2dNode->setXAxisId(REQUESTOUTPUTPLOTELEMENTXY_XAXISID); $histogram2dNode->setYAxisId($yAxis); if ($index >= 0) $histogram2dNode->setIndex($index); -- libgit2 0.21.2