Commit a44cf065ac4af25b2292ccfcd0b9741bfb8554e4
1 parent
0904976e
Exists in
master
and in
45 other branches
Add indexes support for getPlot API (#9183)
Showing
2 changed files
with
29 additions
and
9 deletions
Show diff stats
src/InputOutput/IHMImpl/Tools/IHMParamTemplateClass.php
@@ -292,8 +292,14 @@ class IHMParamTemplateClass | @@ -292,8 +292,14 @@ class IHMParamTemplateClass | ||
292 | if (empty($arguments)) | 292 | if (empty($arguments)) |
293 | return; | 293 | return; |
294 | foreach ($arguments as $arg_key => $arg_def) { | 294 | foreach ($arguments as $arg_key => $arg_def) { |
295 | - if (!array_key_exists($arg_key, $template_args)) | ||
296 | - $template_args->{$arg_key} = $arg_def['default']; | 295 | + if (!array_key_exists($arg_key, $template_args)) { |
296 | + if (is_array($template_args)) { | ||
297 | + $template_args[$arg_key] = $arg_def['default']; | ||
298 | + } | ||
299 | + else { | ||
300 | + $template_args->{$arg_key} = $arg_def['default']; | ||
301 | + } | ||
302 | + } | ||
297 | } | 303 | } |
298 | } | 304 | } |
299 | 305 |
src/InputOutput/WSImpl/Params/PlotImpl/WSInputOutputParamsPlotClass.php
@@ -130,14 +130,28 @@ class WSInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass | @@ -130,14 +130,28 @@ class WSInputOutputParamsPlotClass extends IHMInputOutputParamsAbstractClass | ||
130 | 130 | ||
131 | $requestParamsNode->addParam($paramInfo['id']); | 131 | $requestParamsNode->addParam($paramInfo['id']); |
132 | $paramNode = $plotNode->getParams()->getParamById($paramInfo['id']); | 132 | $paramNode = $plotNode->getParams()->getParamById($paramInfo['id']); |
133 | + | ||
134 | + $activateLegends = FALSE; | ||
135 | + if (empty($paramInfo['indexes'])) { | ||
136 | + $paramInfo['indexes'] = array(-1); | ||
137 | + if ($this->isVector($paramInfo['id'])) { | ||
138 | + $activateLegends = TRUE; | ||
139 | + } | ||
140 | + } | ||
141 | + else if (count($paramInfo['indexes']) > 1) { | ||
142 | + $activateLegends = TRUE; | ||
143 | + } | ||
144 | + | ||
145 | + $serieId = 1; | ||
146 | + foreach ($paramInfo['indexes'] as $index) { | ||
147 | + $serieNode = $paramNode->addYSerie('y-left', $index); | ||
148 | + $serieNode->setId($serieId); | ||
149 | + $lineNode = $serieNode->getLine(); | ||
150 | + $lineNode->setType(RequestOutputPlotLineTypeEnum::LINE); | ||
151 | + ++$serieId; | ||
152 | + } | ||
133 | 153 | ||
134 | - $serieNode = $paramNode->addYSerie('y-left', -1); | ||
135 | - $serieNode->setId('1'); | ||
136 | - | ||
137 | - $lineNode = $serieNode->getLine(); | ||
138 | - $lineNode->setType(RequestOutputPlotLineTypeEnum::LINE); | ||
139 | - | ||
140 | - if ($this->isVector($paramInfo['id'])) { // vector - activate legend | 154 | + if ($activateLegends) { // vector - activate legend |
141 | $paramLegendNode = $plotNode->getLegends()->getParamsLegend(); | 155 | $paramLegendNode = $plotNode->getLegends()->getParamsLegend(); |
142 | $paramLegendNode->setType(RequestOutputPlotParamsLegendTypeEnum::TEXTONLY); | 156 | $paramLegendNode->setType(RequestOutputPlotParamsLegendTypeEnum::TEXTONLY); |
143 | $paramLegendNode->setShowParamInfo("true"); | 157 | $paramLegendNode->setShowParamInfo("true"); |