function Stroke($aStrokeFileName = "") { if ($this->texts != null) { for ($i = 0; $i < count($this->texts); ++$i) { $this->texts[$i]->Stroke($this->img); } } if ($this->iTables !== null) { for ($i = 0; $i < count($this->iTables); ++$i) { $this->iTables[$i]->Stroke($this->img); } } $this->StrokeTitles(); $_csim = $aStrokeFileName === _CSIM_SPECIALFILE; $this->iHasStroked = true; if (!$_csim) { if ($this->iImgTrans) { if (!class_exists('ImgTrans')) { require_once 'jpgraph_imgtrans.php'; } $tform = new ImgTrans($this->img->img); $this->img->img = $tform->Skew3D($this->iImgTransHorizon, $this->iImgTransSkewDist, $this->iImgTransDirection, $this->iImgTransHighQ, $this->iImgTransMinSize, $this->iImgTransFillColor, $this->iImgTransBorder); } if ($aStrokeFileName == _IMG_HANDLER) { return $this->img->img; } else { $this->cache->PutAndStream($this->img, $this->cache_name, $this->inline, $aStrokeFileName); return true; } } }
function Stroke($aStrokeFileName = "") { if ($this->texts != null) { for ($i = 0; $i < count($this->texts); ++$i) { $this->texts[$i]->Stroke($this->img); } } $this->StrokeTitles(); // Should we do any final image transformation if ($this->iImgTrans) { if (!class_exists('ImgTrans')) { require_once 'jpgraph_imgtrans.php'; } $tform = new ImgTrans($this->img->img); $this->img->img = $tform->Skew3D($this->iImgTransHorizon, $this->iImgTransSkewDist, $this->iImgTransDirection, $this->iImgTransHighQ, $this->iImgTransMinSize, $this->iImgTransFillColor, $this->iImgTransBorder); } // If the filename is given as the special _IMG_HANDLER // then the image handler is returned and the image is NOT // streamed back if ($aStrokeFileName == _IMG_HANDLER) { return $this->img->img; } else { // Finally stream the generated picture $this->cache->PutAndStream($this->img, $this->cache_name, $this->inline, $aStrokeFileName); return true; } }
function Stroke($aStrokeFileName = "") { if ($this->texts != null) { $textsCnt = count($this->texts); for ($i = 0; $i < $textsCnt; ++$i) { $this->texts[$i]->Stroke($this->img); } } if ($this->iTables !== null) { $iTablesCnt = count($this->iTables); for ($i = 0; $i < $iTablesCnt; ++$i) { $this->iTables[$i]->Stroke($this->img); } } $this->StrokeTitles(); // If the filename is the predefined value = '_csim_special_' // we assume that the call to stroke only needs to do enough // to correctly generate the CSIM maps. // We use this variable to skip things we don't strictly need // to do to generate the image map to improve performance // a best we can. Therefor you will see a lot of tests !$_csim in the // code below. $_csim = $aStrokeFileName === _CSIM_SPECIALFILE; // We need to know if we have stroked the plot in the // GetCSIMareas. Otherwise the CSIM hasn't been generated // and in the case of GetCSIM called before stroke to generate // CSIM without storing an image to disk GetCSIM must call Stroke. $this->iHasStroked = true; if (!$_csim) { // Should we do any final image transformation if ($this->iImgTrans) { if (!class_exists('ImgTrans', false)) { require_once 'jpgraph_imgtrans.php'; } $tform = new ImgTrans($this->img->img); $this->img->img = $tform->Skew3D($this->iImgTransHorizon, $this->iImgTransSkewDist, $this->iImgTransDirection, $this->iImgTransHighQ, $this->iImgTransMinSize, $this->iImgTransFillColor, $this->iImgTransBorder); } // If the filename is given as the special _IMG_HANDLER // then the image handler is returned and the image is NOT // streamed back if ($aStrokeFileName == _IMG_HANDLER) { return $this->img->img; } else { // Finally stream the generated picture $this->cache->PutAndStream($this->img, $this->cache_name, $this->inline, $aStrokeFileName); return true; } } }
function Stroke($aStrokeFileName = "") { // Fist make a sanity check that user has specified a scale if (empty($this->yscale)) { JpGraphError::Raise('You must specify what scale to use with a call to Graph::SetScale().'); } // Start by adjusting the margin so that potential titles will fit. $this->AdjustMarginsForTitles(); // If the filename is the predefined value = '_csim_special_' // we assume that the call to stroke only needs to do enough // to correctly generate the CSIM maps. // We use this variable to skip things we don't strictly need // to do to generate the image map to improve performance // a best we can. Therefor you will see a lot of tests !$_csim in the // code below. $_csim = $aStrokeFileName === _CSIM_SPECIALFILE; // We need to know if we have stroked the plot in the // GetCSIMareas. Otherwise the CSIM hasn't been generated // and in the case of GetCSIM called before stroke to generate // CSIM without storing an image to disk GetCSIM must call Stroke. $this->iHasStroked = true; // Do any pre-stroke adjustment that is needed by the different plot types // (i.e bar plots want's to add an offset to the x-labels etc) for ($i = 0; $i < count($this->plots); ++$i) { $this->plots[$i]->PreStrokeAdjust($this); $this->plots[$i]->DoLegend($this); } // Any plots on the second Y scale? if ($this->y2scale != null) { for ($i = 0; $i < count($this->y2plots); ++$i) { $this->y2plots[$i]->PreStrokeAdjust($this); $this->y2plots[$i]->DoLegend($this); } } // Bail out if any of the Y-axis not been specified and // has no plots. (This means it is impossible to do autoscaling and // no other scale was given so we can't possible draw anything). If you use manual // scaling you also have to supply the tick steps as well. if (!$this->yscale->IsSpecified() && count($this->plots) == 0 || $this->y2scale != null && !$this->y2scale->IsSpecified() && count($this->y2plots) == 0) { //$e = "n=".count($this->y2plots)."\n"; $e = "Can't draw unspecified Y-scale.<br>\nYou have either:<br>\n"; $e .= "1. Specified an Y axis for autoscaling but have not supplied any plots<br>\n"; $e .= "2. Specified a scale manually but have forgot to specify the tick steps"; JpGraphError::Raise($e); } // Bail out if no plots and no specified X-scale if (!$this->xscale->IsSpecified() && count($this->plots) == 0 && count($this->y2plots) == 0) { JpGraphError::Raise("<strong>JpGraph: Can't draw unspecified X-scale.</strong><br>No plots.<br>"); } //Check if we should autoscale y-axis if (!$this->yscale->IsSpecified() && count($this->plots) > 0) { list($min, $max) = $this->GetPlotsYMinMax($this->plots); $lres = $this->GetLinesYMinMax($this->lines); if (is_array($lres)) { list($linmin, $linmax) = $lres; $min = min($min, $linmin); $max = max($max, $linmax); } $tres = $this->GetTextsYMinMax(); if (is_array($tres)) { list($tmin, $tmax) = $tres; $min = min($min, $tmin); $max = max($max, $tmax); } $this->yscale->AutoScale($this->img, $min, $max, $this->img->plotheight / $this->ytick_factor); } elseif ($this->yscale->IsSpecified() && ($this->yscale->auto_ticks || !$this->yscale->ticks->IsSpecified())) { // The tick calculation will use the user suplied min/max values to determine // the ticks. If auto_ticks is false the exact user specifed min and max // values will be used for the scale. // If auto_ticks is true then the scale might be slightly adjusted // so that the min and max values falls on an even major step. $min = $this->yscale->scale[0]; $max = $this->yscale->scale[1]; $this->yscale->AutoScale($this->img, $min, $max, $this->img->plotheight / $this->ytick_factor, $this->yscale->auto_ticks); } if ($this->y2scale != null) { if (!$this->y2scale->IsSpecified() && count($this->y2plots) > 0) { list($min, $max) = $this->GetPlotsYMinMax($this->y2plots); $lres = $this->GetLinesYMinMax($this->y2lines); if (is_array($lres)) { list($linmin, $linmax) = $lres; $min = min($min, $linmin); $max = max($max, $linmax); } $tres = $this->GetTextsYMinMax(true); if (is_array($tres)) { list($tmin, $tmax) = $tres; $min = min($min, $tmin); $max = max($max, $tmax); } $this->y2scale->AutoScale($this->img, $min, $max, $this->img->plotheight / $this->ytick_factor); } elseif ($this->y2scale->IsSpecified() && ($this->y2scale->auto_ticks || !$this->y2scale->ticks->IsSpecified())) { // The tick calculation will use the user suplied min/max values to determine // the ticks. If auto_ticks is false the exact user specifed min and max // values will be used for the scale. // If auto_ticks is true then the scale might be slightly adjusted // so that the min and max values falls on an even major step. $min = $this->y2scale->scale[0]; $max = $this->y2scale->scale[1]; $this->y2scale->AutoScale($this->img, $min, $max, $this->img->plotheight / $this->ytick_factor, $this->y2scale->auto_ticks); } } //Check if we should autoscale x-axis if (!$this->xscale->IsSpecified()) { if (substr($this->axtype, 0, 4) == "text") { $max = 0; foreach ($this->plots as $p) { $max = max($max, $p->numpoints - 1); } $min = 0; if ($this->y2axis != null) { foreach ($this->y2plots as $p) { $max = max($max, $p->numpoints - 1); } } $this->xscale->Update($this->img, $min, $max); $this->xscale->ticks->Set($this->xaxis->tick_step, 1); $this->xscale->ticks->SupressMinorTickMarks(); } else { list($min, $max) = $this->GetXMinMax(); $lres = $this->GetLinesXMinMax($this->lines); if ($lres) { list($linmin, $linmax) = $lres; $min = min($min, $linmin); $max = max($max, $linmax); } $lres = $this->GetLinesXMinMax($this->y2lines); if ($lres) { list($linmin, $linmax) = $lres; $min = min($min, $linmin); $max = max($max, $linmax); } $tres = $this->GetTextsXMinMax(); if ($tres) { list($tmin, $tmax) = $tres; $min = min($min, $tmin); $max = max($max, $tmax); } $tres = $this->GetTextsXMinMax(true); if ($tres) { list($tmin, $tmax) = $tres; $min = min($min, $tmin); $max = max($max, $tmax); } $this->xscale->AutoScale($this->img, $min, $max, $this->img->plotwidth / $this->xtick_factor); } //Adjust position of y-axis and y2-axis to minimum/maximum of x-scale if (!is_numeric($this->yaxis->pos) && !is_string($this->yaxis->pos)) { $this->yaxis->SetPos($this->xscale->GetMinVal()); } if ($this->y2axis != null) { if (!is_numeric($this->y2axis->pos) && !is_string($this->y2axis->pos)) { $this->y2axis->SetPos($this->xscale->GetMaxVal()); } $this->y2axis->SetTitleSide(SIDE_RIGHT); } } elseif ($this->xscale->IsSpecified() && ($this->xscale->auto_ticks || !$this->xscale->ticks->IsSpecified())) { // The tick calculation will use the user suplied min/max values to determine // the ticks. If auto_ticks is false the exact user specifed min and max // values will be used for the scale. // If auto_ticks is true then the scale might be slightly adjusted // so that the min and max values falls on an even major step. $min = $this->xscale->scale[0]; $max = $this->xscale->scale[1]; $this->xscale->AutoScale($this->img, $min, $max, $this->img->plotwidth / $this->xtick_factor, false); if ($this->y2axis != null) { if (!is_numeric($this->y2axis->pos) && !is_string($this->y2axis->pos)) { $this->y2axis->SetPos($this->xscale->GetMaxVal()); } $this->y2axis->SetTitleSide(SIDE_RIGHT); } } // If we have a negative values and x-axis position is at 0 // we need to supress the first and possible the last tick since // they will be drawn on top of the y-axis (and possible y2 axis) // The test below might seem strange the reasone being that if // the user hasn't specified a value for position this will not // be set until we do the stroke for the axis so as of now it // is undefined. // For X-text scale we ignore all this since the tick are usually // much further in and not close to the Y-axis. Hence the test // for 'text' if (($this->yaxis->pos == $this->xscale->GetMinVal() || is_string($this->yaxis->pos) && $this->yaxis->pos == 'min') && !is_numeric($this->xaxis->pos) && $this->yscale->GetMinVal() < 0 && substr($this->axtype, 0, 4) != 'text' && $this->xaxis->pos != "min") { //$this->yscale->ticks->SupressZeroLabel(false); $this->xscale->ticks->SupressFirst(); if ($this->y2axis != null) { $this->xscale->ticks->SupressLast(); } } elseif (!is_numeric($this->yaxis->pos) && $this->yaxis->pos == 'max') { $this->xscale->ticks->SupressLast(); } if (!$_csim) { $this->StrokePlotArea(); $this->StrokeAxis(); } // Stroke bands if ($this->bands != null && !$_csim) { for ($i = 0; $i < count($this->bands); ++$i) { // Stroke all bands that asks to be in the background if ($this->bands[$i]->depth == DEPTH_BACK) { $this->bands[$i]->Stroke($this->img, $this->xscale, $this->yscale); } } } if ($this->y2bands != null && $this->y2scale != null && !$_csim) { for ($i = 0; $i < count($this->y2bands); ++$i) { // Stroke all bands that asks to be in the foreground if ($this->y2bands[$i]->depth == DEPTH_BACK) { $this->y2bands[$i]->Stroke($this->img, $this->xscale, $this->y2scale); } } } if ($this->grid_depth == DEPTH_BACK && !$_csim) { $this->ygrid->Stroke(); $this->xgrid->Stroke(); } // Stroke Y2-axis if ($this->y2axis != null && !$_csim) { $this->y2axis->Stroke($this->xscale); $this->y2grid->Stroke(); } $oldoff = $this->xscale->off; if (substr($this->axtype, 0, 4) == "text") { $this->xscale->off += ceil($this->xscale->scale_factor * $this->text_scale_off * $this->xscale->ticks->minor_step); } if ($this->iDoClipping) { $oldimage = $this->img->CloneCanvasH(); } if (!$this->y2orderback) { // Stroke all plots for Y1 axis for ($i = 0; $i < count($this->plots); ++$i) { $this->plots[$i]->Stroke($this->img, $this->xscale, $this->yscale); $this->plots[$i]->StrokeMargin($this->img); } } // Stroke all plots for Y2 axis if ($this->y2scale != null) { for ($i = 0; $i < count($this->y2plots); ++$i) { $this->y2plots[$i]->Stroke($this->img, $this->xscale, $this->y2scale); } } if ($this->y2orderback) { // Stroke all plots for Y1 axis for ($i = 0; $i < count($this->plots); ++$i) { $this->plots[$i]->Stroke($this->img, $this->xscale, $this->yscale); $this->plots[$i]->StrokeMargin($this->img); } } if ($this->iDoClipping) { // Clipping only supports graphs at 0 and 90 degrees if ($this->img->a == 0) { $this->img->CopyCanvasH($oldimage, $this->img->img, $this->img->left_margin, $this->img->top_margin, $this->img->left_margin, $this->img->top_margin, $this->img->plotwidth + 1, $this->img->plotheight); } elseif ($this->img->a == 90) { $adj = ($this->img->height - $this->img->width) / 2; $this->img->CopyCanvasH($oldimage, $this->img->img, $this->img->bottom_margin - $adj, $this->img->left_margin + $adj, $this->img->bottom_margin - $adj, $this->img->left_margin + $adj, $this->img->plotheight + 1, $this->img->plotwidth); } else { JpGraphError::Raise('You have enabled clipping. Cliping is only supported for graphs at 0 or 90 degrees rotation. Please adjust you current angle (=' . $this->img->a . ' degrees) or disable clipping.'); } $this->img->Destroy(); $this->img->SetCanvasH($oldimage); } $this->xscale->off = $oldoff; if ($this->grid_depth == DEPTH_FRONT && !$_csim) { $this->ygrid->Stroke(); $this->xgrid->Stroke(); } // Stroke bands if ($this->bands != null) { for ($i = 0; $i < count($this->bands); ++$i) { // Stroke all bands that asks to be in the foreground if ($this->bands[$i]->depth == DEPTH_FRONT) { $this->bands[$i]->Stroke($this->img, $this->xscale, $this->yscale); } } } if ($this->y2bands != null && $this->y2scale != null) { for ($i = 0; $i < count($this->y2bands); ++$i) { // Stroke all bands that asks to be in the foreground if ($this->y2bands[$i]->depth == DEPTH_FRONT) { $this->y2bands[$i]->Stroke($this->img, $this->xscale, $this->y2scale); } } } // Stroke any lines added if ($this->lines != null) { for ($i = 0; $i < count($this->lines); ++$i) { $this->lines[$i]->Stroke($this->img, $this->xscale, $this->yscale); } } if ($this->y2lines != null && $this->y2scale != null) { for ($i = 0; $i < count($this->y2lines); ++$i) { $this->y2lines[$i]->Stroke($this->img, $this->xscale, $this->y2scale); } } // Finally draw the axis again since some plots may have nagged // the axis in the edges. if (!$_csim) { $this->StrokeAxis(); } if ($this->y2scale != null && !$_csim) { $this->y2axis->Stroke($this->xscale); } if (!$_csim) { $this->StrokePlotBox(); } if (!$_csim) { // The titles and legends never gets rotated so make sure // that the angle is 0 before stroking them $aa = $this->img->SetAngle(0); $this->StrokeTitles(); $this->footer->Stroke($this->img); } $this->legend->Stroke($this->img); if (!$_csim) { $this->StrokeTexts(); $this->img->SetAngle($aa); // Draw an outline around the image map if (_JPG_DEBUG) { $this->DisplayClientSideaImageMapAreas(); } // Adjust the appearance of the image $this->AdjustSaturationBrightnessContrast(); // Should we do any final image transformation if ($this->iImgTrans) { if (!class_exists('ImgTrans')) { require_once 'jpgraph_imgtrans.php'; //JpGraphError::Raise('In order to use image transformation you must include the file jpgraph_imgtrans.php in your script.'); } $tform = new ImgTrans($this->img->img); $this->img->img = $tform->Skew3D($this->iImgTransHorizon, $this->iImgTransSkewDist, $this->iImgTransDirection, $this->iImgTransHighQ, $this->iImgTransMinSize, $this->iImgTransFillColor, $this->iImgTransBorder); } // If the filename is given as the special "__handle" // then the image handler is returned and the image is NOT // streamed back if ($aStrokeFileName == _IMG_HANDLER) { return $this->img->img; } else { // Finally stream the generated picture $this->cache->PutAndStream($this->img, $this->cache_name, $this->inline, $aStrokeFileName); } } }
function Stroke($aStrokeFileName = '') { // Fist make a sanity check that user has specified a scale if (empty($this->yscale)) { JpGraphError::RaiseL(25031); //('You must specify what scale to use with a call to Graph::SetScale().'); } // Start by adjusting the margin so that potential titles will fit. $this->AdjustMarginsForTitles(); // Give the plot a chance to do any scale adjuments the individual plots // wants to do. Right now this is only used by the contour plot to set scale // limits for ($i = 0; $i < count($this->plots); ++$i) { $this->plots[$i]->PreScaleSetup($this); } // Init scale constants that are used to calculate the transformation from // world to pixel coordinates $this->InitScaleConstants(); // If the filename is the predefined value = '_csim_special_' // we assume that the call to stroke only needs to do enough // to correctly generate the CSIM maps. // We use this variable to skip things we don't strictly need // to do to generate the image map to improve performance // a best we can. Therefor you will see a lot of tests !$_csim in the // code below. $_csim = $aStrokeFileName === _CSIM_SPECIALFILE; // If we are called the second time (perhaps the user has called GetHTMLImageMap() // himself then the legends have alsready been populated once in order to get the // CSIM coordinats. Since we do not want the legends to be populated a second time // we clear the legends $this->legend->Clear(); // We need to know if we have stroked the plot in the // GetCSIMareas. Otherwise the CSIM hasn't been generated // and in the case of GetCSIM called before stroke to generate // CSIM without storing an image to disk GetCSIM must call Stroke. $this->iHasStroked = true; // Setup pre-stroked adjustments and Legends $this->doPrestrokeAdjustments(); if ($this->graph_theme) { $this->graph_theme->PreStrokeApply($this); } // Bail out if any of the Y-axis not been specified and // has no plots. (This means it is impossible to do autoscaling and // no other scale was given so we can't possible draw anything). If you use manual // scaling you also have to supply the tick steps as well. if (!$this->yscale->IsSpecified() && count($this->plots) == 0 || $this->y2scale != null && !$this->y2scale->IsSpecified() && count($this->y2plots) == 0) { //$e = "n=".count($this->y2plots)."\n"; // $e = "Can't draw unspecified Y-scale.<br>\nYou have either:<br>\n"; // $e .= "1. Specified an Y axis for autoscaling but have not supplied any plots<br>\n"; // $e .= "2. Specified a scale manually but have forgot to specify the tick steps"; JpGraphError::RaiseL(25026); } // Bail out if no plots and no specified X-scale if (!$this->xscale->IsSpecified() && count($this->plots) == 0 && count($this->y2plots) == 0) { JpGraphError::RaiseL(25034); //("<strong>JpGraph: Can't draw unspecified X-scale.</strong><br>No plots.<br>"); } // Autoscale the normal Y-axis $this->doAutoScaleYAxis(); // Autoscale all additiopnal y-axis $this->doAutoScaleYnAxis(); // Autoscale the regular x-axis and position the y-axis properly $this->doAutoScaleXAxis(); // If we have a negative values and x-axis position is at 0 // we need to supress the first and possible the last tick since // they will be drawn on top of the y-axis (and possible y2 axis) // The test below might seem strange the reasone being that if // the user hasn't specified a value for position this will not // be set until we do the stroke for the axis so as of now it // is undefined. // For X-text scale we ignore all this since the tick are usually // much further in and not close to the Y-axis. Hence the test // for 'text' if (($this->yaxis->pos == $this->xscale->GetMinVal() || is_string($this->yaxis->pos) && $this->yaxis->pos == 'min') && !is_numeric($this->xaxis->pos) && $this->yscale->GetMinVal() < 0 && substr($this->axtype, 0, 4) != 'text' && $this->xaxis->pos != 'min') { //$this->yscale->ticks->SupressZeroLabel(false); $this->xscale->ticks->SupressFirst(); if ($this->y2axis != null) { $this->xscale->ticks->SupressLast(); } } elseif (!is_numeric($this->yaxis->pos) && $this->yaxis->pos == 'max') { $this->xscale->ticks->SupressLast(); } if (!$_csim) { $this->StrokePlotArea(); if ($this->iIconDepth == DEPTH_BACK) { $this->StrokeIcons(); } } $this->StrokeAxis(false); // Stroke colored bands $this->StrokeBands(DEPTH_BACK, $_csim); if ($this->grid_depth == DEPTH_BACK && !$_csim) { $this->ygrid->Stroke(); $this->xgrid->Stroke(); } // Stroke Y2-axis if ($this->y2axis != null && !$_csim) { $this->y2axis->Stroke($this->xscale); $this->y2grid->Stroke(); } // Stroke yn-axis $n = count($this->ynaxis); for ($i = 0; $i < $n; ++$i) { $this->ynaxis[$i]->Stroke($this->xscale); } $oldoff = $this->xscale->off; if (substr($this->axtype, 0, 4) == 'text') { if ($this->text_scale_abscenteroff > -1) { // For a text scale the scale factor is the number of pixel per step. // Hence we can use the scale factor as a substitute for number of pixels // per major scale step and use that in order to adjust the offset so that // an object of width "abscenteroff" becomes centered. $this->xscale->off += round($this->xscale->scale_factor / 2) - round($this->text_scale_abscenteroff / 2); } else { $this->xscale->off += ceil($this->xscale->scale_factor * $this->text_scale_off * $this->xscale->ticks->minor_step); } } if ($this->iDoClipping) { $oldimage = $this->img->CloneCanvasH(); } if (!$this->y2orderback) { // Stroke all plots for Y1 axis for ($i = 0; $i < count($this->plots); ++$i) { $this->plots[$i]->Stroke($this->img, $this->xscale, $this->yscale); $this->plots[$i]->StrokeMargin($this->img); } } // Stroke all plots for Y2 axis if ($this->y2scale != null) { for ($i = 0; $i < count($this->y2plots); ++$i) { $this->y2plots[$i]->Stroke($this->img, $this->xscale, $this->y2scale); } } if ($this->y2orderback) { // Stroke all plots for Y1 axis for ($i = 0; $i < count($this->plots); ++$i) { $this->plots[$i]->Stroke($this->img, $this->xscale, $this->yscale); $this->plots[$i]->StrokeMargin($this->img); } } $n = count($this->ynaxis); for ($i = 0; $i < $n; ++$i) { $m = count($this->ynplots[$i]); for ($j = 0; $j < $m; ++$j) { $this->ynplots[$i][$j]->Stroke($this->img, $this->xscale, $this->ynscale[$i]); $this->ynplots[$i][$j]->StrokeMargin($this->img); } } if ($this->iIconDepth == DEPTH_FRONT) { $this->StrokeIcons(); } if ($this->iDoClipping) { // Clipping only supports graphs at 0 and 90 degrees if ($this->img->a == 0) { $this->img->CopyCanvasH($oldimage, $this->img->img, $this->img->left_margin, $this->img->top_margin, $this->img->left_margin, $this->img->top_margin, $this->img->plotwidth + 1, $this->img->plotheight); } elseif ($this->img->a == 90) { $adj = ($this->img->height - $this->img->width) / 2; $this->img->CopyCanvasH($oldimage, $this->img->img, $this->img->bottom_margin - $adj, $this->img->left_margin + $adj, $this->img->bottom_margin - $adj, $this->img->left_margin + $adj, $this->img->plotheight + 1, $this->img->plotwidth); } else { JpGraphError::RaiseL(25035, $this->img->a); //('You have enabled clipping. Cliping is only supported for graphs at 0 or 90 degrees rotation. Please adjust you current angle (='.$this->img->a.' degrees) or disable clipping.'); } $this->img->Destroy(); $this->img->SetCanvasH($oldimage); } $this->xscale->off = $oldoff; if ($this->grid_depth == DEPTH_FRONT && !$_csim) { $this->ygrid->Stroke(); $this->xgrid->Stroke(); } // Stroke colored bands $this->StrokeBands(DEPTH_FRONT, $_csim); // Finally draw the axis again since some plots may have nagged // the axis in the edges. if (!$_csim) { $this->StrokeAxis(); } if ($this->y2scale != null && !$_csim) { $this->y2axis->Stroke($this->xscale, false); } if (!$_csim) { $this->StrokePlotBox(); } // The titles and legends never gets rotated so make sure // that the angle is 0 before stroking them $aa = $this->img->SetAngle(0); $this->StrokeTitles(); $this->footer->Stroke($this->img); $this->legend->Stroke($this->img); $this->img->SetAngle($aa); $this->StrokeTexts(); $this->StrokeTables(); if (!$_csim) { $this->img->SetAngle($aa); // Draw an outline around the image map if (_JPG_DEBUG) { $this->DisplayClientSideaImageMapAreas(); } // Should we do any final image transformation if ($this->iImgTrans) { if (!class_exists('ImgTrans', false)) { require_once 'jpgraph_imgtrans.php'; //JpGraphError::Raise('In order to use image transformation you must include the file jpgraph_imgtrans.php in your script.'); } $tform = new ImgTrans($this->img->img); $this->img->img = $tform->Skew3D($this->iImgTransHorizon, $this->iImgTransSkewDist, $this->iImgTransDirection, $this->iImgTransHighQ, $this->iImgTransMinSize, $this->iImgTransFillColor, $this->iImgTransBorder); } // If the filename is given as the special "__handle" // then the image handler is returned and the image is NOT // streamed back if ($aStrokeFileName == _IMG_HANDLER) { return $this->img->img; } else { // Finally stream the generated picture $this->cache->PutAndStream($this->img, $this->cache_name, $this->inline, $aStrokeFileName); } } }
function Stroke($aStrokeFileName = "") { $n = count($this->plots); // Set Y-scale if (!$this->yscale->IsSpecified() && count($this->plots) > 0) { list($min, $max) = $this->GetPlotsYMinMax(); $this->yscale->AutoScale($this->img, 0, $max, $this->len / $this->ytick_factor); } // Set start position end length of scale (in absolute pixels) $this->yscale->SetConstants($this->posx, $this->len); // We need as many axis as there are data points $nbrpnts = $this->plots[0]->GetCount(); // If we have no titles just number the axis 1,2,3,... if ($this->axis_title == null) { for ($i = 0; $i < $nbrpnts; ++$i) { $this->axis_title[$i] = $i + 1; } } elseif (count($this->axis_title) < $nbrpnts) { JpGraphError::RaiseL(18007); } //("Number of titles does not match number of points in plot."); for ($i = 0; $i < $n; ++$i) { if ($nbrpnts != $this->plots[$i]->GetCount()) { JpGraphError::RaiseL(18008); } } //("Each radar plot must have the same number of data points."); if ($this->background_image != "") { $this->StrokeFrameBackground(); } else { $this->StrokeFrame(); } $astep = 2 * M_PI / $nbrpnts; // Prepare legends for ($i = 0; $i < $n; ++$i) { $this->plots[$i]->Legend($this); } $this->legend->Stroke($this->img); $this->footer->Stroke($this->img); if ($this->grid_depth == DEPTH_BACK) { // Draw axis and grid for ($i = 0, $a = M_PI / 2; $i < $nbrpnts; ++$i, $a += $astep) { $this->axis->Stroke($this->posy, $a, $grid[$i], $this->axis_title[$i], $i == 0); } } // Plot points $a = M_PI / 2; for ($i = 0; $i < $n; ++$i) { $this->plots[$i]->Stroke($this->img, $this->posy, $this->yscale, $a); } if ($this->grid_depth != DEPTH_BACK) { // Draw axis and grid for ($i = 0, $a = M_PI / 2; $i < $nbrpnts; ++$i, $a += $astep) { $this->axis->Stroke($this->posy, $a, $grid[$i], $this->axis_title[$i], $i == 0); } } $this->grid->Stroke($this->img, $grid); $this->StrokeTitles(); // Stroke texts if ($this->texts != null) { foreach ($this->texts as $t) { $t->Stroke($this->img); } } // Should we do any final image transformation if ($this->iImgTrans) { if (!class_exists('ImgTrans')) { require_once 'jpgraph_imgtrans.php'; } $tform = new ImgTrans($this->img->img); $this->img->img = $tform->Skew3D($this->iImgTransHorizon, $this->iImgTransSkewDist, $this->iImgTransDirection, $this->iImgTransHighQ, $this->iImgTransMinSize, $this->iImgTransFillColor, $this->iImgTransBorder); } // If the filename is given as the special "__handle" // then the image handler is returned and the image is NOT // streamed back if ($aStrokeFileName == _IMG_HANDLER) { return $this->img->img; } else { // Finally stream the generated picture $this->cache->PutAndStream($this->img, $this->cache_name, $this->inline, $aStrokeFileName); } }
function Stroke($aStrokeFileName = "") { // If the filename is the predefined value = '_csim_special_' // we assume that the call to stroke only needs to do enough // to correctly generate the CSIM maps. // We use this variable to skip things we don't strictly need // to do to generate the image map to improve performance // a best we can. Therefor you will see a lot of tests !$_csim in the // code below. $_csim = $aStrokeFileName === _CSIM_SPECIALFILE; // Should we autoscale dates? if (!$this->scale->IsRangeSet()) { list($min, $max) = $this->GetBarMinMax(); $this->scale->SetRange($min, $max); } $this->scale->AdjustStartEndDay(); // Check if we should autoscale the image $this->AutoSize(); // Should we start from the top or just spread the bars out even over the // available height $this->scale->SetVertLayout($this->iLayout); if ($this->iLayout == GANTT_FROMTOP) { $maxheight = max($this->GetMaxLabelHeight(), $this->GetMaxBarAbsHeight()); $this->scale->SetVertSpacing($maxheight * (1 + $this->iLabelVMarginFactor)); } // If it hasn't been set find out the maximum line number if ($this->scale->iVertLines == -1) { $this->scale->iVertLines = $this->GetBarMaxLineNumber() + 1; } $maxwidth = max($this->scale->actinfo->GetWidth($this->img), max($this->GetMaxLabelWidth(), $this->scale->tableTitle->GetWidth($this->img))); $this->scale->SetLabelWidth($maxwidth + $this->scale->divider->iWeight); //*(1+$this->iLabelHMarginFactor)); if (!$_csim) { $this->StrokePlotArea(); if ($this->iIconDepth == DEPTH_BACK) { $this->StrokeIcons(); } } $this->scale->Stroke(); if (!$_csim) { // Due to a minor off by 1 bug we need to temporarily adjust the margin $this->img->right_margin--; $this->StrokePlotBox(); $this->img->right_margin++; } // Stroke Grid line $this->hgrid->Stroke($this->img, $this->scale); $n = count($this->iObj); for ($i = 0; $i < $n; ++$i) { //$this->iObj[$i]->SetLabelLeftMargin(round($maxwidth*$this->iLabelHMarginFactor/2)); $this->iObj[$i]->Stroke($this->img, $this->scale); } $this->StrokeTitles(); if (!$_csim) { $this->StrokeConstrains(); $this->footer->Stroke($this->img); if ($this->iIconDepth == DEPTH_FRONT) { $this->StrokeIcons(); } // Should we do any final image transformation if ($this->iImgTrans) { if (!class_exists('ImgTrans', false)) { require_once 'jpgraph_imgtrans.php'; } $tform = new ImgTrans($this->img->img); $this->img->img = $tform->Skew3D($this->iImgTransHorizon, $this->iImgTransSkewDist, $this->iImgTransDirection, $this->iImgTransHighQ, $this->iImgTransMinSize, $this->iImgTransFillColor, $this->iImgTransBorder); } // If the filename is given as the special "__handle" // then the image handler is returned and the image is NOT // streamed back if ($aStrokeFileName == _IMG_HANDLER) { return $this->img->img; } else { // Finally stream the generated picture $this->cache->PutAndStream($this->img, $this->cache_name, $this->inline, $aStrokeFileName); } } }
function Stroke($aStrokeFileName = "") { // If the filename is the predefined value = '_csim_special_' // we assume that the call to stroke only needs to do enough // to correctly generate the CSIM maps. // We use this variable to skip things we don't strictly need // to do to generate the image map to improve performance // a best we can. Therefor you will see a lot of tests !$_csim in the // code below. $_csim = $aStrokeFileName === _CSIM_SPECIALFILE; // We need to know if we have stroked the plot in the // GetCSIMareas. Otherwise the CSIM hasn't been generated // and in the case of GetCSIM called before stroke to generate // CSIM without storing an image to disk GetCSIM must call Stroke. $this->iHasStroked = true; $n = count($this->plots); if ($this->pieaa) { if (!$_csim) { if ($this->background_image != "") { $this->StrokeFrameBackground(); } else { $this->StrokeFrame(); } } $w = $this->img->width; $h = $this->img->height; $oldimg = $this->img->img; $this->img->CreateImgCanvas(2 * $w, 2 * $h); $this->img->SetColor($this->margin_color); $this->img->FilledRectangle(0, 0, 2 * $w - 1, 2 * $h - 1); // Make all icons *2 i size since we will be scaling down the // imahe to do the anti aliasing $ni = count($this->iIcons); for ($i = 0; $i < $ni; ++$i) { $this->iIcons[$i]->iScale *= 2; } $this->StrokeIcons(); for ($i = 0; $i < $n; ++$i) { if ($this->plots[$i]->posx > 1) { $this->plots[$i]->posx *= 2; } if ($this->plots[$i]->posy > 1) { $this->plots[$i]->posy *= 2; } $this->plots[$i]->Stroke($this->img, 1); if ($this->plots[$i]->posx > 1) { $this->plots[$i]->posx /= 2; } if ($this->plots[$i]->posy > 1) { $this->plots[$i]->posy /= 2; } } $indent = $this->doframe ? $this->frame_weight + ($this->doshadow ? $this->shadow_width : 0) : 0; $indent += $this->framebevel ? $this->framebeveldepth + 1 : 0; $this->img->CopyCanvasH($oldimg, $this->img->img, $indent, $indent, $indent, $indent, $w - 2 * $indent, $h - 2 * $indent, 2 * ($w - $indent), 2 * ($h - $indent)); $this->img->img = $oldimg; $this->img->width = $w; $this->img->height = $h; for ($i = 0; $i < $n; ++$i) { $this->plots[$i]->Stroke($this->img, 2); // Stroke labels $this->plots[$i]->Legend($this); } } else { if (!$_csim) { if ($this->background_image != "") { $this->StrokeFrameBackground(); } else { $this->StrokeFrame(); } } $this->StrokeIcons(); for ($i = 0; $i < $n; ++$i) { $this->plots[$i]->Stroke($this->img); $this->plots[$i]->Legend($this); } } $this->legend->Stroke($this->img); $this->footer->Stroke($this->img); $this->StrokeTitles(); if (!$_csim) { // Stroke texts if ($this->texts != null) { $n = count($this->texts); for ($i = 0; $i < $n; ++$i) { $this->texts[$i]->Stroke($this->img); } } if (_JPG_DEBUG) { $this->DisplayCSIMAreas(); } // Should we do any final image transformation if ($this->iImgTrans) { if (!class_exists('ImgTrans')) { require_once 'jpgraph_imgtrans.php'; //JpGraphError::Raise('In order to use image transformation you must include the file jpgraph_imgtrans.php in your script.'); } $tform = new ImgTrans($this->img->img); $this->img->img = $tform->Skew3D($this->iImgTransHorizon, $this->iImgTransSkewDist, $this->iImgTransDirection, $this->iImgTransHighQ, $this->iImgTransMinSize, $this->iImgTransFillColor, $this->iImgTransBorder); } // If the filename is given as the special "__handle" // then the image handler is returned and the image is NOT // streamed back if ($aStrokeFileName == _IMG_HANDLER) { return $this->img->img; } else { // Finally stream the generated picture $this->cache->PutAndStream($this->img, $this->cache_name, $this->inline, $aStrokeFileName); } } }
function Stroke($aStrokeFileName = '') { // If the filename is the predefined value = '_csim_special_' // we assume that the call to stroke only needs to do enough // to correctly generate the CSIM maps. // We use this variable to skip things we don't strictly need // to do to generate the image map to improve performance // a best we can. Therefor you will see a lot of tests !$_csim in the // code below. $_csim = $aStrokeFileName === _CSIM_SPECIALFILE; // We need to know if we have stroked the plot in the // GetCSIMareas. Otherwise the CSIM hasn't been generated // and in the case of GetCSIM called before stroke to generate // CSIM without storing an image to disk GetCSIM must call Stroke. $this->iHasStroked = true; $n = count($this->plots); // Set Y-scale if (!$this->yscale->IsSpecified() && count($this->plots) > 0) { list($min, $max) = $this->GetPlotsYMinMax($this->plots); $this->yscale->AutoScale($this->img, 0, $max, $this->len / $this->ytick_factor); } elseif ($this->yscale->IsSpecified() && ($this->yscale->auto_ticks || !$this->yscale->ticks->IsSpecified())) { // The tick calculation will use the user suplied min/max values to determine // the ticks. If auto_ticks is false the exact user specifed min and max // values will be used for the scale. // If auto_ticks is true then the scale might be slightly adjusted // so that the min and max values falls on an even major step. $min = $this->yscale->scale[0]; $max = $this->yscale->scale[1]; $this->yscale->AutoScale($this->img, $min, $max, $this->len / $this->ytick_factor, $this->yscale->auto_ticks); } // Set start position end length of scale (in absolute pixels) $this->yscale->SetConstants($this->posx, $this->len); // We need as many axis as there are data points $nbrpnts = $this->plots[0]->GetCount(); // If we have no titles just number the axis 1,2,3,... if ($this->axis_title == null) { for ($i = 0; $i < $nbrpnts; ++$i) { $this->axis_title[$i] = $i + 1; } } elseif (count($this->axis_title) < $nbrpnts) { JpGraphError::RaiseL(18007); // ("Number of titles does not match number of points in plot."); } for ($i = 0; $i < $n; ++$i) { if ($nbrpnts != $this->plots[$i]->GetCount()) { JpGraphError::RaiseL(18008); //("Each radar plot must have the same number of data points."); } } if (!$_csim) { if ($this->background_image != '') { $this->StrokeFrameBackground(); } else { $this->StrokeFrame(); $this->StrokeBackgroundGrad(); } } $astep = 2 * M_PI / $nbrpnts; if (!$_csim) { if ($this->iIconDepth == DEPTH_BACK) { $this->StrokeIcons(); } // Prepare legends for ($i = 0; $i < $n; ++$i) { $this->plots[$i]->Legend($this); } $this->legend->Stroke($this->img); $this->footer->Stroke($this->img); } if (!$_csim) { if ($this->grid_depth == DEPTH_BACK) { // Draw axis and grid for ($i = 0, $a = M_PI / 2; $i < $nbrpnts; ++$i, $a += $astep) { $this->axis->Stroke($this->posy, $a, $grid[$i], $this->axis_title[$i], $i == 0); } $this->grid->Stroke($this->img, $grid); } if ($this->iIconDepth == DEPTH_BACK) { $this->StrokeIcons(); } } // Plot points $a = M_PI / 2; for ($i = 0; $i < $n; ++$i) { $this->plots[$i]->Stroke($this->img, $this->posy, $this->yscale, $a); } if (!$_csim) { if ($this->grid_depth != DEPTH_BACK) { // Draw axis and grid for ($i = 0, $a = M_PI / 2; $i < $nbrpnts; ++$i, $a += $astep) { $this->axis->Stroke($this->posy, $a, $grid[$i], $this->axis_title[$i], $i == 0); } $this->grid->Stroke($this->img, $grid); } $this->StrokeTitles(); $this->StrokeTexts(); if ($this->iIconDepth == DEPTH_FRONT) { $this->StrokeIcons(); } } // Should we do any final image transformation if ($this->iImgTrans && !$_csim) { if (!class_exists('ImgTrans', false)) { require_once 'jpgraph_imgtrans.php'; } $tform = new ImgTrans($this->img->img); $this->img->img = $tform->Skew3D($this->iImgTransHorizon, $this->iImgTransSkewDist, $this->iImgTransDirection, $this->iImgTransHighQ, $this->iImgTransMinSize, $this->iImgTransFillColor, $this->iImgTransBorder); } if (!$_csim) { // If the filename is given as the special "__handle" // then the image handler is returned and the image is NOT // streamed back if ($aStrokeFileName == _IMG_HANDLER) { return $this->img->img; } else { // Finally stream the generated picture $this->cache->PutAndStream($this->img, $this->cache_name, $this->inline, $aStrokeFileName); } } }
function Stroke($aStrokeFileName = "") { $_csim = $aStrokeFileName === _CSIM_SPECIALFILE; $this->iHasStroked = true; $n = count($this->plots); if ($this->pieaa) { if (!$_csim) { if ($this->background_image != "") { $this->StrokeFrameBackground(); } else { $this->StrokeFrame(); } } $w = $this->img->width; $h = $this->img->height; $oldimg = $this->img->img; $this->img->CreateImgCanvas(2 * $w, 2 * $h); $this->img->SetColor($this->margin_color); $this->img->FilledRectangle(0, 0, 2 * $w - 1, 2 * $h - 1); $ni = count($this->iIcons); for ($i = 0; $i < $ni; ++$i) { $this->iIcons[$i]->iScale *= 2; if ($this->iIcons[$i]->iX > 1) { $this->iIcons[$i]->iX *= 2; } if ($this->iIcons[$i]->iY > 1) { $this->iIcons[$i]->iY *= 2; } } $this->StrokeIcons(); for ($i = 0; $i < $n; ++$i) { if ($this->plots[$i]->posx > 1) { $this->plots[$i]->posx *= 2; } if ($this->plots[$i]->posy > 1) { $this->plots[$i]->posy *= 2; } $this->plots[$i]->Stroke($this->img, 1); if ($this->plots[$i]->posx > 1) { $this->plots[$i]->posx /= 2; } if ($this->plots[$i]->posy > 1) { $this->plots[$i]->posy /= 2; } } $indent = $this->doframe ? $this->frame_weight + ($this->doshadow ? $this->shadow_width : 0) : 0; $indent += $this->framebevel ? $this->framebeveldepth + 1 : 0; $this->img->CopyCanvasH($oldimg, $this->img->img, $indent, $indent, $indent, $indent, $w - 2 * $indent, $h - 2 * $indent, 2 * ($w - $indent), 2 * ($h - $indent)); $this->img->img = $oldimg; $this->img->width = $w; $this->img->height = $h; for ($i = 0; $i < $n; ++$i) { $this->plots[$i]->Stroke($this->img, 2); $this->plots[$i]->Legend($this); } } else { if (!$_csim) { if ($this->background_image != "") { $this->StrokeFrameBackground(); } else { $this->StrokeFrame(); $this->StrokeBackgroundGrad(); } } $this->StrokeIcons(); for ($i = 0; $i < $n; ++$i) { $this->plots[$i]->Stroke($this->img); $this->plots[$i]->Legend($this); } } $this->legend->Stroke($this->img); $this->footer->Stroke($this->img); $this->StrokeTitles(); if (!$_csim) { if ($this->texts != null) { $n = count($this->texts); for ($i = 0; $i < $n; ++$i) { $this->texts[$i]->Stroke($this->img); } } if (_JPG_DEBUG) { $this->DisplayCSIMAreas(); } if ($this->iImgTrans) { if (!class_exists('ImgTrans')) { require_once 'jpgraph_imgtrans.php'; } $tform = new ImgTrans($this->img->img); $this->img->img = $tform->Skew3D($this->iImgTransHorizon, $this->iImgTransSkewDist, $this->iImgTransDirection, $this->iImgTransHighQ, $this->iImgTransMinSize, $this->iImgTransFillColor, $this->iImgTransBorder); } if ($aStrokeFileName == _IMG_HANDLER) { return $this->img->img; } else { $this->cache->PutAndStream($this->img, $this->cache_name, $this->inline, $aStrokeFileName); } } }
function Stroke($aStrokeFileName = "") { $_csim = $aStrokeFileName === _CSIM_SPECIALFILE; if (!$this->scale->IsRangeSet()) { list($min, $max) = $this->GetBarMinMax(); $this->scale->SetRange($min, $max); } $this->scale->AdjustStartEndDay(); $this->AutoSize(); $this->scale->SetVertLayout($this->iLayout); if ($this->iLayout == GANTT_FROMTOP) { $maxheight = max($this->GetMaxLabelHeight(), $this->GetMaxBarAbsHeight()); $this->scale->SetVertSpacing($maxheight * (1 + $this->iLabelVMarginFactor)); } if ($this->scale->iVertLines == -1) { $this->scale->iVertLines = $this->GetBarMaxLineNumber() + 1; } $maxwidth = max($this->scale->actinfo->GetWidth($this->img), max($this->GetMaxLabelWidth(), $this->scale->tableTitle->GetWidth($this->img))); $this->scale->SetLabelWidth($maxwidth + $this->scale->divider->iWeight); if (!$_csim) { $this->StrokePlotArea(); if ($this->iIconDepth == DEPTH_BACK) { $this->StrokeIcons(); } } $this->scale->Stroke(); if (!$_csim) { $this->img->right_margin--; $this->StrokePlotBox(); $this->img->right_margin++; } $this->hgrid->Stroke($this->img, $this->scale); $n = count($this->iObj); for ($i = 0; $i < $n; ++$i) { $this->iObj[$i]->Stroke($this->img, $this->scale); } $this->StrokeTitles(); if (!$_csim) { $this->StrokeConstrains(); $this->footer->Stroke($this->img); if ($this->iIconDepth == DEPTH_FRONT) { $this->StrokeIcons(); } if ($this->iImgTrans) { if (!class_exists('ImgTrans')) { require_once 'jpgraph_imgtrans.php'; } $tform = new ImgTrans($this->img->img); $this->img->img = $tform->Skew3D($this->iImgTransHorizon, $this->iImgTransSkewDist, $this->iImgTransDirection, $this->iImgTransHighQ, $this->iImgTransMinSize, $this->iImgTransFillColor, $this->iImgTransBorder); } if ($aStrokeFileName == _IMG_HANDLER) { return $this->img->img; } else { $this->cache->PutAndStream($this->img, $this->cache_name, $this->inline, $aStrokeFileName); } } }
function Stroke($aStrokeFileName = "") { $n = count($this->plots); if (!$this->yscale->IsSpecified() && count($this->plots) > 0) { list($min, $max) = $this->GetPlotsYMinMax(); $this->yscale->AutoScale($this->img, 0, $max, $this->len / $this->ytick_factor); } elseif ($this->yscale->IsSpecified() && ($this->yscale->auto_ticks || !$this->yscale->ticks->IsSpecified())) { $min = $this->yscale->scale[0]; $max = $this->yscale->scale[1]; $this->yscale->AutoScale($this->img, $min, $max, $this->len / $this->ytick_factor, $this->yscale->auto_ticks); } $this->yscale->SetConstants($this->posx, $this->len); $nbrpnts = $this->plots[0]->GetCount(); if ($this->axis_title == null) { for ($i = 0; $i < $nbrpnts; ++$i) { $this->axis_title[$i] = $i + 1; } } elseif (count($this->axis_title) < $nbrpnts) { JpGraphError::RaiseL(18007); } for ($i = 0; $i < $n; ++$i) { if ($nbrpnts != $this->plots[$i]->GetCount()) { JpGraphError::RaiseL(18008); } } if ($this->background_image != "") { $this->StrokeFrameBackground(); } else { $this->StrokeFrame(); } $astep = 2 * M_PI / $nbrpnts; for ($i = 0; $i < $n; ++$i) { $this->plots[$i]->Legend($this); } $this->legend->Stroke($this->img); $this->footer->Stroke($this->img); if ($this->grid_depth == DEPTH_BACK) { for ($i = 0, $a = M_PI / 2; $i < $nbrpnts; ++$i, $a += $astep) { $this->axis->Stroke($this->posy, $a, $grid[$i], $this->axis_title[$i], $i == 0); } } $a = M_PI / 2; for ($i = 0; $i < $n; ++$i) { $this->plots[$i]->Stroke($this->img, $this->posy, $this->yscale, $a); } if ($this->grid_depth != DEPTH_BACK) { for ($i = 0, $a = M_PI / 2; $i < $nbrpnts; ++$i, $a += $astep) { $this->axis->Stroke($this->posy, $a, $grid[$i], $this->axis_title[$i], $i == 0); } } $this->grid->Stroke($this->img, $grid); $this->StrokeTitles(); if ($this->texts != null) { foreach ($this->texts as $t) { $t->Stroke($this->img); } } if ($this->iImgTrans) { if (!class_exists('ImgTrans')) { require_once 'jpgraph_imgtrans.php'; } $tform = new ImgTrans($this->img->img); $this->img->img = $tform->Skew3D($this->iImgTransHorizon, $this->iImgTransSkewDist, $this->iImgTransDirection, $this->iImgTransHighQ, $this->iImgTransMinSize, $this->iImgTransFillColor, $this->iImgTransBorder); } if ($aStrokeFileName == _IMG_HANDLER) { return $this->img->img; } else { $this->cache->PutAndStream($this->img, $this->cache_name, $this->inline, $aStrokeFileName); } }
function Stroke($aStrokeFileName = "") { if (empty($this->yscale)) { JpGraphError::RaiseL(25031); } $this->AdjustMarginsForTitles(); if ($this->yscale) { $this->yscale->InitConstants($this->img); } if ($this->xscale) { $this->xscale->InitConstants($this->img); } if ($this->y2scale) { $this->y2scale->InitConstants($this->img); } $n = count($this->ynscale); for ($i = 0; $i < $n; ++$i) { if ($this->ynscale[$i]) { $this->ynscale[$i]->InitConstants($this->img); } } $_csim = $aStrokeFileName === _CSIM_SPECIALFILE; $this->iHasStroked = true; for ($i = 0; $i < count($this->plots); ++$i) { $this->plots[$i]->PreStrokeAdjust($this); $this->plots[$i]->DoLegend($this); } if ($this->y2scale != null) { for ($i = 0; $i < count($this->y2plots); ++$i) { $this->y2plots[$i]->PreStrokeAdjust($this); $this->y2plots[$i]->DoLegend($this); } } $n = count($this->ynaxis); for ($i = 0; $i < $n; ++$i) { if ($this->ynplots == null || $this->ynplots[$i] == null) { JpGraphError::RaiseL(25032, $i); } $m = count($this->ynplots[$i]); for ($j = 0; $j < $m; ++$j) { $this->ynplots[$i][$j]->PreStrokeAdjust($this); $this->ynplots[$i][$j]->DoLegend($this); } } if (!$this->yscale->IsSpecified() && count($this->plots) == 0 || $this->y2scale != null && !$this->y2scale->IsSpecified() && count($this->y2plots) == 0) { JpGraphError::RaiseL(25026); } if (!$this->xscale->IsSpecified() && count($this->plots) == 0 && count($this->y2plots) == 0) { JpGraphError::RaiseL(25034); } if (!$this->yscale->IsSpecified() && count($this->plots) > 0) { list($min, $max) = $this->GetPlotsYMinMax($this->plots); $lres = $this->GetLinesYMinMax($this->lines); if (is_array($lres)) { list($linmin, $linmax) = $lres; $min = min($min, $linmin); $max = max($max, $linmax); } $tres = $this->GetTextsYMinMax(); if (is_array($tres)) { list($tmin, $tmax) = $tres; $min = min($min, $tmin); $max = max($max, $tmax); } $this->yscale->AutoScale($this->img, $min, $max, $this->img->plotheight / $this->ytick_factor); } elseif ($this->yscale->IsSpecified() && ($this->yscale->auto_ticks || !$this->yscale->ticks->IsSpecified())) { $min = $this->yscale->scale[0]; $max = $this->yscale->scale[1]; $this->yscale->AutoScale($this->img, $min, $max, $this->img->plotheight / $this->ytick_factor, $this->yscale->auto_ticks); } if ($this->y2scale != null) { if (!$this->y2scale->IsSpecified() && count($this->y2plots) > 0) { list($min, $max) = $this->GetPlotsYMinMax($this->y2plots); $lres = $this->GetLinesYMinMax($this->y2lines); if (is_array($lres)) { list($linmin, $linmax) = $lres; $min = min($min, $linmin); $max = max($max, $linmax); } $tres = $this->GetTextsYMinMax(true); if (is_array($tres)) { list($tmin, $tmax) = $tres; $min = min($min, $tmin); $max = max($max, $tmax); } $this->y2scale->AutoScale($this->img, $min, $max, $this->img->plotheight / $this->ytick_factor); } elseif ($this->y2scale->IsSpecified() && ($this->y2scale->auto_ticks || !$this->y2scale->ticks->IsSpecified())) { $min = $this->y2scale->scale[0]; $max = $this->y2scale->scale[1]; $this->y2scale->AutoScale($this->img, $min, $max, $this->img->plotheight / $this->ytick_factor, $this->y2scale->auto_ticks); } } $n = count($this->ynaxis); for ($i = 0; $i < $n; ++$i) { if ($this->ynscale[$i] != null) { if (!$this->ynscale[$i]->IsSpecified() && count($this->ynplots[$i]) > 0) { list($min, $max) = $this->GetPlotsYMinMax($this->ynplots[$i]); $this->ynscale[$i]->AutoScale($this->img, $min, $max, $this->img->plotheight / $this->ytick_factor); } elseif ($this->ynscale[$i]->IsSpecified() && ($this->ynscale[$i]->auto_ticks || !$this->ynscale[$i]->ticks->IsSpecified())) { $min = $this->ynscale[$i]->scale[0]; $max = $this->ynscale[$i]->scale[1]; $this->ynscale[$i]->AutoScale($this->img, $min, $max, $this->img->plotheight / $this->ytick_factor, $this->ynscale[$i]->auto_ticks); } } } if (!$this->xscale->IsSpecified()) { if (substr($this->axtype, 0, 4) == "text") { $max = 0; $n = count($this->plots); for ($i = 0; $i < $n; ++$i) { $p = $this->plots[$i]; if (is_a($p, 'BarPlot') || empty($p->barcenter)) { $max = max($max, $p->numpoints - 1); } else { $max = max($max, $p->numpoints); } } $min = 0; if ($this->y2axis != null) { foreach ($this->y2plots as $p) { $max = max($max, $p->numpoints - 1); } } $n = count($this->ynaxis); for ($i = 0; $i < $n; ++$i) { if ($this->ynaxis[$i] != null) { foreach ($this->ynplots[$i] as $p) { $max = max($max, $p->numpoints - 1); } } } $this->xscale->Update($this->img, $min, $max); $this->xscale->ticks->Set($this->xaxis->tick_step, 1); $this->xscale->ticks->SupressMinorTickMarks(); } else { list($min, $max) = $this->GetXMinMax(); $lres = $this->GetLinesXMinMax($this->lines); if ($lres) { list($linmin, $linmax) = $lres; $min = min($min, $linmin); $max = max($max, $linmax); } $lres = $this->GetLinesXMinMax($this->y2lines); if ($lres) { list($linmin, $linmax) = $lres; $min = min($min, $linmin); $max = max($max, $linmax); } $tres = $this->GetTextsXMinMax(); if ($tres) { list($tmin, $tmax) = $tres; $min = min($min, $tmin); $max = max($max, $tmax); } $tres = $this->GetTextsXMinMax(true); if ($tres) { list($tmin, $tmax) = $tres; $min = min($min, $tmin); $max = max($max, $tmax); } $this->xscale->AutoScale($this->img, $min, $max, round($this->img->plotwidth / $this->xtick_factor)); } if (!is_numeric($this->yaxis->pos) && !is_string($this->yaxis->pos)) { $this->yaxis->SetPos($this->xscale->GetMinVal()); } if ($this->y2axis != null) { if (!is_numeric($this->y2axis->pos) && !is_string($this->y2axis->pos)) { $this->y2axis->SetPos($this->xscale->GetMaxVal()); } $this->y2axis->SetTitleSide(SIDE_RIGHT); } $n = count($this->ynaxis); $nY2adj = $this->y2axis != null ? $this->iYAxisDeltaPos : 0; for ($i = 0; $i < $n; ++$i) { if ($this->ynaxis[$i] != null) { if (!is_numeric($this->ynaxis[$i]->pos) && !is_string($this->ynaxis[$i]->pos)) { $this->ynaxis[$i]->SetPos($this->xscale->GetMaxVal()); $this->ynaxis[$i]->SetPosAbsDelta($i * $this->iYAxisDeltaPos + $nY2adj); } $this->ynaxis[$i]->SetTitleSide(SIDE_RIGHT); } } } elseif ($this->xscale->IsSpecified() && ($this->xscale->auto_ticks || !$this->xscale->ticks->IsSpecified())) { $min = $this->xscale->scale[0]; $max = $this->xscale->scale[1]; $this->xscale->AutoScale($this->img, $min, $max, $this->img->plotwidth / $this->xtick_factor, false); if ($this->y2axis != null) { if (!is_numeric($this->y2axis->pos) && !is_string($this->y2axis->pos)) { $this->y2axis->SetPos($this->xscale->GetMaxVal()); } $this->y2axis->SetTitleSide(SIDE_RIGHT); } } if (($this->yaxis->pos == $this->xscale->GetMinVal() || is_string($this->yaxis->pos) && $this->yaxis->pos == 'min') && !is_numeric($this->xaxis->pos) && $this->yscale->GetMinVal() < 0 && substr($this->axtype, 0, 4) != 'text' && $this->xaxis->pos != "min") { $this->xscale->ticks->SupressFirst(); if ($this->y2axis != null) { $this->xscale->ticks->SupressLast(); } } elseif (!is_numeric($this->yaxis->pos) && $this->yaxis->pos == 'max') { $this->xscale->ticks->SupressLast(); } if (!$_csim) { $this->StrokePlotArea(); if ($this->iIconDepth == DEPTH_BACK) { $this->StrokeIcons(); } } $this->StrokeAxis(false); if ($this->bands != null && !$_csim) { for ($i = 0; $i < count($this->bands); ++$i) { if ($this->bands[$i]->depth == DEPTH_BACK) { $this->bands[$i]->Stroke($this->img, $this->xscale, $this->yscale); } } } if ($this->y2bands != null && $this->y2scale != null && !$_csim) { for ($i = 0; $i < count($this->y2bands); ++$i) { if ($this->y2bands[$i]->depth == DEPTH_BACK) { $this->y2bands[$i]->Stroke($this->img, $this->xscale, $this->y2scale); } } } if ($this->grid_depth == DEPTH_BACK && !$_csim) { $this->ygrid->Stroke(); $this->xgrid->Stroke(); } if ($this->y2axis != null && !$_csim) { $this->y2axis->Stroke($this->xscale); $this->y2grid->Stroke(); } $n = count($this->ynaxis); for ($i = 0; $i < $n; ++$i) { $this->ynaxis[$i]->Stroke($this->xscale); } $oldoff = $this->xscale->off; if (substr($this->axtype, 0, 4) == "text") { if ($this->text_scale_abscenteroff > -1) { $this->xscale->off += round($this->xscale->scale_factor / 2) - round($this->text_scale_abscenteroff / 2); } else { $this->xscale->off += ceil($this->xscale->scale_factor * $this->text_scale_off * $this->xscale->ticks->minor_step); } } if ($this->iDoClipping) { $oldimage = $this->img->CloneCanvasH(); } if (!$this->y2orderback) { for ($i = 0; $i < count($this->plots); ++$i) { $this->plots[$i]->Stroke($this->img, $this->xscale, $this->yscale); $this->plots[$i]->StrokeMargin($this->img); } } if ($this->y2scale != null) { for ($i = 0; $i < count($this->y2plots); ++$i) { $this->y2plots[$i]->Stroke($this->img, $this->xscale, $this->y2scale); } } if ($this->y2orderback) { for ($i = 0; $i < count($this->plots); ++$i) { $this->plots[$i]->Stroke($this->img, $this->xscale, $this->yscale); $this->plots[$i]->StrokeMargin($this->img); } } $n = count($this->ynaxis); for ($i = 0; $i < $n; ++$i) { $m = count($this->ynplots[$i]); for ($j = 0; $j < $m; ++$j) { $this->ynplots[$i][$j]->Stroke($this->img, $this->xscale, $this->ynscale[$i]); $this->ynplots[$i][$j]->StrokeMargin($this->img); } } if ($this->iIconDepth == DEPTH_FRONT) { $this->StrokeIcons(); } if ($this->iDoClipping) { if ($this->img->a == 0) { $this->img->CopyCanvasH($oldimage, $this->img->img, $this->img->left_margin, $this->img->top_margin, $this->img->left_margin, $this->img->top_margin, $this->img->plotwidth + 1, $this->img->plotheight); } elseif ($this->img->a == 90) { $adj = ($this->img->height - $this->img->width) / 2; $this->img->CopyCanvasH($oldimage, $this->img->img, $this->img->bottom_margin - $adj, $this->img->left_margin + $adj, $this->img->bottom_margin - $adj, $this->img->left_margin + $adj, $this->img->plotheight + 1, $this->img->plotwidth); } else { JpGraphError::RaiseL(25035, $this->img->a); } $this->img->Destroy(); $this->img->SetCanvasH($oldimage); } $this->xscale->off = $oldoff; if ($this->grid_depth == DEPTH_FRONT && !$_csim) { $this->ygrid->Stroke(); $this->xgrid->Stroke(); } if ($this->bands != null) { for ($i = 0; $i < count($this->bands); ++$i) { if ($this->bands[$i]->depth == DEPTH_FRONT) { $this->bands[$i]->Stroke($this->img, $this->xscale, $this->yscale); } } } if ($this->y2bands != null && $this->y2scale != null) { for ($i = 0; $i < count($this->y2bands); ++$i) { if ($this->y2bands[$i]->depth == DEPTH_FRONT) { $this->y2bands[$i]->Stroke($this->img, $this->xscale, $this->y2scale); } } } if ($this->lines != null) { for ($i = 0; $i < count($this->lines); ++$i) { $this->lines[$i]->Stroke($this->img, $this->xscale, $this->yscale); $this->lines[$i]->DoLegend($this); } } if ($this->y2lines != null && $this->y2scale != null) { for ($i = 0; $i < count($this->y2lines); ++$i) { $this->y2lines[$i]->Stroke($this->img, $this->xscale, $this->y2scale); $this->y2lines[$i]->DoLegend($this); } } if (!$_csim) { $this->StrokeAxis(); } if ($this->y2scale != null && !$_csim) { $this->y2axis->Stroke($this->xscale, false); } if (!$_csim) { $this->StrokePlotBox(); } $aa = $this->img->SetAngle(0); $this->StrokeTitles(); $this->footer->Stroke($this->img); $this->legend->Stroke($this->img); $this->img->SetAngle($aa); $this->StrokeTexts(); $this->StrokeTables(); if (!$_csim) { $this->img->SetAngle($aa); if (_JPG_DEBUG) { $this->DisplayClientSideaImageMapAreas(); } if ($this->iImgTrans) { if (!class_exists('ImgTrans')) { require_once 'jpgraph_imgtrans.php'; } $tform = new ImgTrans($this->img->img); $this->img->img = $tform->Skew3D($this->iImgTransHorizon, $this->iImgTransSkewDist, $this->iImgTransDirection, $this->iImgTransHighQ, $this->iImgTransMinSize, $this->iImgTransFillColor, $this->iImgTransBorder); } if ($aStrokeFileName == _IMG_HANDLER) { return $this->img->img; } else { $this->cache->PutAndStream($this->img, $this->cache_name, $this->inline, $aStrokeFileName); } } }