diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index e97f9ec10a..2d53b1b00d 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,13 @@ +2011-04-13 Sergio Martin + + * include/graphs/functions_pchart.php + include/graphs/functions_fsgraph.php + include/graphs/functions_gd.php + include/graphs/fgraph.php: Fixed long index bug into + stacked and line graphs. + Add entry for radar and polar charts (kiviat) + Clean code + 2011-04-12 Miguel de Dios * include/graphs/functions_fsgraph.php: fixed the "fs_area_graph" when diff --git a/pandora_console/include/graphs/fgraph.php b/pandora_console/include/graphs/fgraph.php index 043cf9bf6c..74111e7603 100755 --- a/pandora_console/include/graphs/fgraph.php +++ b/pandora_console/include/graphs/fgraph.php @@ -91,8 +91,6 @@ function area_graph($flash_chart, $chart_data, $width, $height, $color, $legend, return fs_area_graph($chart_data, $width, $height, $color, $legend, $long_index); } else { - $id_graph = uniqid(); - $graph = array(); $graph['data'] = $chart_data; $graph['width'] = $width; @@ -102,7 +100,7 @@ function area_graph($flash_chart, $chart_data, $width, $height, $color, $legend, $graph['xaxisname'] = $xaxisname; $graph['yaxisname'] = $yaxisname; - serialize_in_temp($graph, $id_graph); + $id_graph = serialize_in_temp($graph); return ""; } @@ -118,8 +116,6 @@ function stacked_area_graph($flash_chart, $chart_data, $width, $height, $color, return fs_stacked_graph($chart_data, $width, $height, $color, $legend, $long_index); } else { - $id_graph = uniqid(); - //Stack the data stack_data($chart_data, $legend, $color); @@ -130,10 +126,10 @@ function stacked_area_graph($flash_chart, $chart_data, $width, $height, $color, $graph['color'] = $color; $graph['legend'] = $legend; - serialize_in_temp($graph, $id_graph); + $id_graph = serialize_in_temp($graph); - return ""; - } + return ""; + } } function stacked_line_graph($flash_chart, $chart_data, $width, $height, $color, $legend, $long_index, $no_data_image) { @@ -147,9 +143,7 @@ function stacked_line_graph($flash_chart, $chart_data, $width, $height, $color, if($flash_chart) { return fs_line_graph($chart_data, $width, $height, $color, $legend, $long_index); } - else { - $id_graph = uniqid(); - + else { $graph = array(); $graph['data'] = $chart_data; $graph['width'] = $width; @@ -157,9 +151,9 @@ function stacked_line_graph($flash_chart, $chart_data, $width, $height, $color, $graph['color'] = $color; $graph['legend'] = $legend; - serialize_in_temp($graph, $id_graph); + $id_graph = serialize_in_temp($graph); - return ""; + return ""; } } @@ -172,9 +166,6 @@ function line_graph($flash_chart, $chart_data, $width, $height, $color, $legend, return fs_line_graph($chart_data, $width, $height, $color, $legend, $long_index); } else { - $id_graph = uniqid(); - - $graph = array(); $graph['data'] = $chart_data; $graph['width'] = $width; @@ -182,12 +173,35 @@ function line_graph($flash_chart, $chart_data, $width, $height, $color, $legend, $graph['color'] = $color; $graph['legend'] = $legend; - serialize_in_temp($graph, $id_graph); + $id_graph = serialize_in_temp($graph); - return ""; + return ""; } } +function kiviat_graph($graph_type, $flash_chart, $chart_data, $width, $height, $no_data_image) { + if (empty($chart_data)) { + return ''; + } + + $graph = array(); + $graph['data'] = $chart_data; + $graph['width'] = $width; + $graph['height'] = $height; + + $id_graph = serialize_in_temp($graph); + + return ""; +} + +function radar_graph($flash_chart, $chart_data, $width, $height, $no_data_image) { + return kiviat_graph('radar', $flash_chart, $chart_data, $width, $height, $no_data_image); +} + +function polar_graph($flash_chart, $chart_data, $width, $height, $no_data_image) { + return kiviat_graph('polar', $flash_chart, $chart_data, $width, $height, $no_data_image); +} + function hbar_graph($flash_chart, $chart_data, $width, $height, $color = array(), $legend = array(), $xaxisname = "", $yaxisname = "") { if($flash_chart) { echo fs_hbar_chart (array_values($chart_data), array_keys($chart_data), $width, $height); diff --git a/pandora_console/include/graphs/functions_fsgraph.php b/pandora_console/include/graphs/functions_fsgraph.php index 9f9da5ce17..7091499f00 100755 --- a/pandora_console/include/graphs/functions_fsgraph.php +++ b/pandora_console/include/graphs/functions_fsgraph.php @@ -46,18 +46,6 @@ function fs_stacked_graph($chart_data, $width, $height, $color, $legend, $long_i $data2 = array(); $count = 0; foreach($chart_data as $i =>$values) { -// $count = 0; -// $step = 10; -// $num_vlines = 0; -// -// if ($count++ % $step == 0) { -// $show_name = '1'; -// $num_vlines++; -// } -// else { -// $show_name = '0'; -// } - $count++; $show_name = '0'; if (($count % $step) == 0) { @@ -69,6 +57,9 @@ function fs_stacked_graph($chart_data, $width, $height, $color, $legend, $long_i 'hoverText=' . $long_index[$i] . ';showName=' . $show_name); } + else { + $chart->addCategory($i, 'showName=' . $show_name); + } $c = 0; foreach($values as $i2 => $value) { @@ -198,18 +189,6 @@ function fs_line_graph($chart_data, $width, $height, $color, $legend, $long_inde $data2 = array(); $count = 0; foreach($chart_data as $i =>$values) { -// $count = 0; -// $step = 10; -// $num_vlines = 0; -// -// if ($count++ % $step == 0) { -// $show_name = '1'; -// $num_vlines++; -// } -// else { -// $show_name = '0'; -// } - $count++; $show_name = '0'; if (($count % $step) == 0) { @@ -221,6 +200,9 @@ function fs_line_graph($chart_data, $width, $height, $color, $legend, $long_inde 'hoverText=' . $long_index[$i] . ';showName=' . $show_name); } + else { + $chart->addCategory($i, 'showName=' . $show_name); + } $c = 0; foreach($values as $i2 => $value) { @@ -310,7 +292,7 @@ function fs_line_graph($chart_data, $width, $height, $color, $legend, $long_inde $output = '
'; - $output .= ''; + //$output .= ''; $output .= '