本文整理汇总了PHP中JpGraphError::Raise方法的典型用法代码示例。如果您正苦于以下问题:PHP JpGraphError::Raise方法的具体用法?PHP JpGraphError::Raise怎么用?PHP JpGraphError::Raise使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JpGraphError
的用法示例。
在下文中一共展示了JpGraphError::Raise方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: mydie
function mydie($errno, $errstr = '', $errfile = '', $errline = '')
{
global $conf;
$jpgraph = $conf->get_conf('jpgraph_path');
include_once "{$jpgraph}/jpgraph.php";
$err = $errstr ? $errstr : $errno;
if ($errfile) {
switch ($errno) {
case 1:
$errprefix = 'Error';
break;
case 2:
$errprefix = 'Warning';
break;
case 8:
$errprefix = 'Notice';
break;
default:
return;
// dont show E_STRICT errors
}
$err = "{$errprefix}: {$err} in '{$errfile}' line {$errline}";
}
$error = new JpGraphError();
$error->Raise($err);
echo "{$err}";
exit;
}
示例2: Stroke
function Stroke(&$img, &$xscale, &$yscale)
{
$numpoints = count($this->coords[0]) / 2;
$img->SetColor($this->color);
$img->SetLineWeight($this->weight);
if (isset($this->coords[1])) {
if (count($this->coords[1]) != $numpoints) {
JpGraphError::Raise("Number of X and Y points are not equal. Number of X-points:" . count($this->coords[1]) . " Number of Y-points:{$numpoints}");
} else {
$exist_x = true;
}
} else {
$exist_x = false;
}
if ($exist_x) {
$xs = $this->coords[1][0];
} else {
$xs = 0;
}
for ($i = 0; $i < $numpoints; ++$i) {
if ($exist_x) {
$x = $this->coords[1][$i];
} else {
$x = $i;
}
$xt = $xscale->Translate($x);
$yt1 = $yscale->Translate($this->coords[0][$i * 2]);
$yt2 = $yscale->Translate($this->coords[0][$i * 2 + 1]);
$img->Line($xt, $yt1, $xt, $yt2);
$img->Line($xt - $this->errwidth, $yt1, $xt + $this->errwidth, $yt1);
$img->Line($xt - $this->errwidth, $yt2, $xt + $this->errwidth, $yt2);
}
return true;
}
示例3: ScatterPlot
function ScatterPlot(&$datay, $datax = false)
{
if (count($datax) != count($datay) && is_array($datax)) {
JpGraphError::Raise("Scatterplot must have equal number of X and Y points.");
}
$this->Plot($datay, $datax);
$this->mark = new PlotMark();
$this->mark->SetType(MARK_CIRCLE);
$this->mark->SetColor($this->color);
}
示例4: execute
function execute()
{
$this->set_title($this->lang->stats);
$this->tree($this->lang->stats);
include '../lib/jpgraph/jpgraph.php';
include '../lib/jpgraph/jpgraph_bar.php';
if (!defined('IMG_PNG')) {
JpGraphError::Raise("This PHP installation is not configured with PNG support. Please recompile PHP with GD and JPEG support to run JpGraph. (Constant IMG_PNG does not exist)");
}
/**
* Posts
*/
$query = $this->db->query("SELECT COUNT(post_id) AS posts, FROM_UNIXTIME(post_time, '%%b %%y') AS month\n\t\t\tFROM %pposts GROUP BY month\tORDER BY post_time");
$data = array();
while ($item = $this->db->nqfetch($query)) {
$data[$item['month']] = $item['posts'];
}
if (!$data) {
$data = array(0, 0);
}
$graph = new Graph(400, 300, 'auto');
$graph->SetScale('textint');
$graph->SetColor('aliceblue');
$graph->SetMarginColor('white');
$graph->xaxis->SetTickLabels(array_keys($data));
$graph->yaxis->scale->SetGrace(20);
$graph->title->Set($this->lang->stats_post_by_month);
$temp = array_values($data);
$barplot = new BarPlot($temp);
$barplot->SetFillColor('darkorange');
$graph->add($barplot);
$graph->Stroke("../stats/{$this->time}1.png");
/**
* Registrations
*/
$query = $this->db->query("SELECT COUNT(user_id) AS users, FROM_UNIXTIME(user_joined, '%%b %%y') AS month\n\t\t\tFROM %pusers\n\t\t\tWHERE user_joined != 0\n\t\t\tGROUP BY month\n\t\t\tORDER BY user_joined");
$data = array();
while ($item = $this->db->nqfetch($query)) {
$data[$item['month']] = $item['users'];
}
$graph = new Graph(400, 300, 'auto');
$graph->SetScale('textint');
$graph->SetColor('aliceblue');
$graph->SetMarginColor('white');
$graph->xaxis->SetTickLabels(array_keys($data));
$graph->yaxis->scale->SetGrace(20);
$graph->title->Set($this->lang->stats_reg_by_month);
$temp = array_values($data);
$barplot = new BarPlot($temp);
$barplot->SetFillColor('darkorange');
$graph->add($barplot);
$graph->Stroke("../stats/{$this->time}2.png");
return $this->message($this->lang->stats, "<img src='../stats/{$this->time}1.png' alt='{$this->lang->stats_post_by_month}' /><br /><br />\n\t\t<img src='../stats/{$this->time}2.png' alt='{$this->lang->stats_reg_by_month}' />");
}
示例5: Translate
function Translate($a)
{
if ($a < 0) {
JpGraphError::Raise("Negative data values can not be used in a log scale.");
exit(1);
}
if ($a == 0) {
$a = 1;
}
$a = log10($a);
return floor($this->off + ($a * 1.0 - $this->scale[0]) * $this->scale_factor);
}
示例6: Interpolate
function Interpolate($xpoint)
{
$max = $this->n - 1;
$min = 0;
// Binary search to find interval
while ($max - $min > 1) {
$k = ($max + $min) / 2;
if ($this->xdata[$k] > $xpoint) {
$max = $k;
} else {
$min = $k;
}
}
// Each interval is interpolated by a 3:degree polynom function
$h = $this->xdata[$max] - $this->xdata[$min];
if ($h == 0) {
JpGraphError::Raise('Invalid input data for spline. Two or more consecutive input X-values are equal. Each input X-value must differ since from a mathematical point of view it must be a one-to-one mapping, i.e. each X-value must correspond to exactly one Y-value.');
}
$a = ($this->xdata[$max] - $xpoint) / $h;
$b = ($xpoint - $this->xdata[$min]) / $h;
return $a * $this->ydata[$min] + $b * $this->ydata[$max] + (($a * $a * $a - $a) * $this->y2[$min] + ($b * $b * $b - $b) * $this->y2[$max]) * ($h * $h) / 6.0;
}
示例7: Stroke
function Stroke($aImg)
{
if ($this->iFile != '' && $this->iCountryFlag != '') {
JpGraphError::Raise('It is not possible to specify both an image file and a country flag for the same icon.');
}
if ($this->iFile != '') {
$gdimg = Graph::LoadBkgImage('', $this->iFile);
} else {
if (!class_exists('FlagImages')) {
JpGraphError::Raise('In order to use Country flags as icons you must include the "jpgraph_flags.php" file.');
}
$fobj = new FlagImages($this->iCountryStdSize);
$dummy = '';
$gdimg = $fobj->GetImgByName($this->iCountryFlag, $dummy);
}
if ($this->iX >= 0 && $this->iX <= 1.0) {
$w = imagesx($aImg->img);
$this->iX = round($w * $this->iX);
}
if ($this->iY >= 0 && $this->iY <= 1.0) {
$h = imagesy($aImg->img);
$this->iY = round($h * $this->iY);
}
$iconw = imagesx($gdimg);
$iconh = imagesy($gdimg);
if ($this->iHorAnchor == 'center') {
$this->iX -= round($iconw * $this->iScale / 2);
}
if ($this->iHorAnchor == 'right') {
$this->iX -= round($iconw * $this->iScale);
}
if ($this->iVertAnchor == 'center') {
$this->iY -= round($iconh * $this->iScale / 2);
}
if ($this->iVertAnchor == 'bottom') {
$this->iY -= round($iconh * $this->iScale);
}
$aImg->CopyMerge($gdimg, $this->iX, $this->iY, 0, 0, round($iconw * $this->iScale), round($iconh * $this->iScale), $iconw, $iconh, $this->iMix);
}
示例8: Stroke
function Stroke($aStrokeFileName = "")
{
// 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::Raise("JpGraph: Number of titles does not match number of points in plot.");
}
for ($i = 0; $i < count($this->plots); ++$i) {
if ($nbrpnts != $this->plots[$i]->GetCount()) {
JpGraphError::Raise("JpGraph: Each spider plot must have the same number of data points.");
}
}
$this->StrokeFrame();
$astep = 2 * M_PI / $nbrpnts;
// Prepare legends
for ($i = 0; $i < count($this->plots); ++$i) {
$this->plots[$i]->Legend($this);
}
$this->legend->Stroke($this->img);
// Plot points
$a = M_PI / 2;
for ($i = 0; $i < count($this->plots); ++$i) {
$this->plots[$i]->Stroke($this->img, $this->posy, $this->yscale, $a);
}
// 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->title->Center($this->img->left_margin, $this->img->width - $this->img->right_margin, 5);
$this->title->Stroke($this->img);
// Stroke texts
if ($this->texts != null) {
foreach ($this->texts as $t) {
$t->Stroke($this->img);
}
}
// Finally output the image
$this->cache->PutAndStream($this->img, $this->cache_name, $this->inline, $aStrokeFileName);
}
示例9: Stroke
function Stroke($aImg)
{
// The way the path for the arrow is constructed is partly based
// on some heuristics. This is not an exact science but draws the
// path in a way that, for me, makes esthetic sence. For example
// if the start and end activities are very close we make a small
// detour to endter the target horixontally. If there are more
// space between axctivities then no suh detour is made and the
// target is "hit" directly vertical. I have tried to keep this
// simple. no doubt this could become almost infinitive complex
// and have some real AI. Feel free to modify this.
// This will no-doubt be tweaked as times go by. One design aim
// is to avoid having the user choose what types of arrow
// he wants.
// The arrow is drawn between (x1,y1) to (x2,y2)
$x1 = $this->ix1;
$x2 = $this->ix2;
$y1 = $this->iy1;
$y2 = $this->iy2;
// Depending on if the target is below or above we have to
// handle thi different.
if ($y2 > $y1) {
$arrowtype = ARROW_DOWN;
$midy = round(($y2 - $y1) / 2 + $y1);
if ($x2 > $x1) {
switch ($this->iPathType) {
case 0:
$c = array($x1, $y1, $x1, $midy, $x2, $midy, $x2, $y2);
break;
case 1:
case 2:
case 3:
$c = array($x1, $y1, $x2, $y1, $x2, $y2);
break;
default:
JpGraphError::Raise('Internal error: Unknown path type (=' . $this->iPathType . ') specified for link.');
exit(1);
break;
}
} else {
switch ($this->iPathType) {
case 0:
case 1:
$c = array($x1, $y1, $x1, $midy, $x2, $midy, $x2, $y2);
break;
case 2:
// Always extend out horizontally a bit from the first point
// If we draw a link back in time (end to start) and the bars
// are very close we also change the path so it comes in from
// the left on the activity
$c = array($x1, $y1, $x1 + $this->iPathExtend, $y1, $x1 + $this->iPathExtend, $midy, $x2, $midy, $x2, $y2);
break;
case 3:
if ($y2 - $midy < 6) {
$c = array($x1, $y1, $x1, $midy, $x2 - $this->iPathExtend, $midy, $x2 - $this->iPathExtend, $y2, $x2, $y2);
$arrowtype = ARROW_RIGHT;
} else {
$c = array($x1, $y1, $x1, $midy, $x2, $midy, $x2, $y2);
}
break;
default:
JpGraphError::Raise('Internal error: Unknown path type specified for link.');
exit(1);
break;
}
}
$arrow = new LinkArrow($x2, $y2, $arrowtype);
} else {
// Y2 < Y1
$arrowtype = ARROW_UP;
$midy = round(($y1 - $y2) / 2 + $y2);
if ($x2 > $x1) {
switch ($this->iPathType) {
case 0:
case 1:
$c = array($x1, $y1, $x1, $midy, $x2, $midy, $x2, $y2);
break;
case 3:
if ($midy - $y2 < 8) {
$arrowtype = ARROW_RIGHT;
$c = array($x1, $y1, $x1, $y2, $x2, $y2);
} else {
$c = array($x1, $y1, $x1, $midy, $x2, $midy, $x2, $y2);
}
break;
default:
JpGraphError::Raise('Internal error: Unknown path type specified for link.');
break;
}
} else {
switch ($this->iPathType) {
case 0:
case 1:
$c = array($x1, $y1, $x1, $midy, $x2, $midy, $x2, $y2);
break;
case 2:
// Always extend out horizontally a bit from the first point
$c = array($x1, $y1, $x1 + $this->iPathExtend, $y1, $x1 + $this->iPathExtend, $midy, $x2, $midy, $x2, $y2);
break;
case 3:
//.........这里部分代码省略.........
示例10: Stroke
function Stroke(&$img, &$xscale, &$yscale)
{
$numpoints = count($this->coords[0]);
if (isset($this->coords[1])) {
if (count($this->coords[1]) != $numpoints) {
JpGraphError::Raise("Number of X and Y points are not equal. Number of X-points:" . count($this->coords[1]) . " Number of Y-points:{$numpoints}");
} else {
$exist_x = true;
}
} else {
$exist_x = false;
}
if ($exist_x) {
$xs = $this->coords[1][0];
} else {
$xs = 0;
}
$img->SetStartPoint($xscale->Translate($xs), $yscale->Translate($this->coords[0][0]));
if ($this->filled) {
$cord[] = $xscale->Translate($xs);
$cord[] = $yscale->Translate($yscale->GetMinVal());
}
$xt = $xscale->Translate($xs);
$yt = $yscale->Translate($this->coords[0][0]);
$cord[] = $xt;
$cord[] = $yt;
$yt_old = $yt;
$this->value->Stroke($img, $this->coords[0][0], $xt, $yt);
$img->SetColor($this->color);
$img->SetLineWeight($this->weight);
$img->SetLineStyle($this->line_style);
for ($pnts = 1; $pnts < $numpoints; ++$pnts) {
if ($exist_x) {
$x = $this->coords[1][$pnts];
} else {
$x = $pnts;
}
$xt = $xscale->Translate($x);
$yt = $yscale->Translate($this->coords[0][$pnts]);
if ($this->step_style) {
$img->StyleLineTo($xt, $yt_old);
$img->StyleLineTo($xt, $yt);
$cord[] = $xt;
$cord[] = $yt_old;
$cord[] = $xt;
$cord[] = $yt;
} else {
$cord[] = $xt;
$cord[] = $yt;
$y = $this->coords[0][$pnts];
if (is_numeric($y) || is_string($y) && $y != "-") {
$tmp1 = $this->coords[0][$pnts];
$tmp2 = $this->coords[0][$pnts - 1];
if (is_numeric($tmp1) && (is_numeric($tmp2) || $tmp2 == "-")) {
$img->StyleLineTo($xt, $yt);
} else {
$img->SetStartPoint($xt, $yt);
}
}
}
$yt_old = $yt;
$this->StrokeDataValue($img, $this->coords[0][$pnts], $xt, $yt);
}
if ($this->filled) {
$cord[] = $xt;
$cord[] = $yscale->Translate($yscale->GetMinVal());
$img->SetColor($this->fill_color);
$img->FilledPolygon($cord);
$img->SetColor($this->color);
$img->Polygon($cord);
}
if (!empty($this->filledAreas)) {
$minY = $yscale->Translate($yscale->GetMinVal());
$factor = $this->step_style ? 4 : 2;
for ($i = 0; $i < sizeof($this->filledAreas); ++$i) {
// go through all filled area elements ordered by insertion
// fill polygon array
$areaCoords[] = $cord[$this->filledAreas[$i][0] * $factor];
$areaCoords[] = $minY;
$areaCoords = array_merge($areaCoords, array_slice($cord, $this->filledAreas[$i][0] * $factor, ($this->filledAreas[$i][1] - $this->filledAreas[$i][0] + ($this->step_style ? 0 : 1)) * $factor));
$areaCoords[] = $areaCoords[sizeof($areaCoords) - 2];
// last x
$areaCoords[] = $minY;
// last y
if ($this->filledAreas[$i][3]) {
$img->SetColor($this->filledAreas[$i][2]);
$img->FilledPolygon($areaCoords);
$img->SetColor($this->color);
}
$img->Polygon($areaCoords);
$areaCoords = array();
}
}
$adjust = 0;
if ($this->filled) {
$adjust = 2;
}
$factor = 1;
if ($this->step_style) {
$factor = 2;
//.........这里部分代码省略.........
示例11: _chkR
function _chkR($aRow)
{
if (!$this->iInit) {
JpGraphError::Raise(27014);
// Table not initialized
}
if ($aRow < 0 || $aRow >= $this->iSize[0]) {
JpGraphError::RaiseL(27007, $aRow);
}
//("GTextTable:\nRow argument ($aRow) is outside specified table size.");
}
示例12: Stroke
function Stroke(&$img)
{
$colors = array_keys($img->rgb->rgb_table);
sort($colors);
$ta = $this->themearr[$this->theme];
if ($this->setslicecolors == null) {
$numcolors = count($ta);
} else {
$numcolors = count($this->setslicecolors);
}
// Draw the slices
$sum = 0;
$n = count($this->data);
for ($i = 0; $i < $n; ++$i) {
$sum += $this->data[$i];
}
// Bail out with error if the sum is 0
if ($sum == 0) {
JpGraphError::Raise("Sum of all data is 0 for Pie.");
}
// Format the titles for each slice
for ($i = 0; $i < count($this->data); ++$i) {
if ($this->labeltype == 0) {
if ($sum != 0) {
$l = 100.0 * $this->data[$i] / $sum;
} else {
$l = 0.0;
}
} else {
$l = $this->data[$i] * 1.0;
}
if (isset($this->labels[$i]) && is_string($this->labels[$i])) {
$this->labels[$i] = sprintf($this->labels[$i], $l);
} else {
$this->labels[$i] = $l;
}
}
// Set up the pie-circle
if ($this->radius < 1) {
$this->radius = floor($this->radius * min($img->width, $img->height));
} else {
$this->radius = $this->radius;
}
$xc = round($this->posx * $img->width);
$yc = round($this->posy * $img->height);
$this->startangle = $this->startangle * M_PI / 180;
if ($this->explode_all) {
for ($i = 0; $i < count($this->data); ++$i) {
$this->explode_radius[$i] = $this->explode_r;
}
}
$n = count($this->data);
if ($this->ishadowcolor != "") {
$accsum = 0;
$angle2 = $this->startangle;
$img->SetColor($this->ishadowcolor);
for ($i = 0; $sum > 0 && $i < $n; ++$i) {
$d = $this->data[$i];
$angle1 = $angle2;
$accsum += $d;
$angle2 = $this->startangle + 2 * M_PI * $accsum / $sum;
if (empty($this->explode_radius[$i])) {
$this->explode_radius[$i] = 0;
}
$la = 2 * M_PI - (abs($angle2 - $angle1) / 2.0 + $angle1);
$xcm = $xc + $this->explode_radius[$i] * cos($la);
$ycm = $yc - $this->explode_radius[$i] * sin($la);
$xcm += $this->ishadowdrop;
$ycm += $this->ishadowdrop;
$img->CakeSlice($xcm, $ycm, $this->radius, $this->radius, $angle1 * 180 / M_PI, $angle2 * 180 / M_PI, $this->ishadowcolor);
}
}
$accsum = 0;
$angle2 = $this->startangle;
$img->SetColor($this->color);
for ($i = 0; $sum > 0 && $i < $n; ++$i) {
$d = $this->data[$i];
$angle1 = $angle2;
$accsum += $d;
$angle2 = $this->startangle + 2 * M_PI * $accsum / $sum;
if ($this->setslicecolors == null) {
$slicecolor = $colors[$ta[$i % $numcolors]];
} else {
$slicecolor = $this->setslicecolors[$i % $numcolors];
}
if ($this->pie_interior_border) {
$img->SetColor($this->color);
} else {
$img->SetColor($slicecolor);
}
$arccolor = $this->pie_border ? $this->color : "";
$this->la[$i] = 2 * M_PI - (abs($angle2 - $angle1) / 2.0 + $angle1);
if (empty($this->explode_radius[$i])) {
$this->explode_radius[$i] = 0;
}
$xcm = $xc + $this->explode_radius[$i] * cos($this->la[$i]);
$ycm = $yc - $this->explode_radius[$i] * sin($this->la[$i]);
$img->CakeSlice($xcm, $ycm, $this->radius - 1, $this->radius - 1, $angle1 * 180 / M_PI, $angle2 * 180 / M_PI, $slicecolor, $arccolor);
if ($this->csimtargets) {
$this->AddSliceToCSIM($i, $xcm, $ycm, $this->radius, $angle1, $angle2);
//.........这里部分代码省略.........
示例13: AutoScale
function AutoScale($img, $min, $max, $maxsteps, $majend = true)
{
if (!is_numeric($min) || !is_numeric($max)) {
JpGraphError::Raise(25044);
}
if ($this->intscale) {
$this->IntAutoScale($img, $min, $max, $maxsteps, $majend);
return;
}
if (abs($min - $max) < 1.0E-5) {
// We need some difference to be able to autoscale
// make it 5% above and 5% below value
if ($min == 0 && $max == 0) {
// Special case
$min = -1;
$max = 1;
} else {
$delta = (abs($max) + abs($min)) * 0.005;
$min -= $delta;
$max += $delta;
}
}
$gracetop = $this->gracetop / 100.0 * abs($max - $min);
$gracebottom = $this->gracebottom / 100.0 * abs($max - $min);
if (is_numeric($this->autoscale_min)) {
$min = $this->autoscale_min;
if ($min >= $max) {
JpGraphError::RaiseL(25071);
//('You have specified a min value with SetAutoMin() which is larger than the maximum value used for the scale. This is not possible.');
}
if (abs($min - $max) < 0.001) {
$max *= 1.2;
}
}
if (is_numeric($this->autoscale_max)) {
$max = $this->autoscale_max;
if ($min >= $max) {
JpGraphError::RaiseL(25072);
//('You have specified a max value with SetAutoMax() which is smaller than the miminum value used for the scale. This is not possible.');
}
if (abs($min - $max) < 0.001) {
$min *= 0.8;
}
}
$min -= $gracebottom;
$max += $gracetop;
// First get tickmarks as multiples of 0.1, 1, 10, ...
if ($majend) {
list($num1steps, $adj1min, $adj1max, $min1step, $maj1step) = $this->CalcTicks($maxsteps, $min, $max, 1, 2);
} else {
$adj1min = $min;
$adj1max = $max;
list($num1steps, $min1step, $maj1step) = $this->CalcTicksFreeze($maxsteps, $min, $max, 1, 2, false);
}
// Then get tick marks as 2:s 0.2, 2, 20, ...
if ($majend) {
list($num2steps, $adj2min, $adj2max, $min2step, $maj2step) = $this->CalcTicks($maxsteps, $min, $max, 5, 2);
} else {
$adj2min = $min;
$adj2max = $max;
list($num2steps, $min2step, $maj2step) = $this->CalcTicksFreeze($maxsteps, $min, $max, 5, 2, false);
}
// Then get tickmarks as 5:s 0.05, 0.5, 5, 50, ...
if ($majend) {
list($num5steps, $adj5min, $adj5max, $min5step, $maj5step) = $this->CalcTicks($maxsteps, $min, $max, 2, 5);
} else {
$adj5min = $min;
$adj5max = $max;
list($num5steps, $min5step, $maj5step) = $this->CalcTicksFreeze($maxsteps, $min, $max, 2, 5, false);
}
// Check to see whichof 1:s, 2:s or 5:s fit better with
// the requested number of major ticks
$match1 = abs($num1steps - $maxsteps);
$match2 = abs($num2steps - $maxsteps);
$match5 = abs($num5steps - $maxsteps);
// Compare these three values and see which is the closest match
// We use a 0.8 weight to gravitate towards multiple of 5:s
$r = $this->MatchMin3($match1, $match2, $match5, 0.8);
switch ($r) {
case 1:
$this->Update($img, $adj1min, $adj1max);
$this->ticks->Set($maj1step, $min1step);
break;
case 2:
$this->Update($img, $adj2min, $adj2max);
$this->ticks->Set($maj2step, $min2step);
break;
case 3:
$this->Update($img, $adj5min, $adj5max);
$this->ticks->Set($maj5step, $min5step);
break;
}
}
示例14: Stroke
//.........这里部分代码省略.........
$x -= $abswidth / 2;
} elseif ($this->align == "right") {
$x -= $abswidth;
}
}
$pts = array($x, $zp, $x, $yscale->Translate($this->coords[0][$i]), $x + $abswidth, $yscale->Translate($this->coords[0][$i]), $x + $abswidth, $zp);
if ($this->grad) {
$grad = new Gradient($img);
$grad->FilledRectangle($pts[2], $pts[3], $pts[6], $pts[7], $this->grad_fromcolor, $this->grad_tocolor, $this->grad_style);
} elseif (!empty($this->fill_color)) {
if (is_array($this->fill_color)) {
$img->PushColor($this->fill_color[$i % count($this->fill_color)]);
} else {
$img->PushColor($this->fill_color);
}
$img->FilledPolygon($pts);
$img->PopColor();
}
// Remember value of this bar
$val = $this->coords[0][$i];
if ($this->bar_shadow && $val != 0) {
$ssh = $this->bar_shadow_hsize;
$ssv = $this->bar_shadow_vsize;
// Create points to create a "upper-right" shadow
if ($val > 0) {
$sp[0] = $pts[6];
$sp[1] = $pts[7];
$sp[2] = $pts[4];
$sp[3] = $pts[5];
$sp[4] = $pts[2];
$sp[5] = $pts[3];
$sp[6] = $pts[2] + $ssh;
$sp[7] = $pts[3] - $ssv;
$sp[8] = $pts[4] + $ssh;
$sp[9] = $pts[5] - $ssv;
$sp[10] = $pts[6] + $ssh;
$sp[11] = $pts[7] - $ssv;
} elseif ($val < 0) {
$sp[0] = $pts[4];
$sp[1] = $pts[5];
$sp[2] = $pts[6];
$sp[3] = $pts[7];
$sp[4] = $pts[0];
$sp[5] = $pts[1];
$sp[6] = $pts[0] + $ssh;
$sp[7] = $pts[1] - $ssv;
$sp[8] = $pts[6] + $ssh;
$sp[9] = $pts[7] - $ssv;
$sp[10] = $pts[4] + $ssh;
$sp[11] = $pts[5] - $ssv;
}
$img->PushColor($this->bar_shadow_color);
$img->FilledPolygon($sp);
$img->PopColor();
}
// Stroke the outline of the bar
if (is_array($this->color)) {
$img->SetColor($this->color[$i % count($this->color)]);
} else {
$img->SetColor($this->color);
}
$img->SetLineWeight($this->weight);
$pts[] = $pts[0];
$pts[] = $pts[1];
$img->Polygon($pts);
$x = $pts[2] + ($pts[4] - $pts[2]) / 2;
if ($this->valuepos == 'top') {
$y = $pts[3];
$this->value->Stroke($img, $val, $x, $y);
} elseif ($this->valuepos == 'center') {
$y = ($pts[3] + $pts[1]) / 2;
$this->value->SetAlign('center', 'center');
$this->value->SetMargin(0);
$this->value->Stroke($img, $val, $x, $y);
} elseif ($this->valuepos == 'bottom') {
$y = $pts[1];
$this->value->SetMargin(0);
$this->value->Stroke($img, $val, $x, $y);
} else {
JpGraphError::Raise('Unknown position for values on bars :' . $this->valuepos);
die;
}
// Create the client side image map
$rpts = $img->ArrRotate($pts);
$csimcoord = round($rpts[0]) . ", " . round($rpts[1]);
for ($j = 1; $j < 4; ++$j) {
$csimcoord .= ", " . round($rpts[2 * $j]) . ", " . round($rpts[2 * $j + 1]);
}
$this->csimareas .= '<area shape="poly" coords="' . $csimcoord . '" ';
if (!empty($this->csimtargets[$i])) {
$this->csimareas .= " href=\"" . $this->csimtargets[$i] . "\"";
}
if (!empty($this->csimalts[$i])) {
$sval = sprintf($this->csimalts[$i], $this->coords[0][$i]);
$this->csimareas .= " alt=\"{$sval}\" title=\"{$sval}\" ";
}
$this->csimareas .= ">\n";
}
return true;
}
示例15: ScatterPlot
function ScatterPlot($datay, $datax = false)
{
if (count($datax) != count($datay) && is_array($datax)) {
JpGraphError::Raise("Scatterplot must have equal number of X and Y points.");
}
$this->Plot($datay, $datax);
$this->mark = new PlotMark();
$this->mark->SetType(MARK_SQUARE);
$this->mark->SetColor($this->color);
$this->value->SetAlign('center', 'center');
$this->value->SetMargin(0);
}