Hello,
I’m pretty new here, but i know Piwik for a long time. My knowledge of php are modest, but well I know quite a few lines of code and links. Piwik is indeed very powerful and offers the opportunity to evaluate their own data.
And there begins my problem. Because this possibility is, in my opinion, very poorly described.
Under piwik\plugins\ExampleUI\ you have all what you need, or?
In the present there is indeed found api.php following lines of code:
public function getTemperaturesEvolution($date, $period)
{
$period = new Piwik_Period_Range($period, 'last30');
$dateStart = $period->getDateStart()->toString('Y-m-d'); // eg. "2009-04-01"
$dateEnd = $period->getDateEnd()->toString('Y-m-d'); // eg. "2009-04-30"
// here you could select from your custom table in the database, eg.
$query = "SELECT AVG(temperature)
FROM server_temperatures
WHERE date > ?
AND date < ?
GROUP BY date
ORDER BY date ASC";
//$result = Piwik_FetchAll($query, array($dateStart, $dateEnd));
// to keep things simple, we generate the data
But why is there no “how-to” access to external databases and spreadsheets and then use these values for themselves:
foreach($period->getSubperiods() as $subPeriod)
{
$server1 = rand(50,90);
$server2 = rand(40, 110);
$value = array('server1' => $server1, 'server2' => $server2);
$temperatures[$subPeriod->getLocalizedShortString()] = $value;
}
$xAxis = array(
'0h', '1h', '2h', '3h', '4h', '5h', '6h', '7h', '8h', '9h', '10h', '11h',
'12h', '13h', '14h', '15h', '16h', '17h', '18h', '19h', '20h', '21h', '22h', '23h',
);
$temperatureValues = array_slice(range(50,90), 0, count($xAxis));
shuffle($temperatureValues);
$temperatures = array();
foreach($xAxis as $i => $xAxisLabel) {
$temperatures[$xAxisLabel] = $temperatureValues[$i];
}
Maybe someone here has knowledge & time to help me?
Thank you in advance,
DeepX