Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /* pChart library inclusions */
- include("pchart/class/pData.class.php");
- include("pchart/class/pDraw.class.php");
- include("pchart/class/pImage.class.php");
- $con = mysql_connect("","","");
- if (!$con)
- {
- die('Could not connect: ' . mysql_error());
- }
- mysql_select_db("weather",$con);
- $result = mysql_query("SELECT hour(time) as time, temp_out FROM wmr200 WHERE date(time) = curdate()");
- $time = array();
- $temp = array();
- while($row = mysql_fetch_array($result))
- {
- $time[] = $row['time'];
- $temp[] = $row['temp_out'];
- }
- $prev = -1;
- foreach ($time as &$hour) {
- if ($prev === $hour) {
- $hour = NULL;
- }
- else {
- $prev = $hour;
- }
- }
- mysql_close($con);
- /* Create and populate the pData object */
- $MyData = new pData();
- $MyData->addPoints($temp,"Temperature");
- $MyData->addPoints($time,"Time");
- $MyData->setAxisName(0,"Temperature °C");
- $MyData->setSerieTicks("Time",1000);
- $MyData->setAbscissa("Time");
- #$MyData->setXAxisDisplay(AXIS_FORMAT_TIME,"H");
- /* Create the pChart object */
- $myPicture = new pImage(600,400,$MyData);
- /* Draw the background */
- #$Settings = array("R"=>170, "G"=>183, "B"=>87, "Dash"=>1, "DashR"=>190, "DashG"=>203, "DashB"=>107);
- #$myPicture->drawFilledRectangle(0,0,700,230,$Settings);
- /* Draw the scale and the 1st chart */
- $myPicture->setGraphArea(50,20,550,130);
- $myPicture->drawScale(array("DrawSubTicks"=>FALSE,"DisplayValues"=>FALSE,"LabelRotation"=>0));
- $myPicture->drawLineChart(array("DisplayValues"=>FALSE,"DisplayColor"=>DISPLAY_AUTO));
- $myPicture->setShadow(FALSE);
- $myPicture->Antialias = FALSE;
- /* Render the picture (choose the best way) */
- $myPicture->autoOutput("pictures/example.drawLineChart.png");
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement