Exemple #1
0
 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;
 }
Exemple #2
0
 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();
 }
/**
*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;
}
Exemple #4
0
 function SetColor($aColor)
 {
     parent::SetColor($aColor);
 }
 function __construct($datay, $datax = false)
 {
     parent::__construct($datay, $datax);
     $this->numpoints /= 2;
 }
Exemple #6
0
$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();
Exemple #7
0
 function Min()
 {
     $m = parent::Min();
     $m[1] = min($m[1], $this->ymin);
     return $m;
 }
Exemple #8
0
$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;
}
Exemple #9
0
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);
Exemple #10
0
?>
<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>
Exemple #11
0
			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.'));
}
Exemple #12
0
?>
</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>
Exemple #13
0
$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();
Exemple #14
0
    $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);
Exemple #15
0
	<div class="panel-menu">
		<ul>
			<li class="with-submenu"><span class="link"><?php 
_e('Performance model');
?>
</span><ul class="submenu"><?php 
echo $perfmodelsmenu;
?>
</ul></li>
			<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('Shape');
?>
</h1>
</div>

<div class="panel-content">
	<?php 
echo Plot::getDivFor('form' . $timerange . $perfmodel, 800, 450);
include FRONTEND_PATH . '../plugin/RunalyzePluginPanel_Rechenspiele/Plot.Form.php';
?>
</div>
 /**
  * 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>';
 }
Exemple #17
0
        }
        $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);
Exemple #18
0
 /**
  * Output JS 
  */
 public final function display()
 {
     echo Plot::getInnerDivFor($this->getCSSid(), $this->WIDTH, $this->HEIGHT);
     $this->Plot->outputJavaScript();
 }
Exemple #19
0
 /**
  * Constructor
  */
 public function __construct()
 {
     $sportid = strlen(Request::param('sportid')) > 0 ? Request::param('sportid') : Configuration::General()->runningSport();
     $this->Year = $this->getRequestedYear();
     $this->Sport = new Sport($sportid);
     parent::__construct($this->getCSSid(), 800, 500);
     $this->init();
     $this->addAverage();
 }
Exemple #20
0
 /**
  * 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;
 }
Exemple #21
0
 function Min()
 {
     $m = parent::Min();
     if ($m[1] > 0) {
         $m[1] = $this->ymin;
     }
     return $m;
 }
 /**
  * Display the images
  */
 private function displayImages()
 {
     echo '<div style="max-width:750px;margin:0 auto;">';
     echo '<span class="right">';
     echo Plot::getDivFor('weekday', 350, 190);
     echo '</span>';
     echo '<span class="left">';
     echo Plot::getDivFor('daytime', 350, 190);
     echo '</span>';
     echo HTML::clearBreak();
     echo '</div>';
     include FRONTEND_PATH . '../plugin/' . $this->key() . '/Plot.Daytime.php';
     include FRONTEND_PATH . '../plugin/' . $this->key() . '/Plot.Weekday.php';
 }
Exemple #23
0
 function SetColor($c)
 {
     parent::SetColor($c);
     $this->mark->SetColor($this->color);
 }
Exemple #24
0
$link = 'plugin/RunalyzePluginPanel_Rechenspiele/window.plot.php?y=lastyear';
$Submenu .= '<li' . ('lastyear' == $_GET['y'] ? ' class="active"' : '') . '>' . Ajax::window('<a href="' . $link . '">' . __('Last year') . '</a>') . '</li>';
for ($j = date('Y'); $j >= START_YEAR; $j--) {
    $link = 'plugin/RunalyzePluginPanel_Rechenspiele/window.plot.php?y=' . $j;
    $Submenu .= '<li' . ($j == $_GET['y'] ? ' class="active"' : '') . '>' . Ajax::window('<a href="' . $link . '">' . $j . '</a>') . '</li>';
}
?>
<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('Shape');
?>
</h1>
</div>

<div class="panel-content">
	<?php 
echo Plot::getDivFor('form' . $_GET['y'], 800, 450);
include FRONTEND_PATH . '../plugin/RunalyzePluginPanel_Rechenspiele/Plot.Form.php';
?>
</div>
<?php

/*
This is an example of how plot.class.php could be used. In this example we will draw a graph of the mathematical expression sent via. the GET method.
*/
//Tell the client that this is a binary png file, NOT html.
//This is also why you can't use html in this example.
header("Content-type: image/png");
/*
Include plot.class.php, since we need the file to draw with.
*/
include "plot.class.php";
//Create an instance of Plot
$Plot = new Plot();
//Initialize some fields on the Plot
$Plot->Caption = "Example plot";
//Setting image size
$Plot->Width = 500;
$Plot->Height = 500;
//Setting coordinate space
$Plot->MinX = -250;
$Plot->MaxX = 250;
$Plot->MinY = -250;
$Plot->MaxY = 250;
//Creating an instance of Graph
$G = new Graph();
//Set the expression of the graph to the parameter given via the GET method.
$G->Exp = $_GET["exp"];
//Set the color of the Graph
$G->Color = array(0, 0, 255);
//Set the label of the Graph
Exemple #26
0
}
$Query = '
	SELECT
		YEAR(FROM_UNIXTIME(`time`)) as `y`,
		MONTH(FROM_UNIXTIME(`time`)) as `m`,
		AVG(`temperature`) as `temp`
	FROM `' . PREFIX . 'training`
	WHERE
		!ISNULL(`temperature`)
	GROUP BY `y`, `m`
	ORDER BY `y` ASC, `m` ASC';
