From 2c3bf6ff9a0ca718a2f464b8dd96194493784f67 Mon Sep 17 00:00:00 2001 From: mdtrooper Date: Thu, 20 Jun 2013 08:20:11 +0000 Subject: [PATCH] 2013-06-20 Miguel de Dios * include/graphs/pChart/pPie.class.php, include/graphs/fgraph.php: fixed the htmlentities in the pie chart legend, the border was fixed for older commits. MERGED FROM THE BRANCH PANDORA_4.0 git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@8357 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f --- pandora_console/ChangeLog | 8 ++ pandora_console/include/graphs/fgraph.php | 7 ++ .../include/graphs/pChart/pPie.class.php | 106 ++++++++++-------- 3 files changed, 73 insertions(+), 48 deletions(-) diff --git a/pandora_console/ChangeLog b/pandora_console/ChangeLog index 3886d55959..00fa4dd36f 100644 --- a/pandora_console/ChangeLog +++ b/pandora_console/ChangeLog @@ -1,3 +1,11 @@ +2013-06-20 Miguel de Dios + + * include/graphs/pChart/pPie.class.php, include/graphs/fgraph.php: + fixed the htmlentities in the pie chart legend, the border was + fixed for older commits. + + MERGED FROM THE BRANCH PANDORA_4.0 + 2013-06-20 Junichi Satoh * include/help/ja/help_alerts_config.php: Added a new help. diff --git a/pandora_console/include/graphs/fgraph.php b/pandora_console/include/graphs/fgraph.php index 053a7e48b6..bd2cb2d5ac 100755 --- a/pandora_console/include/graphs/fgraph.php +++ b/pandora_console/include/graphs/fgraph.php @@ -465,6 +465,13 @@ function pie_graph($graph_type, $flash_chart, $chart_data, $width, $height, // This library allows only 8 colors $max_values = 8; + //Remove the html_entities + $temp = array(); + foreach ($chart_data as $key => $value) { + $temp[io_safe_output($key)] = $value; + } + $chart_data = $temp; + if (count($chart_data) > $max_values) { $chart_data_trunc = array(); $n = 1; diff --git a/pandora_console/include/graphs/pChart/pPie.class.php b/pandora_console/include/graphs/pChart/pPie.class.php index fe8dc4cf80..bea05181f3 100755 --- a/pandora_console/include/graphs/pChart/pPie.class.php +++ b/pandora_console/include/graphs/pChart/pPie.class.php @@ -512,54 +512,64 @@ for($j=0;$jpChartObject->drawPolygon($Top,$Settings); } - - - /* Second pass to smooth the angles */ - if ( $SecondPass ) - { - $Step = 360 / (2 * PI * $Radius); - $Offset = 360; $ID = 0; - foreach($Values as $Key => $Value) - { - $FirstPoint = TRUE; - if ( $Shadow ) - $Settings = array("R"=>$this->pChartObject->ShadowR,"G"=>$this->pChartObject->ShadowG,"B"=>$this->pChartObject->ShadowB,"Alpha"=>$this->pChartObject->Shadowa); - else - { - if ( $Border ) - { $Settings = array("R"=>$Palette[$ID]["R"]+30,"G"=>$Palette[$ID]["G"]+30,"B"=>$Palette[$ID]["B"]+30,"Alpha"=>$Palette[$ID]["Alpha"]); } - else - $Settings = array("R"=>$Palette[$ID]["R"],"G"=>$Palette[$ID]["G"],"B"=>$Palette[$ID]["B"],"Alpha"=>$Palette[$ID]["Alpha"]); - } - - $EndAngle = $Offset-($Value*$ScaleFactor); if ( $EndAngle < 0 ) { $EndAngle = 0; } - - if ($DataGapAngle == 0) - { $X0 = $X; $Y0 = $Y- $SliceHeight; } - else - { - $Angle = ($EndAngle - $Offset)/2 + $Offset; - $X0 = cos(($Angle-90)*PI/180) * $DataGapRadius + $X; - $Y0 = sin(($Angle-90)*PI/180) * $DataGapRadius*$SkewFactor + $Y - $SliceHeight; - } - $Plots[] = $X0; $Plots[] = $Y0; - - for($i=$Offset;$i>=$EndAngle;$i=$i-$Step) - { - $Xc = cos(($i-90)*PI/180) * $Radius + $X; - $Yc = sin(($i-90)*PI/180) * $Radius*$SkewFactor + $Y - $SliceHeight; - - if ( $FirstPoint ) { $this->pChartObject->drawLine($Xc,$Yc,$X0,$Y0,$Settings); } { $FirstPoint = FALSE; } - - $this->pChartObject->drawAntialiasPixel($Xc,$Yc,$Settings); - if ($i < 270 && $i > 90 ) { $this->pChartObject->drawAntialiasPixel($Xc,$Yc+$SliceHeight,$Settings); } - } - $this->pChartObject->drawLine($Xc,$Yc,$X0,$Y0,$Settings); - - $Offset = $i - $DataGapAngle; $ID++; - } - } - + + + /* Second pass to smooth the angles */ + if ( $SecondPass ) + { + $Step = 360 / (2 * PI * $Radius); + $Offset = 360; $ID = 0; + foreach($Values as $Key => $Value) + { + $FirstPoint = TRUE; + if ( $Shadow ) + $Settings = array("R"=>$this->pChartObject->ShadowR,"G"=>$this->pChartObject->ShadowG,"B"=>$this->pChartObject->ShadowB,"Alpha"=>$this->pChartObject->Shadowa); + else + { + if ( $Border ) + { + $Settings = array( + "R" => $Palette[$ID]["R"] + 30, + "G" => $Palette[$ID]["G"] + 30, + "B" => $Palette[$ID]["B"] + 30, + "Alpha" => $Palette[$ID]["Alpha"]); + } + else + $Settings = array("R"=>$Palette[$ID]["R"],"G"=>$Palette[$ID]["G"],"B"=>$Palette[$ID]["B"],"Alpha"=>$Palette[$ID]["Alpha"]); + } + + $EndAngle = $Offset-($Value*$ScaleFactor); if ( $EndAngle < 0 ) { $EndAngle = 0; } + + if ($DataGapAngle == 0) + { $X0 = $X; $Y0 = $Y- $SliceHeight; } + else + { + $Angle = ($EndAngle - $Offset)/2 + $Offset; + $X0 = cos(($Angle-90)*PI/180) * $DataGapRadius + $X; + $Y0 = sin(($Angle-90)*PI/180) * $DataGapRadius*$SkewFactor + $Y - $SliceHeight; + } + $Plots[] = $X0; $Plots[] = $Y0; + + for ($i=$Offset;$i>=$EndAngle;$i=$i-$Step) + { + $Xc = cos(($i-90)*PI/180) * $Radius + $X; + $Yc = sin(($i-90)*PI/180) * $Radius*$SkewFactor + $Y - $SliceHeight; + + if ( $FirstPoint ) + { $this->pChartObject->drawLine($Xc,$Yc,$X0,$Y0,$Settings); } + else + { $FirstPoint = FALSE; } + + $this->pChartObject->drawAntialiasPixel($Xc,$Yc,$Settings); + if ($i < 270 && $i > 90 ) + { $this->pChartObject->drawAntialiasPixel($Xc,$Yc+$SliceHeight,$Settings); } + } + $this->pChartObject->drawLine($Xc,$Yc,$X0,$Y0,$Settings); + + $Offset = $i - $DataGapAngle; $ID++; + } + } + if ( $WriteValues != NULL ) { $Step = 360 / (2 * PI * $Radius);