Salve.
Ho scaricato un template di un chart.
Precisamente questo:
http://razorflow.com/
Vorrei impostarlo per monitorare i download di un file in tempo reale.
ecco il codice sorgente del chart.php
codice:
<?php
require "razorflow.php";
Dashboard::setTitle("Chart Component");
// Get the sample DataSource
$dataSource = RFUtil::getSampleDataSource();
$genreChart = new ChartComponent();
$genreChart->setWidth(4);
$genreChart->setCaption("Downloads");
$genreChart->setDataSource($dataSource);
$genreChart->setLabelExpression("Day", "InvoiceDate", array(
'timestampRange' => true,
'timeUnit' => 'day'
));
$genreChart->addSeries("Downloads", 'Quantity', array(
'condition' => "genre.Name = 'Downloads'",
'displayType' => 'Line'
));
Dashboard::addComponent($genreChart);
Dashboard::Render();
Il mio problema è impostare in modo corretto $dataSource e fare in modo che invece di avere una data fissa, il grafico vada avanti in tempo reale, giorno per giorno.
Se non sbaglio il seguente grafico usa sql.
Questo è il codice sorgente del RFUtil.php
codice:
<?php
class RFUtil {
protected static $url;
public static function RequestRedirect($url) {
self::$url = $url;
}
public static function emitJson ($object, $extraHeaders = array()) {
if(headers_sent()) {
die("Error! Please do not send any data directly to the browser. For logging, use Dashboard::log instead");
}
if(PHP_SAPI !== "cli")
{
// Set the content-type header.
foreach($extraHeaders as $header)
{
header($header);
}
// VERY AGGRESSIVELY PREVENT CACHING!!!
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
header("Cache-Control: no-store, no-cache, must-revalidate");
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache");
// Ensure it's parsed as JSON
header('Content-Type: application/json;');
}
if(RFConfig::isSetAndTrue('debug'))
{
$object['logs'] = RFLog::__getMessages ();
$object['rfdt'] = array(
'queries' => RFDevTools::getQueries (),
'dataSources' => RFDevTools::getDataSources(),
'diagnostics' => RFDevTools::getDiagnostics()
);
}
if(isset(self::$url))
{
$object['redirect'] = self::$url;
}
$GLOBALS['rfDisableErrors'] = true;
echo json_encode($object);
exit();
}
/**
* Throw an exception into JSON.
*
* @param Exception $ex
*/
public static function Exception (Exception $ex) {
RFLog::log("[ERROR][ERROR][ERROR][ERROR][ERROR][ERROR][ERROR][ERROR]");
RFLog::log("Exception: ". $ex->getMessage());
$trace = $ex->getTrace();
if(isset($trace[0]['file']) && isset($trace[0]['line']))
RFLog::log("Trace: ". $trace[0]['file'].":".$trace[0]['line']);
RFLog::log("[ERROR][ERROR][ERROR][ERROR][ERROR][ERROR][ERROR][ERROR]");
$traceMsg = "";
foreach($ex->getTrace() as $item)
{
if(isset($item['file']) && $item['line'])
$traceMsg .= $item['file'].":".$item['line']."\n";
}
$object = array(
'message' => $ex->getMessage(),
'trace' => $traceMsg,
'error' => 'RazorflowException'
);
$extraHeaders = array(
'HTTP/1.1 500 Internal Exception;',
'X-RazorFlow-Info: Exception'
);
self::emitJson($object, $extraHeaders);
}
public static function Error ($message, $trace = "") {
RFLog::log("[ERROR][ERROR][ERROR][ERROR][ERROR][ERROR][ERROR][ERROR]");
RFLog::log("Message: ", $message);
RFLog::log("Trace: ", $trace);
RFLog::log("[ERROR][ERROR][ERROR][ERROR][ERROR][ERROR][ERROR][ERROR]");
$object = array(
'message' => $message,
'trace' => $trace,
'error' => 'RazorflowError'
);
$extraHeaders = array(
'HTTP/1.1 500 Internal Exception;',
'X-RazorFlow-Info: Error'
);
if(!RFRequest::isHTMLRequest())
{
self::emitJson($object, $extraHeaders);
}
}
public static function getSampleDataSource ()
{
if(!isset(self::$sampleDs))
{
self::$sampleDs = new SQLiteDataSource(RF_FOLDER_ROOT."/demos/databases/chinook.sqlite");
self::$sampleDs->setSQLSource("InvoiceLine JOIN Invoice ON Invoice.InvoiceId = InvoiceLine.InvoiceId JOIN Track ON Track.TrackId = InvoiceLine.TrackId JOIN Album ON Track.AlbumId = Album.AlbumId JOIN Artist ON Album.ArtistId = Artist.ArtistId JOIN Genre ON Track.GenreId = Genre.GenreId");
}
return self::$sampleDs;
}
public static function getTempDir () {
// Get the temporary directory.
return sys_get_temp_dir();
}
public static function isCLI() {
return PHP_SAPI === "cli";
}
protected static $sampleDs;
}
è possibile fare una cosa del genere?
Qualcuno può darmi una mano per favore?