diff --git a/pandora_console/include/graphs/flot/pandora.flot.js b/pandora_console/include/graphs/flot/pandora.flot.js index 38b7f75f1c..f7af997508 100644 --- a/pandora_console/include/graphs/flot/pandora.flot.js +++ b/pandora_console/include/graphs/flot/pandora.flot.js @@ -869,7 +869,7 @@ function pandoraFlotSlicebar( var datas = new Array(); - for (i = 0; i < values.length; i++) { + for (var i = 0; i < values.length; i++) { var serie = values[i].split(separator); var aux = new Array(); @@ -1938,6 +1938,8 @@ function pandoraFlotArea( switch (type) { case "line": case 2: + stacked = null; + filled_s = false; break; case 3: stacked = "stack"; diff --git a/pandora_console/include/graphs/functions_flot.php b/pandora_console/include/graphs/functions_flot.php index 4492da7834..8e32673b48 100644 --- a/pandora_console/include/graphs/functions_flot.php +++ b/pandora_console/include/graphs/functions_flot.php @@ -279,6 +279,12 @@ function flot_area_graph( // Trick to get translated string from javascript. $return .= html_print_input_hidden('unknown_text', __('Unknown'), true); + // To use the js document ready event or not. Default true. + $document_ready = true; + if (isset($params['document_ready']) === true) { + $document_ready = $params['document_ready']; + } + $values = json_encode($array_data); $legend = json_encode($legend); @@ -295,9 +301,28 @@ function flot_area_graph( } $return .= "'; // Parent layer. @@ -428,11 +453,9 @@ function flot_pie_chart( include_javascript_dependencies_flot_graph(); $return .= "'; return $return; @@ -508,11 +531,9 @@ function flot_custom_pie_chart( $colors = implode($separator, $temp_colors); $return .= "'; return $return; @@ -608,10 +629,8 @@ function flot_hcolumn_chart($graph_data, $width, $height, $water_mark, $font='', // Javascript code $return .= "'; return $return; @@ -701,7 +720,6 @@ function flot_vcolumn_chart($graph_data, $width, $height, $color, $legend, $long // Javascript code $return .= "'; return $return; @@ -887,9 +904,7 @@ function flot_slicesbar_graph( // Javascript code $return .= "'; diff --git a/pandora_console/include/rest-api/models/VisualConsole/Items/ModuleGraph.php b/pandora_console/include/rest-api/models/VisualConsole/Items/ModuleGraph.php index a9c16d0866..a804e29b02 100644 --- a/pandora_console/include/rest-api/models/VisualConsole/Items/ModuleGraph.php +++ b/pandora_console/include/rest-api/models/VisualConsole/Items/ModuleGraph.php @@ -211,13 +211,14 @@ final class ModuleGraph extends Item $params = [ 'period' => $period, - 'width' => $data['width'], + 'width' => (int) $data['width'], 'height' => ($data['height'] - 30), 'title' => '', 'unit_name' => null, 'show_alerts' => false, 'only_image' => $imageOnly, 'vconsole' => true, + 'document_ready' => false, 'backgroundColor' => $backgroundType, ]; @@ -244,7 +245,7 @@ final class ModuleGraph extends Item 'agent_module_id' => $moduleId, 'period' => $period, 'show_events' => false, - 'width' => $data['width'], + 'width' => (int) $data['width'], 'height' => ($data['height'] - 30), 'title' => \modules_get_agentmodule_name($moduleId), 'unit' => \modules_get_unit($moduleId), @@ -253,6 +254,7 @@ final class ModuleGraph extends Item 'backgroundColor' => $backgroundType, 'type_graph' => $graphType, 'vconsole' => true, + 'document_ready' => false, ]; $data['html'] = \grafico_modulo_sparse($params); diff --git a/visual_console_client/src/items/ModuleGraph.ts b/visual_console_client/src/items/ModuleGraph.ts index ce23785d36..aee1469b21 100644 --- a/visual_console_client/src/items/ModuleGraph.ts +++ b/visual_console_client/src/items/ModuleGraph.ts @@ -106,9 +106,7 @@ export default class ModuleGraph extends Item { } // Hack to execute the JS after the HTML is added to the DOM. - const aux = document.createElement("div"); - aux.innerHTML = this.props.html; - const scripts = aux.getElementsByTagName("script"); + const scripts = element.getElementsByTagName("script"); for (let i = 0; i < scripts.length; i++) { if (scripts[i].src.length === 0) { eval(scripts[i].innerHTML.trim());