$Data = DB::getInstance()->query($Query)->fetchAll();
foreach ($Data as $dat) {
    $Temperatures[$dat['y']][$dat['m'] - 1] = (int) $dat['temp'];
}
$Plot = new Plot("average", 780, 240);
for ($y = START_YEAR, $n = date('Y'); $y <= $n; $y++) {
    if (min($Temperatures[$y]) != null || max($Temperatures[$y]) != null) {
        $Plot->Data[] = array('label' => $y, 'data' => $Temperatures[$y]);
    }
}
$Plot->setMarginForGrid(5);
$Plot->setXLabels($Months);
$Plot->addYAxis(1, 'left');
$Plot->addYUnit(1, '°C', 1);
$Plot->setYTicks(1, 5, 0);
$Plot->addThreshold('y', 0);
$Plot->addMarkingArea('y', -99, 0);
$Plot->lineWithPoints();
$Plot->smoothing(false);
$Plot->outputJavaScript();
Exemple #27
0
 function Max()
 {
     $m = parent::Max();
     if ($m[1] <= $this->ybase) {
         $m[1] = $this->ybase;
     }
     return $m;
 }
Exemple #28
0
	WHERE
		`sportid`=:id
		' . $this->getYearDependenceForQuery() . '
	GROUP BY `day`
	ORDER BY ((`day`+6)%7) ASC');
// TODO: Should be possible with one query?
foreach ($Sports as $sport) {
    $id = $sport['name'];
    $yAxis[$id] = array(0, 0, 0, 0, 0, 0, 0);
    $Query->execute(array(':id' => $sport['id']));
    $data = $Query->fetchAll();
    foreach ($data as $dat) {
        $yAxis[$id][($dat['day'] + 6) % 7] = $dat['value'] / 3600;
    }
}
$Plot = new Plot("weekday", 350, 190);
$max = 0;
foreach ($yAxis as $key => $data) {
    $Plot->Data[] = array('label' => $key, 'data' => $data);
    $max += max($data);
}
$Plot->setLegendAsTable();
$Plot->setMarginForGrid(5);
$Plot->setXLabels($xAxis);
$Plot->addYAxis(1, 'left');
$Plot->addYUnit(1, 'h');
$Plot->setYTicks(1, 1, 0);
$Plot->setYLimits(1, 0, $max);
$Plot->showBars(true);
$Plot->stacked();
$error = true;
Exemple #29
0
 function __construct($datay, $datax = false)
 {
     if (count($datax) != count($datay) && is_array($datax)) {
         JpGraphError::RaiseL(20003);
         //("Scatterplot must have equal number of X and Y points.");
     }
     parent::__construct($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);
     $this->link = new LineProperty(1, 'black', 'solid');
     $this->link->iShow = false;
 }
Exemple #30
0
 public static function plotSpectra()
 {
     $plot = new Plot();
     $plot->xlabel("Wavelength (nm)");
     $spectra = new Spectra();
     $spectra->loadOptions();
     // Make material selection if it exists
     if (isset($_GET['selection'])) {
         $selection = json_decode(urldecode($_GET['selection']));
         // print_r($selection);
         $x = array();
         $y = array();
         $legend = array();
         foreach ($selection as $type => $name_array) {
             $plot->ylabel($type . " (cm^2)");
             foreach ($name_array as $name => $axis_array) {
                 $plot->title($name . " " . $type . " Vs. Wavelength");
                 $n = 0;
                 foreach ($axis_array as $axis => $range_array) {
                     // print_r($axis);
                     $legend[$n] = $axis . " axis";
                     $y[$legend[$n]] = array();
                     foreach ($range_array as $range => $empty) {
                         if (!$spectra->selectOptions($type, $name, $axis, $range)) {
                             $errors[] = new UserError("Options do not exist", 1);
                         }
                         if ($n == 0) {
                             // only need wavelengths once
                             $x = array_merge($x, $spectra->getWavelengths());
                         }
                         $y[$legend[$n]] = array_merge($y[$legend[$n]], $spectra->getSignals());
                         $spectra->clearSelection();
                     }
                     $n = $n + 1;
                 }
             }
         }
         $plot->setX($x);
         $plot->setY($y);
         $plot->legend($legend);
         // Output plot data
         echo $plot->getJson();
     } else {
         // Output materials list
         echo $spectra->getJson();
     }
 }