Commit f84b7023616bc3cbcc7b145fc87358ec8f2caa75
1 parent
18a4a61b
Exists in
master
and in
18 other branches
Prevent exception when X parameter not defined for a histogram 2D
Showing
2 changed files
with
15 additions
and
10 deletions
Show diff stats
src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php
... | ... | @@ -713,14 +713,18 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass |
713 | 713 | $histogram2DNodes = array(); |
714 | 714 | if (count($indexes) == 0) { |
715 | 715 | $histogram2DNode = $paramNode->addHistogram2DSerie($paramData->{'param-drawing-object'}->{'serie-yaxis'}, -1, $xId); |
716 | - $histogram2DNode->setId($paramData->{'id'}); | |
717 | - $histogram2DNodes[] = $histogram2DNode; | |
716 | + if (isset($histogram2DNode)) { | |
717 | + $histogram2DNode->setId($paramData->{'id'}); | |
718 | + $histogram2DNodes[] = $histogram2DNode; | |
719 | + } | |
718 | 720 | } |
719 | 721 | foreach ($indexes as $index) { |
720 | 722 | $histogram2DNode = $paramNode->addHistogram2DSerie($paramData->{'param-drawing-object'}->{'serie-yaxis'}, $index, $xId); |
721 | - if (count($indexes) == 1) | |
722 | - $histogram2DNode->setId($paramData->{'id'}); | |
723 | - $histogram2DNodes[] = $histogram2DNode; | |
723 | + if (isset($histogram2DNode)) { | |
724 | + if (count($indexes) == 1) | |
725 | + $histogram2DNode->setId($paramData->{'id'}); | |
726 | + $histogram2DNodes[] = $histogram2DNode; | |
727 | + } | |
724 | 728 | } |
725 | 729 | |
726 | 730 | // ranges |
... | ... |
src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotParamsNodeClass.php
... | ... | @@ -102,11 +102,12 @@ class RequestOutputPlotParamNodeClass extends NodeClass |
102 | 102 | |
103 | 103 | public function addHistogram2DSerie($yAxis, $index, $xId = -1) |
104 | 104 | { |
105 | - if ($xId != -1) { | |
106 | - $histogram2dNode = new RequestOutputPlotHistogram2DSerieNodeClass(REQUESTOUTPUTPLOTHISTOGRAM2DSERIE_NAME); | |
107 | - $histogram2dNode->setXId($xId); | |
108 | - $histogram2dNode->setXAxisId(REQUESTOUTPUTPLOTELEMENTXY_XAXISID); | |
109 | - } | |
105 | + if ($xId == -1) { | |
106 | + return NULL; | |
107 | + } | |
108 | + $histogram2dNode = new RequestOutputPlotHistogram2DSerieNodeClass(REQUESTOUTPUTPLOTHISTOGRAM2DSERIE_NAME); | |
109 | + $histogram2dNode->setXId($xId); | |
110 | + $histogram2dNode->setXAxisId(REQUESTOUTPUTPLOTELEMENTXY_XAXISID); | |
110 | 111 | $histogram2dNode->setYAxisId($yAxis); |
111 | 112 | if ($index >= 0) |
112 | 113 | $histogram2dNode->setIndex($index); |
... | ... |