diff --git a/htdocs/core/class/dolgraph.class.php b/htdocs/core/class/dolgraph.class.php index 4dff7e50e76..a48621bb745 100644 --- a/htdocs/core/class/dolgraph.class.php +++ b/htdocs/core/class/dolgraph.class.php @@ -260,7 +260,8 @@ class DolGraph /** * Set type * - * @param array $type Array with type for each serie. Example: array('pie', ...), array('lines', 'linesnopoint', 'bars', 'pie') + * @param array $type Array with type for each serie. Example: array('type1', 'type2', ...) where type can be: + * 'pie', 'piesemicircle', 'polar', 'lines', 'linesnopoint', 'bars', ... * @return void */ public function SetType($type) @@ -715,7 +716,7 @@ class DolGraph $x++; } - if (isset($this->type[$firstlot]) && $this->type[$firstlot] == 'pie') + if (isset($this->type[$firstlot]) && in_array($this->type[$firstlot], array('pie', 'piesemicircle', 'polar'))) { foreach ($values as $x => $y) { if (isset($y)) $serie[$i] .= 'd'.$i.'.push({"label":"'.dol_escape_js($legends[$x]).'", "data":'.$y.'});'."\n"; @@ -766,7 +767,7 @@ class DolGraph $this->stringtoshow .= "\n"; // Special case for Graph of type 'pie' - if (isset($this->type[$firstlot]) && ($this->type[$firstlot] == 'pie' || $this->type[$firstlot] == 'polar')) + if (isset($this->type[$firstlot]) && in_array($this->type[$firstlot], array('pie', 'piesemicircle', 'polar'))) { $datacolor = array(); foreach ($this->datacolor as $val) { @@ -933,7 +934,7 @@ class DolGraph * $this->data = array(array(0=>'labelxA',1=>yA1,...,n=>yAn), array('labelxB',yB1,...yBn)); // or when there is n series to show for each x * $this->data = array(array('label'=>'labelxA','data'=>yA), array('labelxB',yB)); // Syntax deprecated * $this->legend= array("Val1",...,"Valn"); // list of n series name - * $this->type = array('bars',...'lines', 'linesnopoint'); or array('pie') or array('polar'); + * $this->type = array('bars',...'lines', 'linesnopoint'); or array('pie') or array('polar') or array('piesemicircle'); * $this->mode = 'depth' ??? * $this->bgcolorgrid * $this->datacolor @@ -982,26 +983,11 @@ class DolGraph $x++; } - if (isset($this->type[$firstlot]) && $this->type[$firstlot] == 'pie') - { - $j = 0; - foreach ($values as $x => $y) { - //if (isset($y)) $serie[$i] .= 'd'.$i.'.push({"label":"'.dol_escape_js($legends[$x]).'", "data":'.$y.'});'."\n"; - if (isset($y)) { - //$serie[$i][] = $y; - $serie[$i] .= ($j > 0 ? ", " : "").$y; - $j++; - } - } - } - else - { - $j = 0; - foreach ($values as $x => $y) { - if (isset($y)) { - $serie[$i] .= ($j > 0 ? ", " : "").$y; - $j++; - } + $j = 0; + foreach ($values as $x => $y) { + if (isset($y)) { + $serie[$i] .= ($j > 0 ? ", " : "").$y; + $j++; } } @@ -1024,7 +1010,7 @@ class DolGraph if (count($this->data) > 20) $dolxaxisvertical='dol-xaxis-vertical'; // No height for the pie grah $cssfordiv = 'dolgraphchart'; - if (isset($this->type[$firstlot]) && ($this->type[$firstlot] == 'pie' || $this->type[$firstlot] == 'polar')) $cssfordiv .= ' dolgraphcharpie'; + if (isset($this->type[$firstlot])) $cssfordiv .= ' dolgraphchar'.$this->type[$firstlot]; $this->stringtoshow .= '
'."\n"; $this->stringtoshow .= '