Proyectos de Subversion LeadersLinked - Backend

Rev

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

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