Y axis fixed in custom graphs, now show correctly the numeration. Ticket#2578

This commit is contained in:
Arturo Gonzalez Diaz 2015-08-24 13:14:48 +02:00
parent 274d0c524f
commit 596a20b19d
4 changed files with 5033 additions and 5027 deletions

View File

@ -1444,7 +1444,7 @@ function graphic_combined_module ($module_list, $weight_list, $period,
$height, $color, $module_name_list, $long_index, $height, $color, $module_name_list, $long_index,
ui_get_full_url("images/image_problem.opaque.png", false, false, false), ui_get_full_url("images/image_problem.opaque.png", false, false, false),
"", "", $homeurl, $water_mark, $config['fontpath'], "", "", $homeurl, $water_mark, $config['fontpath'],
$fixed_font_size, "", $ttl, array(), array(), 0, 0, '', $fixed_font_size, $unit, $ttl, array(), array(), 0, 0, '',
false, '', true, $background_color); false, '', true, $background_color);
break; break;
default: default:

View File

@ -265,6 +265,7 @@ function area_graph($flash_chart, $chart_data, $width, $height, $color,
$graph['font'] = $font; $graph['font'] = $font;
$graph['font_size'] = $font_size; $graph['font_size'] = $font_size;
$graph['backgroundColor'] = $backgroundColor; $graph['backgroundColor'] = $backgroundColor;
$graph['unit'] = $unit;
$id_graph = serialize_in_temp($graph, null, $ttl); $id_graph = serialize_in_temp($graph, null, $ttl);

View File

@ -111,6 +111,9 @@ if (isset($graph['force_height'])) {
if (isset($graph['period'])) { if (isset($graph['period'])) {
$period = $graph['period']; $period = $graph['period'];
} }
if (isset($graph['unit'])){
$unit = $graph['unit'];
}
if (!$force_height) { if (!$force_height) {
if ($height < (count($graph['data']) * 14)) { if ($height < (count($graph['data']) * 14)) {
@ -301,7 +304,7 @@ switch($graph_type) {
case 'line': case 'line':
pch_vertical_graph($graph_type, $data_keys, $data_values, $width, pch_vertical_graph($graph_type, $data_keys, $data_values, $width,
$height, $rgb_color, $xaxisname, $yaxisname, false, $legend, $height, $rgb_color, $xaxisname, $yaxisname, false, $legend,
$font, $antialiasing, $water_mark, $font_size, $backgroundColor); $font, $antialiasing, $water_mark, $font_size, $backgroundColor, $unit);
break; break;
case 'threshold': case 'threshold':
pch_threshold_graph($graph_type, $data_keys, $data_values, $width, pch_threshold_graph($graph_type, $data_keys, $data_values, $width,
@ -619,7 +622,7 @@ function pch_bar_graph ($graph_type, $index, $data, $width, $height, $font,
function pch_vertical_graph ($graph_type, $index, $data, $width, $height, function pch_vertical_graph ($graph_type, $index, $data, $width, $height,
$rgb_color = false, $xaxisname = "", $yaxisname = "", $show_values = false, $rgb_color = false, $xaxisname = "", $yaxisname = "", $show_values = false,
$legend = array(), $font, $antialiasing, $water_mark = '', $font_size, $legend = array(), $font, $antialiasing, $water_mark = '', $font_size,
$backgroundColor = 'white') { $backgroundColor = 'white', $unit = '') {
/* CAT:Vertical Charts */ /* CAT:Vertical Charts */
if (!is_array($legend) || empty($legend)) { if (!is_array($legend) || empty($legend)) {
@ -692,6 +695,8 @@ function pch_vertical_graph ($graph_type, $index, $data, $width, $height,
$MyData->addPoints($index,"Xaxis"); $MyData->addPoints($index,"Xaxis");
$MyData->setSerieDescription("Xaxis", $xaxisname); $MyData->setSerieDescription("Xaxis", $xaxisname);
$MyData->setAbscissa("Xaxis"); $MyData->setAbscissa("Xaxis");
$MyData->setAxisUnit(0, $unit);
$MyData->setAxisDisplay(0, AXIS_FORMAT_METRIC);
switch($backgroundColor) { switch($backgroundColor) {
case 'white': case 'white':

View File

@ -2783,12 +2783,12 @@
if ( $Mode == AXIS_FORMAT_METRIC ) if ( $Mode == AXIS_FORMAT_METRIC )
{ {
if (abs($Value) > 1000000000) if (abs($Value) >= 1000000000)
return(round($Value/1000000000,$Format)."g".$Unit); return(round($Value/1000000000,$Format)."G".$Unit);
if (abs($Value) > 1000000) if (abs($Value) >= 1000000)
return(round($Value/1000000,$Format)."m".$Unit); return(round($Value/1000000,$Format)."M".$Unit);
elseif (abs($Value) >= 1000) elseif (abs($Value) >= 1000)
return(round($Value/1000,$Format)."k".$Unit); return(round($Value/1000,$Format)."K".$Unit);
} }
return($Value.$Unit); return($Value.$Unit);