Hi there,
I struggled for a while to understand how to display a chart (bar graph or other charts) inside a tile. I checked on the forum but I never saw something straight forward like the below, so I am sharing it.
Basically, I solved that by referencing a php script as an icon url that runs on my server.
The php runs pChart which is a php charting library.
So the DTH always points the same picture while the content is updated by the server running the php.
Example of DTH tile:
standardTile("chart", "device.chart", width: 6, height: 5, canChangeIcon: false ) { state "default", label: 'my chart', icon: "http://192.168.1.49/chart.php"
Which leads to this:
The php code to generate that chart is simply:
<?php session_start(); include "./pChart/class/pDraw.class.php"; include "./pChart/class/pImage.class.php"; include "./pChart/class/pData.class.php"; /* Create your dataset object */ $myData = new pData;
/* Add data in your dataset */
$myData->addPoints(array(VOID, 3,4,3,5));
/* Create a pChart object and associate your dataset */
$myPicture = new pImage(700,230,$myData);
/* Define the boundaries of the graph area */
$myPicture->setGraphArea(60,40,670,190);
/* Choose a nice font */
$myPicture->setFontProperties(array(“FontName”=>“/usr/share/fonts/truetype/freefont/FreeSansBold.ttf”,“FontSize”=>11));
/* Draw the scale, keep everything automatic */
$myPicture->drawScale();
/* Draw the scale, keep everything automatic */
$myPicture->drawSplineChart();
/* Build the PNG file and send it to the web browser */
$myPicture->Stroke();
?>
More about pChart on: http://www.pchart.net/
Have fun!