Exemplo n.º 1
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();
Exemplo n.º 2
0
    $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;
foreach ($yAxis as $t) {
    foreach ($t as $e) {
        if ($e != "0") {
            $error = false;
        }
    }
}
if ($error === true) {
    $Plot->raiseError(__('No data available.'));
}
Exemplo n.º 3
0
//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);
if (Configuration::Trimp()->showInPercent()) {
    $Plot->addYUnit(1, '%');
    $Plot->setYLimits(1, 0, 100);
}
$Plot->addYAxis(2, 'right');
$Plot->setYTicks(2, 1, 1);
$Plot->addYAxis(3, 'right');
$Plot->setYLimits(3, 0, $maxTrimp * 2);
$Plot->showAsBars(3, 1, 2);
$Plot->showAsPoints(4);
$Plot->smoothing(false);
if (($lastHalf || $lastYear) && !$DataFailed) {
    $Plot->addMarkingArea('x', Plot::dayOfYearToJStime($StartYear, $HighestIndex - 30 - $AddDays + $StartDayInYear + 1), $index, 'rgba(255,255,255,0.3)');
    //'rgba(200,200,200,0.5)');
}
$Plot->setGridAboveData();
if ($All) {
Exemplo n.º 4
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();
Exemplo n.º 5
0
$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);
$Plot->setYTicks(1, 2, 0);
$Plot->addYAxis(2, 'right', false);
$Plot->addYUnit(2, 'bpm', 0);
$Plot->setYTicks(2, 1, 0);
if ($Wunschgewicht > 1) {
    $Plot->addThreshold('y1', $Wunschgewicht);
    $Plot->addMarkingArea('y1', $Wunschgewicht, 0);
}
if (empty($Data)) {
    $Plot->raiseError(__('No data available.'));
} elseif (min(min($Weights), min($HRrests)) == 0 || count($Weights) <= 1) {
    $Plot->setZeroPointsToNull();
    $Plot->lineWithPoints();
    $Plot->Options['series']['curvedLines']['apply'] = false;
}
Exemplo n.º 6
0
        $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);
$Plot->setYTicks(1, 1, 0);
$Plot->addYAxis(2, 'right');
$Plot->addYUnit(2, '%', 0);
$Plot->setYTicks(1, 1, 0);
if (empty($Data)) {
    $Plot->raiseError(__('No data available.'));
} elseif (min(min($Adiposes), min($Water), min($Muscles)) == 0 || count($Adiposes) <= 1) {
    $Plot->setZeroPointsToNull();
    $Plot->lineWithPoints();
    $Plot->Options['series']['curvedLines']['apply'] = false;
}
$Plot->outputJavaScript(true);
Exemplo n.º 7
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']] = (int) $dat['temp'];
}
$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, '°C', 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();
Exemplo n.º 8
0
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->PlotOptions['allowSelection'] = false;
$Plot->addYAxis(1, 'left');
$Plot->addYUnit(1, $Weight->unit(), 1);
$Plot->setYTicks(1, 2, 0);
$Plot->addYAxis(2, 'right', false);
$Plot->addYUnit(2, 'bpm', 0);
$Plot->setYTicks(2, 1, 0);
if ($Wunschgewicht > 1) {
    $Plot->addThreshold('y1', $Wunschgewicht);
    $Plot->addMarkingArea('y1', $Wunschgewicht, 0);
}
if (empty($Data)) {
    $Plot->raiseError(__('No data available.'));
} elseif (min(min($Weights), min($HRrests)) == 0 || count($Weights) <= 1) {
    $Plot->setZeroPointsToNull();
    $Plot->lineWithPoints();
    $Plot->Options['series']['curvedLines']['apply'] = false;
}