From b57adb38a5ea4ad9f2af97de74e4605596dd6055 Mon Sep 17 00:00:00 2001 From: Daniel Maya Date: Mon, 6 May 2019 17:12:00 +0200 Subject: [PATCH] added graph_precision for the float in static_graph and percentile item Former-commit-id: 7fda14add9bcb0d9c0a425caad752364e29b309c --- .../rest-api/models/VisualConsole/Items/Percentile.php | 6 +----- .../rest-api/models/VisualConsole/Items/StaticGraph.php | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/pandora_console/include/rest-api/models/VisualConsole/Items/Percentile.php b/pandora_console/include/rest-api/models/VisualConsole/Items/Percentile.php index ebfb7e94b6..4d1af31e95 100644 --- a/pandora_console/include/rest-api/models/VisualConsole/Items/Percentile.php +++ b/pandora_console/include/rest-api/models/VisualConsole/Items/Percentile.php @@ -222,12 +222,8 @@ final class Percentile extends Item ); } - // Cast to float. - $moduleValue = (float) $moduleValue; - // Store the module value. - $data['value'] = $moduleValue; - + $data['value'] = (float) \number_format((float) $moduleValue, (int) $config['graph_precision'], '.', ''); $unit = \modules_get_unit($moduleId); if (empty($unit) === false) { $data['unit'] = \io_safe_output($unit); diff --git a/pandora_console/include/rest-api/models/VisualConsole/Items/StaticGraph.php b/pandora_console/include/rest-api/models/VisualConsole/Items/StaticGraph.php index f3bd1126b3..4aefbc492a 100644 --- a/pandora_console/include/rest-api/models/VisualConsole/Items/StaticGraph.php +++ b/pandora_console/include/rest-api/models/VisualConsole/Items/StaticGraph.php @@ -226,7 +226,7 @@ final class StaticGraph extends Item || ($isBooleanModule && $showLastValueTooltip !== 'default') ) { if (\is_numeric($value)) { - $imgTitle .= __('Last value: ').remove_right_zeros($value); + $imgTitle .= __('Last value: ').remove_right_zeros(number_format((float) $value, (int) $config['graph_precision'])); } else { $imgTitle .= __('Last value: ').$value; }