Proyectos de Subversion LeadersLinked - Backend

Rev

Rev 6106 | Rev 6109 | Ir a la última revisión | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 6106 Rev 6107
Línea 70... Línea 70...
70
        $graph->Add($bplot);
70
        $graph->Add($bplot);
Línea 71... Línea 71...
71
 
71
 
72
 
72
 
73
        $graph->Stroke($filename);
-
 
74
    }
-
 
75
 
-
 
76
    function BarDiagram($w, $h, $data, $format, $color=null, $maxVal=0, $nbDiv=4)
-
 
77
    {
-
 
78
        $this->SetFont('Courier', '', 10);
-
 
79
        $this->SetLegends($data,$format);
-
 
80
 
-
 
81
        $XPage = $this->GetX();
-
 
82
        $YPage = $this->GetY();
-
 
83
        $margin = 2;
-
 
84
        $YDiag = $YPage + $margin;
-
 
85
        $hDiag = floor($h - $margin * 2);
-
 
86
        $XDiag = $XPage + $margin * 2 + $this->wLegend;
-
 
87
        $lDiag = floor($w - $margin * 3 - $this->wLegend);
-
 
88
        if($color == null)
-
 
89
            $color=array(155,155,155);
-
 
90
        if ($maxVal == 0) {
-
 
91
            $maxVal = max($data);
-
 
92
        }
-
 
93
        $valIndRepere = ceil($maxVal / $nbDiv);
-
 
94
        $maxVal = $valIndRepere * $nbDiv;
-
 
95
        $lRepere = floor($lDiag / $nbDiv);
-
 
96
        $lDiag = $lRepere * $nbDiv;
-
 
97
        $unit = $lDiag / $maxVal;
-
 
98
        $hBar = floor($hDiag / ($this->NbVal + 1));
-
 
99
        $hDiag = $hBar * ($this->NbVal + 1);
-
 
100
        $eBaton = floor($hBar * 80 / 100);
-
 
101
 
-
 
102
        $this->SetLineWidth(0.2);
-
 
103
        $this->Rect($XDiag, $YDiag, $lDiag, $hDiag);
-
 
104
 
-
 
105
        $this->SetFont('Courier', '', 10);
-
 
106
        $this->SetFillColor($color[0],$color[1],$color[2]);
-
 
107
        $i=0;
-
 
108
        foreach($data as $val) {
-
 
109
            //Bar
-
 
110
            $xval = $XDiag;
-
 
111
            $lval = (int)($val * $unit);
-
 
112
            $yval = $YDiag + ($i + 1) * $hBar - $eBaton / 2;
-
 
113
            $hval = $eBaton;
-
 
114
            $this->Rect($xval, $yval, $lval, $hval, 'DF');
-
 
115
            //Legend
-
 
116
            $this->SetXY(0, $yval);
-
 
117
            $this->Cell($xval - $margin, $hval, $this->legends[$i],0,0,'R');
-
 
118
            $i++;
-
 
119
        }
-
 
120
 
-
 
121
        //Scales
-
 
122
        for ($i = 0; $i <= $nbDiv; $i++) {
-
 
123
            $xpos = $XDiag + $lRepere * $i;
-
 
124
            $this->Line($xpos, $YDiag, $xpos, $YDiag + $hDiag);
-
 
125
            $val = $i * $valIndRepere;
-
 
126
            $xpos = $XDiag + $lRepere * $i - $this->GetStringWidth($val) / 2;
-
 
127
            $ypos = $YDiag + $hDiag - $margin;
-
 
128
            $this->Text($xpos, $ypos, $val);
-
 
129
        }
-
 
130
    }
73
        $graph->Stroke($filename);