Commit f84b7023616bc3cbcc7b145fc87358ec8f2caa75

Authored by Benjamin Renard
1 parent 18a4a61b

Prevent exception when X parameter not defined for a histogram 2D

src/InputOutput/IHMImpl/Params/PlotImpl/IHMInputOutputParamsPlotClass.php
@@ -713,14 +713,18 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass @@ -713,14 +713,18 @@ class IHMInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass
713 $histogram2DNodes = array(); 713 $histogram2DNodes = array();
714 if (count($indexes) == 0) { 714 if (count($indexes) == 0) {
715 $histogram2DNode = $paramNode->addHistogram2DSerie($paramData->{'param-drawing-object'}->{'serie-yaxis'}, -1, $xId); 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 foreach ($indexes as $index) { 721 foreach ($indexes as $index) {
720 $histogram2DNode = $paramNode->addHistogram2DSerie($paramData->{'param-drawing-object'}->{'serie-yaxis'}, $index, $xId); 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 // ranges 730 // ranges
src/Request/ParamsRequestImpl/Nodes/Requests/RequestOutputPlotParamsNodeClass.php
@@ -102,11 +102,12 @@ class RequestOutputPlotParamNodeClass extends NodeClass @@ -102,11 +102,12 @@ class RequestOutputPlotParamNodeClass extends NodeClass
102 102
103 public function addHistogram2DSerie($yAxis, $index, $xId = -1) 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 $histogram2dNode->setYAxisId($yAxis); 111 $histogram2dNode->setYAxisId($yAxis);
111 if ($index >= 0) 112 if ($index >= 0)
112 $histogram2dNode->setIndex($index); 113 $histogram2dNode->setIndex($index);