本文整理汇总了PHP中ScatterPlot类的典型用法代码示例。如果您正苦于以下问题:PHP ScatterPlot类的具体用法?PHP ScatterPlot怎么用?PHP ScatterPlot使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ScatterPlot类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: Graph
<?php
require_once "../ScatterPlot.class.php";
$graph = new Graph(400, 400);
$graph->title->set('Impulses');
$graph->title->move(0, 30);
$graph->shadow->setSize(5);
$y = array();
for ($i = 0; $i < 60; $i++) {
$y[] = cos($i / 30 * 2 * M_PI) / (1.5 + $i / 15);
}
$plot = new ScatterPlot($y);
$plot->setBackgroundColor(new VeryLightOrange());
$plot->setSpace(5);
// Set impulses
$plot->setImpulse(new DarkBlue());
$plot->grid->hideVertical();
// Hide ticks
$plot->xAxis->hideTicks();
// Change labels interval
$plot->xAxis->label->setInterval(5);
$plot->mark->setType(MARK_SQUARE);
$plot->mark->setSize(4);
$graph->add($plot);
$graph->draw();
示例2: Graph
<?php
require_once "../ScatterPlot.class.php";
$graph = new Graph(400, 400);
$graph->shadow->setSize(5);
$graph->title->set('ScatterPlot with values');
$y = array(4, 3, 2, 5, 8, 1, 3, 6, 4, 5);
$x = array(1, 2, 5, 4, 3, 6, 2, 4, 5, 1);
$plot = new ScatterPlot($y, $x);
$plot->setSpace(6, 6, 6, 0);
$plot->setPadding(NULL, NULL, 40, 20);
// Set dashed lines on the grid
$plot->grid->setType(LINE_DASHED);
$plot->mark->setSize(30);
$plot->mark->setFill(new DarkOrange(20));
$plot->label->set($y);
$plot->label->setColor(new White());
$graph->add($plot);
$graph->draw();
示例3: _renderPlotScatter
private function _renderPlotScatter($groupID, $bubble)
{
$grouping = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotGrouping();
$scatterStyle = $bubbleSize = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotStyle();
$seriesCount = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotSeriesCount();
$seriesPlots = array();
// Loop through each data series in turn
for ($i = 0; $i < $seriesCount; ++$i) {
$dataValuesY = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotCategoryByIndex($i)->getDataValues();
$dataValuesX = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getDataValues();
foreach ($dataValuesY as $k => $dataValueY) {
$dataValuesY[$k] = $k;
}
$seriesPlot = new ScatterPlot($dataValuesX, $dataValuesY);
if ($scatterStyle == 'lineMarker') {
$seriesPlot->SetLinkPoints();
$seriesPlot->link->SetColor(self::$_colourSet[self::$_plotColour]);
} elseif ($scatterStyle == 'smoothMarker') {
$spline = new Spline($dataValuesY, $dataValuesX);
list($splineDataY, $splineDataX) = $spline->Get(count($dataValuesX) * self::$_width / 20);
$lplot = new LinePlot($splineDataX, $splineDataY);
$lplot->SetColor(self::$_colourSet[self::$_plotColour]);
$this->_graph->Add($lplot);
}
if ($bubble) {
$this->_formatPointMarker($seriesPlot, 'dot');
$seriesPlot->mark->SetColor('black');
$seriesPlot->mark->SetSize($bubbleSize);
} else {
$marker = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotValuesByIndex($i)->getPointMarker();
$this->_formatPointMarker($seriesPlot, $marker);
}
$dataLabel = $this->_chart->getPlotArea()->getPlotGroupByIndex($groupID)->getPlotLabelByIndex($i)->getDataValue();
$seriesPlot->SetLegend($dataLabel);
$this->_graph->Add($seriesPlot);
}
}
示例4: Graph
<?php
require_once "../ScatterPlot.class.php";
$graph = new Graph(400, 400);
$graph->title->set('Simple ScatterPlot');
$y = array(1, 10, 3, -4, 1, 4, 8, 7);
$x = array(0.5, 0.5, 3, 5, 2, 3, 4, 1.5);
$plot = new ScatterPlot($y, $x);
$plot->setBackgroundColor(new VeryLightGray());
$plot->setPadding(NULL, NULL, 40, 20);
$plot->legend->add($plot, 'Some points', LEGEND_MARKONLY);
$graph->add($plot);
$graph->draw();
示例5: LinearRegression
$lr = new LinearRegression($datax, $datay);
list($stderr, $corr) = $lr->GetStat();
list($xd, $yd) = $lr->GetY(0, 19);
// Create the graph
$graph = new Graph\Graph(300, 250);
$graph->SetScale('linlin');
// Setup title
$graph->title->Set("Linear regression");
$graph->title->SetFont(FF_ARIAL, FS_BOLD, 14);
$graph->subtitle->Set('(stderr=' . sprintf('%.2f', $stderr) . ', corr=' . sprintf('%.2f', $corr) . ')');
$graph->subtitle->SetFont(FF_ARIAL, FS_NORMAL, 12);
// make sure that the X-axis is always at the
// bottom at the plot and not just at Y=0 which is
// the default position
$graph->xaxis->SetPos('min');
// Create the scatter plot with some nice colors
$sp1 = new ScatterPlot($datay, $datax);
$sp1->mark->SetType(MARK_FILLEDCIRCLE);
$sp1->mark->SetFillColor("red");
$sp1->SetColor("blue");
$sp1->SetWeight(3);
$sp1->mark->SetWidth(4);
// Create the regression line
$lplot = new Plot\LinePlot($yd);
$lplot->SetWeight(2);
$lplot->SetColor('navy');
// Add the pltos to the line
$graph->Add($sp1);
$graph->Add($lplot);
// ... and stroke
$graph->Stroke();
示例6: array
<?php
// content="text/plain; charset=utf-8"
require_once 'jpgraph/jpgraph.php';
require_once 'jpgraph/jpgraph_scatter.php';
$datay = array(20, 22, 12, 13, 17, 20, 16, 19, 30, 31, 40, 43);
$graph = new Graph(300, 200);
$graph->SetScale("textlin");
$graph->SetShadow();
$graph->img->SetMargin(40, 40, 40, 40);
$graph->title->Set("Simple mpuls plot");
$graph->title->SetFont(FF_FONT1, FS_BOLD);
$sp1 = new ScatterPlot($datay);
$sp1->mark->SetType(MARK_SQUARE);
$sp1->SetImpuls();
$graph->Add($sp1);
$graph->Stroke();
示例7: array
$c = "red";
}
return array(floor($aVal / 3), "", $c);
}
// Setup a basic graph
$graph = new Graph(400, 300, 'auto');
$graph->SetScale("linlin");
$graph->img->SetMargin(40, 100, 40, 40);
$graph->SetShadow();
$graph->title->Set("Example of ballon scatter plot");
// Use a lot of grace to get large scales
$graph->yaxis->scale->SetGrace(50, 10);
// Make sure X-axis as at the bottom of the graph
$graph->xaxis->SetPos('min');
// Create the scatter plot
$sp1 = new ScatterPlot($datay, $datax);
$sp1->mark->SetType(MARK_FILLEDCIRCLE);
// Uncomment the following two lines to display the values
$sp1->value->Show();
$sp1->value->SetFont(FF_FONT1, FS_BOLD);
// Specify the callback
$sp1->mark->SetCallback("FCallback");
// Setup the legend for plot
$sp1->SetLegend('Year 2002');
// Add the scatter plot to the graph
$graph->Add($sp1);
// ... and send to browser
$graph->Stroke();
?>
示例8: addPlot
/**
* add plot to graph
* @param string $pType plot types self::PT_*
* @param array $pOptions plot options
* @param boolean $pAdd if false, return plot instead of adding to graph
* @return object plot, if not rendered directly
*/
public function addPlot($pType = self::PT_LINE, $pOptions = array(), $pAdd = true)
{
$file = self::$JPGRAPH_DIR . \DIRECTORY_SEPARATOR . self::$GRAPH_FILES[self::$GRAPH_TYPES[$pType]];
if (\file_exists($file)) {
require_once $file;
}
if (!(count($this->dataX) > 0)) {
$this->dataX = false;
}
switch ($pType) {
case self::PT_LINE:
$plot = new \LinePlot($this->dataY, $this->dataX);
break;
case self::PT_AREA:
$plot = new \LinePlot($this->dataY, $this->dataX);
if (\array_key_exists('color', $pOptions)) {
$plot->SetFillColor($pOptions['color']);
}
break;
case self::PT_BAR:
$plot = new \BarPlot($this->dataY, $this->dataX);
break;
case self::PT_ERROR:
$plot = new \ErrorPlot($this->dataY, $this->dataY);
break;
case self::PT_FIELD:
$plot = new \FieldPlot($this->dataY, $this->dataX);
break;
case self::PT_STOCK:
$plot = new \StockPlot($this->dataY, $this->dataX);
break;
case self::PT_SCATTER:
$plot = new \ScatterPlot($this->dataY, $this->dataX);
break;
case self::PT_BALLOON:
$plot = new \ScatterPlot($this->dataY, $this->dataX);
break;
case self::PT_IMPULS:
$plot = new \ScatterPlot($this->dataY, $this->dataX);
$plot->SetImpuls();
break;
case self::PT_PIE:
$this->graph = new \PieGraph(self::$WIDTH, self::$HEIGHT);
$plot = new \PiePlot($this->data);
break;
}
if ($pAdd) {
$this->plots[] = $plot;
$this->graph->Add($plot);
} else {
return $plot;
}
}
示例9: array
$graph->Add($sp);
if (count($rv)) {
if (isset($rvMedianValue)) {
$datax = array();
$datay = array();
foreach ($rv as $x => $y) {
$datax[] = $x;
$datay[] = $rvMedianValue;
}
$lp = new LinePlot($datay, $datax);
$lp->SetColor('red');
$lp->SetWeight(1);
$graph->Add($lp);
}
$datax = array();
$datay = array();
foreach ($rv as $x => $y) {
$datax[] = $x;
$datay[] = $y;
}
$sp = new ScatterPlot($datay, $datax);
$sp->mark->SetFillColor('red');
$sp->SetLegend('Repeat View');
$graph->Add($sp);
}
}
if (isset($graph)) {
$graph->Stroke();
} else {
header("HTTP/1.0 404 Not Found");
}
示例10: Graph
<?php
/*
* This work is hereby released into the Public Domain.
* To view a copy of the public domain dedication,
* visit http://creativecommons.org/licenses/publicdomain/ or send a letter to
* Creative Commons, 559 Nathan Abbott Way, Stanford, California 94305, USA.
*
*/
require_once "../../ScatterPlot.class.php";
$graph = new Graph(300, 300);
$graph->title->set('One value!');
$y = array(mt_rand(-42, 42));
$plot = new ScatterPlot($y);
$plot->setPadding(NULL, NULL, 40, 20);
// Set dashed lines on the grid
$plot->grid->setType(LINE_DASHED);
$plot->mark->setSize(mt_rand(0, 60));
$plot->mark->setFill(new Black(mt_rand(0, 50)));
$plot->label->set($y);
$plot->label->setColor(new White());
$graph->add($plot);
$graph->draw();
示例11: Graph
<?php
require_once "../ScatterPlot.class.php";
$graph = new Graph(400, 400);
$graph->title->set('Linked ScatterPlot');
$y = array(1, 10, 3, -4, 1, 4, 8, 7);
$x = array(0.5, 0.5, 3, 5, 2, 3, 4, 1.5);
$plot = new ScatterPlot($y, $x);
$plot->setBackgroundColor(new VeryLightGray());
$plot->setPadding(NULL, NULL, 40, 20);
$plot->link(TRUE, new DarkBlue());
$graph->add($plot);
$graph->draw();
示例12: Graph
<?php
require_once "../ScatterPlot.class.php";
$graph = new Graph(400, 400);
$center = 5;
$x = array();
$y = array();
for ($i = 0; $i <= 30; $i++) {
$rad = $i / 30 * 2 * M_PI;
$x[] = $center + cos($rad) * $center;
$y[] = $center + sin($rad) * $center;
}
$plot = new ScatterPlot($y, $x);
$plot->setBackgroundColor(new VeryLightGray());
$plot->setPadding(30, 30, 30, 30);
$plot->setSpace(5, 5, 5, 5);
$plot->link(TRUE, new DarkGreen());
$plot->mark->setFill(new DarkOrange());
$plot->mark->setType(MARK_SQUARE, 4);
$plot->setXAxis(PLOT_BOTH);
$plot->setXAxisZero(FALSE);
$plot->setYAxis(PLOT_BOTH);
$plot->legend->add($plot, 'A circle', LEGEND_MARK);
$plot->legend->setPosition(0.5, 0.5);
$plot->legend->setAlign(LEGEND_CENTER, LEGEND_MIDDLE);
$graph->add($plot);
$graph->draw();
示例13: Graph
$datay2[$x] = 0;
}
}
//===========
$graph = new Graph(750, 450);
$graph->img->SetMargin(70, 40, 40, 80);
$graph->img->SetAntiAliasing();
$graph->SetScale("textlin");
$graph->SetShadow();
$graph->title->Set(strtoupper($pabrik) . " Tbs Diolah dan Sisa " . $periode);
$graph->title->SetFont(FF_DEFAULT, FS_NORMAL, 14);
$graph->xaxis->SetFont(FF_DEFAULT, FS_NORMAL, 11);
$graph->xaxis->SetTickLabels($labels);
$graph->xaxis->SetLabelAngle(45);
$p1 = new ScatterPlot($datay1);
$p2 = new ScatterPlot($datay2);
$p1->SetLegend('Diolah');
$p2->SetLegend('Sisa');
$graph->legend->Pos(0.02, 0.03);
$p1->mark->SetType(MARK_SQUARE);
$p1->SetImpuls();
$p1->mark->SetFillColor("red");
$p1->mark->SetWidth(4);
$p1->SetColor("blue");
$p2->mark->SetType(MARK_FILLEDCIRCLE);
$p2->SetImpuls();
$p2->mark->SetFillColor("orange");
$p2->mark->SetWidth(4);
$p2->SetColor("black");
$p1->SetCenter();
$graph->Add(array($p1, $p2));
示例14: Graph
<?php
require_once "../ScatterPlot.class.php";
$graph = new Graph(400, 400);
$graph->shadow->setSize(5);
$y = array();
for ($i = 0; $i < 60; $i++) {
$y[] = cos($i / 30 * 2 * M_PI);
}
$plot = new ScatterPlot($y);
$plot->setSpace(6, 6);
// Set impulses
$plot->setImpulse(new DarkGreen());
$plot->grid->hideVertical();
// Hide axis labels and ticks
$plot->xAxis->label->hide();
$plot->xAxis->hideTicks();
$plot->mark->setType(MARK_SQUARE);
$plot->mark->setSize(4);
$graph->add($plot);
$graph->draw();
示例15: getCircle
$group->setSpace(5, 5, 5, 5);
$group->legend->setPosition(0.82, 0.1);
$group->legend->setAlign(LEGEND_CENTER, LEGEND_MIDDLE);
function getCircle($size)
{
$center = 0;
$x = array();
$y = array();
for ($i = 0; $i <= 20; $i++) {
$rad = $i / 20 * 2 * M_PI;
$x[] = $center + cos($rad) * $size;
$y[] = $center + sin($rad) * $size;
}
return array($x, $y);
}
list($x, $y) = getCircle(3);
$plot = new ScatterPlot($y, $x);
$plot->link(TRUE, new DarkBlue());
$plot->mark->setFill(new DarkPink());
$plot->mark->setType(MARK_CIRCLE, 6);
$group->legend->add($plot, 'Circle #1', LEGEND_MARK);
$group->add($plot);
list($x, $y) = getCircle(5);
$plot = new ScatterPlot($y, $x);
$plot->link(TRUE, new DarkGreen());
$plot->mark->setFill(new DarkOrange());
$plot->mark->setType(MARK_SQUARE, 4);
$group->legend->add($plot, 'Circle #2', LEGEND_MARK);
$group->add($plot);
$graph->add($group);
$graph->draw();