本文整理汇总了PHP中Plot类的典型用法代码示例。如果您正苦于以下问题:PHP Plot类的具体用法?PHP Plot怎么用?PHP Plot使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Plot类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: RenderWikiPlot
/**
*RenderWikiPlot CallBack function
*
*This is the function that handles MediaWiki callbacks, and renders the actual plot.
*
*@access private
*@param string $input The content of the wikiplot tag
*@param array $argv Hash-array of the parameters of the wikiplot tag, with parameter-name as key and parameter-value as value.
*@param Parser $parser The parser of MediaWiki, if null parser is obtained from global variable
*@uses WikiPlotDeserializeBoolean()
*@uses WikiPlotDeserializeString()
*@uses WikiPlotDeserializeMixed()
*@uses WikiPlotDeserializeInteger()
*@uses WikiPlotDeserializeColor()
*@uses XMLParser
*@uses Plot
*@uses Graph
*@uses Cache
*@return string HTML that can be directly inserted into any website.
*/
function RenderWikiPlot($input, $argv, $parser = null)
{
//Get parser if not given as parameter
if (!$parser) {
$parser =& $GLOBALS['wgParser'];
}
/*Currently the parser*/
//Creating instance of plot
$Plot = new Plot();
//Getting and deserializing parameters
WikiPlotDeserializeBoolean($argv["grid"], $Plot->EnableGrid);
WikiPlotDeserializeBoolean($argv["axis"], $Plot->EnableAxis);
WikiPlotDeserializeString($argv["caption"], $Plot->Caption);
WikiPlotDeserializeMixed($argv["xspan"], $Plot->MinX, $Plot->MaxX);
WikiPlotDeserializeMixed($argv["yspan"], $Plot->MinY, $Plot->MaxY);
WikiPlotDeserializeMixed($argv["gridspace"], $Plot->XGridSpace, $Plot->YGridSpace);
WikiPlotDeserializeInteger($argv["height"], $Plot->Height);
WikiPlotDeserializeInteger($argv["width"], $Plot->Width);
WikiPlotDeserializeInteger($argv["captionfont"], $Plot->CaptionFont);
WikiPlotDeserializeInteger($argv["gridfont"], $Plot->GridFont);
WikiPlotDeserializeColor($argv["gridcolor"], $Plot->GridColor);
//Parsing Xml
$XmlParser = new XMLParser($input);
$Graphs = $XmlParser->CreateInputArray();
foreach ($Graphs as $Graph) {
$G = new Graph();
if (!is_array($Graph[1])) {
$G->Exp = $Graph[1];
WikiPlotDeserializeString($Graph[0]["label"], $G->Label);
WikiPlotDeserializeColor($Graph[0]["color"], $G->Color);
} else {
$G->Exp = $Graph[0];
}
array_push($Plot->Graphs, $G);
}
//Render the plot
//Get instance of cache
$cache = new cache();
//Url of the current plot
$PlotURL = "";
$PlotFileName = $Plot->GetHash() . ".png";
if (!$cache->FileExist($PlotFileName)) {
$Plot->SaveAs($cache->CachePath($PlotFileName));
} else {
$PlotURL = $cache->FileURL($PlotFileName);
}
$output = "<a href='{$PlotURL}' class='image' title='See the plot'><img src='{$PlotURL}'></a>";
return $output;
}
示例2: UNIX_TIMESTAMP
$Query = '
SELECT
time*1000 as time,
DAYOFYEAR(FROM_UNIXTIME(`time`)) as `d`,
AVG(`temperature`) as `temp`
FROM `' . PREFIX . 'training`
WHERE
!ISNULL(`temperature`) AND
`time` BETWEEN UNIX_TIMESTAMP(\'' . (int) $Year . '-01-01\') AND UNIX_TIMESTAMP(\'' . ((int) $Year + 1) . '-01-01\')-1
GROUP BY `d`
ORDER BY `d` ASC';
$Data = DB::getInstance()->query($Query)->fetchAll();
foreach ($Data as $dat) {
$Temperatures[$dat['time']] = $Temperature->format((int) $dat['temp'], false);
}
$Plot = new Plot("year" . $Year, 780, 240);
$Plot->Data[] = array('label' => __('Temperatures') . ' ' . $Year, 'data' => $Temperatures);
$Plot->setMarginForGrid(5);
$Plot->setXAxisAsTime();
$Plot->setXAxisLimitedTo($Year);
$Plot->addYAxis(1, 'left');
$Plot->addYUnit(1, $Temperature->unit(), 0);
$Plot->setYTicks(1, 5, 0);
$Plot->addThreshold('y', 0);
$Plot->addMarkingArea('y', -99, 0);
$Plot->showPoints(2);
$Plot->smoothing(false);
if (empty($Data)) {
$Plot->raiseError(__('No data available.'));
}
$Plot->outputJavaScript();
示例3: rand
$iPoints = 15;
$dx = (GRAPH_WIDTH - 40) / ($iPoints - 1);
$x = 20;
for ($i = 0; $i < $iPoints; $i++) {
$y = rand(20, GRAPH_HEIGHT - 20);
$aCoords[$x] = $y;
$x += $dx;
}
$vImagegHeight = GRAPH_HEIGHT + 30;
$vImage = imagecreatetruecolor(GRAPH_WIDTH + 50, $vImagegHeight);
$vBgColor = imagecolorallocate($vImage, 160, 160, 160);
$vTextColor = imagecolorallocate($vImage, 0, 0, 0);
$vAxisColor = imagecolorallocate($vImage, 0, 0, 0);
$vDotColor = imagecolorallocate($vImage, 192, 64, 64);
imagefill($vImage, 0, 0, $vBgColor);
$oPlot = new Plot($aCoords);
$oPlot->drawDots($vImage, $vDotColor, 10, GRAPH_HEIGHT, 8);
$oCurve = new CubicSplines();
$vColor = imagecolorallocate($vImage, 225, 64, 64);
$iStart = microtime(1);
if ($oCurve) {
$oCurve->setInitCoords($aCoords, 1);
$r = $oCurve->processCoords();
if ($r) {
$curveGraph = new Plot($r);
} else {
continue;
}
} else {
$curveGraph = $oPlot;
}
示例4: foreach
if (count($Data) == 1) {
$Data[1] = $Data[0];
}
if (!empty($Data)) {
foreach ($Data as $D) {
$Weights[$D['time'] . '000'] = (double) $D['weight'];
$HRrests[$D['time'] . '000'] = (int) $D['pulse_rest'];
}
}
$Labels = array_keys($Weights);
foreach ($Labels as $i => &$value) {
if ($i != 0 && $i != count($Labels) - 1) {
$value = '';
}
}
$Plot = new Plot("sportler_weights", 320, 150);
if ($Plugin->Configuration()->value('use_weight')) {
$Plot->Data[] = array('label' => __('Weight'), 'color' => '#008', 'data' => $Weights);
}
if ($Plugin->Configuration()->value('use_pulse')) {
$Plot->Data[] = array('label' => __('Resting HR'), 'color' => '#800', 'data' => $HRrests, 'yaxis' => 2);
}
$Plot->setMarginForGrid(5);
$Plot->setXLabels($Labels);
$Plot->setXAxisTimeFormat('%m/%y');
$Plot->setXAxisMaxToToday();
$Plot->Options['xaxis']['labelWidth'] = 50;
//$Plot->Options['xaxis']['tickLength'] = 3;
$Plot->Options['series']['curvedLines']['fit'] = true;
$Plot->addYAxis(1, 'left');
$Plot->addYUnit(1, 'kg', 1);
示例5: _e
?>
<div class="panel-heading">
<div class="panel-menu">
<ul>
<li class="with-submenu"><span class="link"><?php
_e('Choose year');
?>
</span><ul class="submenu"><?php
echo $Submenu;
?>
</ul></li>
</ul>
</div>
<h1><?php
_e('Temperatures');
?>
</h1>
</div>
<div class="panel-content">
<?php
echo Plot::getDivFor('average', 780, 240);
include FRONTEND_PATH . '../plugin/RunalyzePluginStat_Wetter/Plot.Average.php';
?>
</div>
<div class="panel-content">
<?php
echo Plot::getDivFor('year' . $_GET['y'], 780, 240);
include FRONTEND_PATH . '../plugin/RunalyzePluginStat_Wetter/Plot.Year.php';
?>
</div>
示例6: foreach
WHERE
`typeid`="' . Configuration::General()->competitionType() . '"
AND `distance`="' . $distance . '"
ORDER BY
`time` ASC')->fetchAll();
Cache::set('prognosePlotDistanceData' . $distance, $ResultsData, '600');
}
foreach ($ResultsData as $dat) {
if (!isset($WKplugin) || !$WKplugin->isFunCompetition($dat['id'])) {
$Results[$dat['time'] . '000'] = $dat['s'] * 1000;
}
}
} else {
$DataFailed = true;
}
$Plot = new Plot("formverlauf_" . str_replace('.', '_', $distance), 800, 450);
$Plot->Data[] = array('label' => __('Prognosis'), 'color' => '#880000', 'data' => $Prognosis, 'lines' => array('show' => true), 'points' => array('show' => false));
$Plot->Data[] = array('label' => __('Result'), 'color' => '#000000', 'data' => $Results, 'lines' => array('show' => false), 'points' => array('show' => true), 'curvedLines' => array('apply' => false));
$Plot->setZeroPointsToNull();
$Plot->setMarginForGrid(5);
$Plot->setXAxisAsTime();
$Plot->addYAxis(1, 'left');
if (!empty($Prognosis) && max($Prognosis) > 1000 * 3600) {
$Plot->setYAxisTimeFormat('%H:%M:%S');
} else {
$Plot->setYAxisTimeFormat('%M:%S');
}
$Plot->setTitle(__('Prognosis trend') . ' ' . Distance::format($distance));
if ($DataFailed || empty($Data)) {
$Plot->raiseError(__('No data available.'));
}
示例7: _e
?>
</span><ul class="submenu"><?php
echo $Submenu;
?>
</ul></li>
</ul>
</div>
<h1><?php
_e('Prognosis calculator: form trend');
?>
</h1>
</div>
<div class="panel-content">
<?php
echo Plot::getDivFor('formverlauf_' . str_replace('.', '_', $distance), 800, 450);
include FRONTEND_PATH . '../plugin/RunalyzePluginPanel_Prognose/Plot.Form.php';
?>
<p class="info">
<?php
_e('The average VDOT value per month is used.');
?>
</p>
<p class="info">
<?php
_e('The basic endurance adjustment is <strong>not</strong> used for these calculations.');
?>
</p>
</div>
示例8: foreach
$timeFormat = '%M:%S';
$competitions = $this->RaceContainer->races($distance);
//$competitions = DB::getInstance()->query('SELECT id,time,s FROM `'.PREFIX.'training` WHERE `typeid`='.Configuration::General()->competitionType().' AND `distance`="'.$distance.'" ORDER BY `time` ASC')->fetchAll();
if (!empty($competitions)) {
foreach ($competitions as $competition) {
if (!$this->isFunCompetition($competition['id'])) {
$Dates[] = $competition['time'];
$Results[$competition['time'] . '000'] = $competition['s'] * 1000;
// Attention: timestamp(0) => 1:00:00
}
}
if (!empty($Results) && max($Results) > 3600 * 1000) {
$timeFormat = '%H:%M:%S';
}
}
$Plot = new Plot("bestzeit" . $distance * 1000, 480, 190);
$Plot->Data[] = array('label' => $label, 'data' => $Results);
//$Plot->Data[] = array('label' => $trend, 'data' => $Results, 'color' => '#C61D17', 'lines' => array('show' => true), 'curvedLines' => array('apply' => true, 'fit' => true));
//$Plot->Data[] = array('label' => $label, 'data' => $Results, 'color' => '#C61D17', 'points' => array('show' => true), 'curvedLines' => array('apply' => false));
$Plot->setMarginForGrid(5);
$Plot->setXAxisAsTime();
if (count($Results) == 1) {
$Plot->setXAxisTimeFormat('%d.%m.%y');
}
$Plot->addYAxis(1, 'left');
$Plot->setYAxisAsTime(1);
$Plot->setYAxisTimeFormat($timeFormat, 1);
$Plot->smoothing(false);
$Plot->lineWithPoints();
$Plot->setTitle($titleCenter);
$Plot->outputJavaScript();
示例9: foreach
$Data[1] = $Data[0];
}
if (!empty($Data)) {
foreach ($Data as $D) {
$Adiposes[$D['time'] . '000'] = $D['fat'];
$Water[$D['time'] . '000'] = $D['water'];
$Muscles[$D['time'] . '000'] = $D['muscles'];
}
}
$Labels = array_keys($Water);
foreach ($Labels as $i => &$value) {
if ($i != 0 && $i != count($Labels) - 1) {
$value = '';
}
}
$Plot = new Plot("sportler_analyse", 320, 150);
$Plot->Data[] = array('label' => __('Fat') . '', 'color' => '#800', 'data' => $Adiposes);
$Plot->Data[] = array('label' => __('Water'), 'color' => '#008', 'data' => $Water, 'yaxis' => 2);
$Plot->Data[] = array('label' => __('Muscles'), 'color' => '#080', 'data' => $Muscles, 'yaxis' => 2);
$Plot->setMarginForGrid(5);
//$Plot->hideXLabels();
$Plot->setXLabels($Labels);
$Plot->setXAxisTimeFormat('%m/%y');
$Plot->setXAxisMaxToToday();
$Plot->Options['xaxis']['labelWidth'] = 50;
//$Plot->Options['xaxis']['tickLength'] = 3;
$Plot->Options['yaxis']['autoscaleMargin'] = 0.1;
$Plot->Options['series']['curvedLines']['fit'] = true;
$Plot->PlotOptions['allowSelection'] = false;
$Plot->addYAxis(1, 'left');
$Plot->addYUnit(1, '%', 0);
示例10: displayPersonalBestsImages
/**
* Display all image-links for personal bests
*/
private function displayPersonalBestsImages()
{
$SubLinks = array();
foreach ($this->PBdistances as $km) {
$name = (new Distance($km))->stringAuto(true, 1);
$SubLinks[] = Ajax::flotChange($name, 'bestzeitenFlots', 'bestzeit' . $km * 1000);
}
$Links = array(array('tag' => '<a href="#">' . __('Choose distance') . '</a>', 'subs' => $SubLinks));
echo '<div class="databox" style="float:none;padding:0;width:490px;margin:20px auto;">';
echo '<div class="panel-heading">';
echo '<div class="panel-menu">';
echo Ajax::toolbarNavigation($Links);
echo '</div>';
echo '<h1>' . __('Results trend') . '</h1>';
echo '</div>';
echo '<div class="panel-content">';
$display_km = $this->PBdistances[0];
if (in_array($this->Configuration()->value('main_distance'), $this->PBdistances)) {
$display_km = $this->Configuration()->value('main_distance');
}
echo '<div id="bestzeitenFlots" class="flot-changeable" style="position:relative;width:482px;height:192px;">';
foreach ($this->PBdistances as $km) {
echo Plot::getInnerDivFor('bestzeit' . $km * 1000, 480, 190, $km != $display_km);
$_GET['km'] = $km;
include 'Plot.Bestzeit.php';
}
echo '</div>';
echo '</div>';
echo '</div>';
}
示例11: array_slice
}
$VDOT_slice = array_slice($VDOTs_raw, $d - $VDOTdays, $VDOTdays);
$Durations_slice = array_slice($Durations_raw, $d - $VDOTdays, $VDOTdays);
$VDOT_sum = array_sum($VDOT_slice);
$Durations_sum = array_sum($Durations_slice);
if (count($VDOT_slice) != 0 && $Durations_sum != 0) {
$VDOTs[$index] = Configuration::Data()->vdotFactor() * ($VDOT_sum / $Durations_sum);
}
if ($VDOTs_raw[$d]) {
$VDOTsday[$index] = Configuration::Data()->vdotFactor() * ($VDOTs_raw[$d] / $Durations_raw[$d]);
}
}
} else {
$DataFailed = true;
}
$Plot = new Plot("form" . $_GET['y'], 800, 450);
$Plot->Data[] = array('label' => __('Fitness (CTL)'), 'color' => '#008800', 'data' => $CTLs);
//if (count($ATLs) < $MaxATLPoints)
$Plot->Data[] = array('label' => __('Fatigue (ATL)'), 'color' => '#CC2222', 'data' => $ATLs);
$Plot->Data[] = array('label' => __('avg VDOT'), 'color' => '#000000', 'data' => $VDOTs, 'yaxis' => 2);
$Plot->Data[] = array('label' => 'TRIMP', 'color' => '#5555FF', 'data' => $TRIMPs, 'yaxis' => 3);
$Plot->Data[] = array('label' => __('day VDOT'), 'color' => '#444444', 'data' => $VDOTsday, 'yaxis' => 2);
$Plot->setMarginForGrid(5);
$Plot->setLinesFilled(array(0));
$Plot->setLinesFilled(array(1), 0.3);
$Plot->setXAxisAsTime();
if (!$All && !$lastHalf && !$lastYear) {
$Plot->setXAxisLimitedTo($Year);
}
$Plot->addYAxis(1, 'left');
$Plot->setYTicks(1, 1);
示例12: display
/**
* Output JS
*/
public final function display()
{
echo Plot::getInnerDivFor($this->getCSSid(), $this->WIDTH, $this->HEIGHT);
$this->Plot->outputJavaScript();
}
示例13: testPlot
/**
* Test a plot
*
* Will be displayed instead of the DataBrowser - Only for testing purposes!
* @param string $includePath
* @param string $name
* @param int $width
* @param int $height
*/
public function testPlot($includePath, $name, $width, $height)
{
echo '<div id="container"><div id="main"><div id="data-browser" class="panel c"><div class="panel-content">';
echo Plot::getDivFor($name, $width, $height);
include FRONTEND_PATH . $includePath;
echo '</div></div></div></div>';
exit;
}
示例14:
function __construct($datay, $datax = false)
{
if (count($datay) % $this->iTupleSize) {
JpGraphError::RaiseL(21001, $this->iTupleSize);
//('Data values for Stock charts must contain an even multiple of '.$this->iTupleSize.' data points.');
}
parent::__construct($datay, $datax);
$this->numpoints /= $this->iTupleSize;
}
示例15: __construct
public function __construct($datay, $datax, $angles)
{
if (count($datax) != count($datay)) {
Util\JpGraphError::RaiseL(20001);
}
//("Fieldplots must have equal number of X and Y points.");
if (count($datax) != count($angles)) {
Util\JpGraphError::RaiseL(20002);
}
//("Fieldplots must have an angle specified for each X and Y points.");
$this->iAngles = $angles;
parent::__construct($datay, $datax);
$this->value->SetAlign('center', 'center');
$this->value->SetMargin(15);
$this->arrow = new FieldArrow();
}