diff --git a/pandora_console/include/graphs/functions_pchart.php b/pandora_console/include/graphs/functions_pchart.php index d33ad21878..f5368ca4c5 100644 --- a/pandora_console/include/graphs/functions_pchart.php +++ b/pandora_console/include/graphs/functions_pchart.php @@ -859,7 +859,7 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height, $MyData->addPoints($index,"Xaxis"); $MyData->setSerieDescription("Xaxis", $xaxisname); $MyData->setAbscissa("Xaxis"); - $MyData->setAxisDisplay(0, AXIS_FORMAT_METRIC); + $MyData->setAxisDisplay(0, AXIS_FORMAT_TWO_SIGNIFICANT, 0); switch ($backgroundColor) { case 'white': @@ -971,42 +971,17 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height, $max_data = max($v); } } - - - $default_chart_size = 40; - $rest_chars = strlen($max_data) - 6; - $default_chart_size += $rest_chars * 5; - + $chart_margin = 36; /* Area depends on yaxisname */ if ($yaxisname != '') { - $chart_size += $default_chart_size; - } - else { - $chart_size = $default_chart_size; + $chart_margin += $chart_size; } - $myPicture->setGraphArea($chart_size, $top_margin, + $myPicture->setGraphArea($chart_margin, $top_margin, $width, ($height - $margin_bottom)); - /*Get minimun value to draw axis properly*/ - - $ManualScale = array(); - $mode = SCALE_MODE_START0; - if ($min_data < 0) { - $mode = SCALE_MODE_FLOATING; - } - - if ($max_data < 0) { - $ManualScale = array(0 => array("Min" => $min_data, "Max" => 0)); - $mode = SCALE_MODE_MANUAL; - } - else if ($max_data >= 0 && $min_data <= 0){ - $ManualScale = array(0 => array("Min" => $min_data, "Max" => $max_data)); - $mode = SCALE_MODE_MANUAL; - } - if($graph_threshold){ $sql_treshold = 'select min_critical, max_critical, min_warning, max_warning, critical_inverse, warning_inverse from tagente_modulo where id_agente_modulo =' . $id_module; $treshold_position = db_get_all_rows_sql($sql_treshold); @@ -1218,6 +1193,14 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height, } else{ + + $ManualScale = array( 0 => array( + "Min" => $min_data, + "Max" => $max_data + )); + //html_debug("MAX: $max_data, ROUND: $max_round", true); + $mode = SCALE_MODE_MANUAL; + /* Draw the scale */ $scaleSettings = array( "GridR" => 200, diff --git a/pandora_console/include/graphs/pChart/pData.class.php b/pandora_console/include/graphs/pChart/pData.class.php index 6fcf4557b1..5cbb22b395 100755 --- a/pandora_console/include/graphs/pChart/pData.class.php +++ b/pandora_console/include/graphs/pChart/pData.class.php @@ -19,6 +19,7 @@ define("AXIS_FORMAT_DATE" , 680003); define("AXIS_FORMAT_METRIC" , 680004); define("AXIS_FORMAT_CURRENCY" , 680005); + define("AXIS_FORMAT_TWO_SIGNIFICANT" , 680006); // ARTICA-PANDORA HACK /* Axis position */ define("AXIS_POSITION_LEFT" , 681001); diff --git a/pandora_console/include/graphs/pChart/pDraw.class.php b/pandora_console/include/graphs/pChart/pDraw.class.php index 786b00756f..f1dfe780d5 100755 --- a/pandora_console/include/graphs/pChart/pDraw.class.php +++ b/pandora_console/include/graphs/pChart/pDraw.class.php @@ -2801,6 +2801,22 @@ return(round($Value/1000,$Format)."K".$Unit); } + // ARTICA-PANDORA HACK BEGIN + if ( $Mode == AXIS_FORMAT_TWO_SIGNIFICANT ) + { + // Display only two significant numbers + if ($Value != 0) { + $multiplier = floor(log(abs($Value), 10)) - 1; + $Value = round($Value/pow(10, $multiplier), 0) * pow(10, $multiplier); + } + if (abs($Value) >= 1000000000) + return(round($Value/1000000000,$Format)."G".$Unit); + if (abs($Value) >= 1000000) + return(round($Value/1000000,$Format)."M".$Unit); + elseif (abs($Value) >= 1000) + return(round($Value/1000,$Format)."K".$Unit); + } + // ARTICA-PANDORA HACK END return($Value.$Unit); }