I am currently experimenting with a sort of basic reporting with charts. I already was successful with "timeplot" http://simile.mit.edu/ (and your help with the sql statement ), but it is not really handy.
So now i give Googlecharts a try. These Charts are simply embedded in an image Url. eg.
- Code: Select all
<img src="http://chart.apis.google.com/chart?cht=lc&chd=s:cEAELFJHHHKUju9uuXUccEAE&chco=76A4FB&chls=2.0,0.0,0.0&chs=600x125&chg=7,10,1,0&chxt=x,y&chxl=0:%7Cwoche1%7Cwoche2%7Cwoche3%7Cwoche4%7Cwoche5%7Cwoche6%7Cwoche7%7Cwoche8%7Cwoche9%7C1:%7C0km%7C50km%7C100km" alt="Line chart with 5 vertical and two horizontal pale gray, solid grid lines">
This should even work in PhpBB
Some Clever folks already Ported this to a PHP Class, see: http://luddep.se/notebook/2008/04/charts_with_php_and_google_charts_api
after the Class is included you could simply create a chart like this
- Code: Select all
<?php
/** Include class */
include( 'GoogChart.class.php' );
/** Create chart */
$chart = new GoogChart();
// Set timeline graph data
$dataTimeline = array(
'2007' => array(
'January' => 31.0,
'February' => 31.2,
'March' => 41.8,
'April' => 52.9,
'May' => 53.7,
'June' => 54.0,
'July' => 64.5,
'August' => 64.9,
'September' => 55.4,
'Oktober' => 36.0,
'November' => 66.3,
'December' => 36.3,
),
'2006' => array(
'January' => 25.0,
'February' => 24.5,
'March' => 24.5,
'April' => 22.9,
'May' => 22.9,
'June' => 25.5,
'July' => 25.5,
'August' => 24.9,
'September' => 27.3,
'Oktober' => 27.3,
'November' => 29.9,
'December' => 29.9,
),
'2005' => array(
'January' => 15.0,
'February' => 14.5,
'March' => 14.5,
'April' => 12.9,
'May' => 12.9,
'June' => 15.5,
'July' => 15.5,
'August' => 14.9,
'September' => 17.3,
'Oktober' => 17.3,
'November' => 19.9,
'December' => 19.9,
),
);
/* # Chart 3 # */
echo '<h2>Timeline</h2>';
$chart->setChartAttrs( array(
'type' => 'sparkline',
'title' => 'Trainingsentwicklung ',
'data' => $dataTimeline,
'size' => array( 800, 200 ),
'color' => $color,
'labelsXY' => true,
'fill' => array( '#ffffff', '#ffffff' ),
));
// Print chart
echo $chart;
?>
I was wondering , if i included this class wthin a tables delegate class and outputting the above snippet to a block eg:
- Code: Select all
function block__before_main_column(){
rest of the above snippet , exept the data arrays
echo $chart
return true;
}
this could be a dead easy way to do some chart art in dataface
I think I could manage to get the data to an array like the one above with a SQL statement but would't it be much cooler to do this the dataface way
I mean when i am in a delegate class for a Table , isn't it possible to get to the data like :
- Code: Select all
$record->val('time entry');
Now the Question:
How to get the data out of a table (based on user or owner) into an assoc array like the one above
Hope this makes sense
cheers Martin