function SetMargin($lm, $rm, $tm, $bm) { $this->left_margin = $lm; $this->right_margin = $rm; $this->top_margin = $tm; $this->bottom_margin = $bm; $this->plotwidth = $this->width - $this->left_margin - $this->right_margin; $this->plotheight = $this->height - $this->top_margin - $this->bottom_margin; if ($this->width > 0 && $this->height > 0) { if ($this->plotwidth < 0 || $this->plotheight < 0) { JpGraphError::raise("To small plot area. ({$lm},{$rm},{$tm},{$bm} : {$this->plotwidth} x {$this->plotheight}). With the given image size and margins there is to little space left for the plot. Increase the plot size or reduce the margins."); } } $this->NotifyObservers(); }
function CResultatsLaboGraph($patient, $examen, $resultats) { $resultats = array_reverse($resultats, true); if ($examen->type != "num") { JpGraphError::raise("Le type d'examen doit être numérique pour être affiché"); } // Prepare values // Value plot $ydata = array(); $xlabels = array(); $min = $examen->min; $max = $examen->max; foreach ($resultats as $resultat) { $min = min($min, $resultat->resultat); $max = max($max, $resultat->resultat); $ydata[] = $resultat->resultat; $xlabels[] = $resultat->date ? CMbDT::transform(null, $resultat->date, "%d/%m/%y") : "attendu"; } // Setup the graph. $this->Graph(360, 250, "auto"); $delta = 2; $this->SetScale("textlin", max(0, $min - $delta), $max + $delta); $this->SetMarginColor("lightblue"); // Image setup $this->img->SetAntiAliasing(true); $this->img->SetMargin(40, 10, 30, 40); if ($examen->max) { $uband = new PlotBand(HORIZONTAL, BAND_RDIAG, $examen->max, "max", "#ffbbbb"); $uband->ShowFrame(true); $uband->SetDensity(92); $this->AddBand($uband); } if ($examen->min) { $lband = new PlotBand(HORIZONTAL, BAND_RDIAG, "min", $examen->min, "#ffbbbb"); $lband->ShowFrame(true); $lband->SetDensity(92); $this->AddBand($lband); } // Legend setup $this->legend->Pos(0.02, 0.5, "right", "center"); $this->legend->SetShadow("darkgray@0.5", 3); $this->legend->SetFont(FF_ARIAL, FS_NORMAL, 7); $this->legend->SetFillColor("white@0.3"); // Title setup $this->title->SetFont(FF_ARIAL, FS_NORMAL, 10); $this->title->SetColor("darkred"); $this->title->Set("Résultats pour " . $examen->_view); $this->subtitle->SetFont(FF_ARIAL, FS_NORMAL, 8); $this->subtitle->SetColor("darkgray"); $this->subtitle->Set($patient->_view); // Setup X-axis labels $this->xgrid->Show(true); $this->xgrid->SetColor("lightgray", "lightgray:1.7"); $this->xaxis->SetFont(FF_ARIAL, FS_NORMAL, 7); $this->xaxis->SetLabelAlign("right", "top", "right"); $this->xaxis->SetLabelMargin(2); $this->xaxis->SetLabelAngle(45); $this->xaxis->SetTickLabels($xlabels); // Setup Y-axis labels $this->ygrid->Show(true, true); $this->ygrid->SetColor("lightgray", "lightgray:1.7"); $this->yaxis->SetFont(FF_ARIAL, FS_NORMAL, 8); $this->yaxis->scale->ticks->SupressMinorTickMarks(false); $this->yaxis->title->SetFont(FF_ARIAL, FS_NORMAL, 7); $this->yaxis->title->SetColor("darkred"); $this->yaxis->title->Set("valeurs en {$examen->unite}"); $this->yaxis->SetLabelMargin(4); $this->yaxis->SetTitleMargin(28); $plot = new LinePlot($ydata); $plot->SetCenter(); $plot->mark->SetType(MARK_FILLEDCIRCLE); $plot->mark->SetFillColor("gray"); $this->Add($plot); }