View unanswered posts | View active topics It is currently Mon Jun 24, 2024 4:59 am

Reply to topic  [ 1 post ] 
Array of Time 
Author Message
New pChart user
New pChart user

Joined: Fri Nov 15, 2013 8:01 pm
Posts: 1
Post Array of Time
Hello, I've noticed that using the library to process time values with the following format: hh:mm:ss, the graph is not properly visualized.
Someone can tell me how to avoid this?

This is the code i have produced:

/* Library settings */
define("CLASS_PATH", "../../../class");
define("FONT_PATH", "../../../fonts");

/* pChart library inclusions */

/* Create and populate the pData object */
$MyData = new pData(); 
//print "::pData";
$curData = date("Y-m-d");
/* Connect to the MySQL database */
$db = mysql_connect("localhost", "root", "password");

/* Build the query that will returns the data to graph */
$Requete = "SELECT * FROM test.eo_data WHERE uid=1 and data='".$curData."';";
//print $Requete;
$Result  = mysql_query($Requete,$db);
//print $Result;
while($row = mysql_fetch_array($Result))
  //print_r ($row);
  /* Get the data from the query result */
     $ora = $ora.",".$row["ora"];
    }else $ora = $row["ora"];
     $energia = $energia.",".$row["energia_conteggiata"];
    }else $energia = $row["energia_conteggiata"];
     $fatpot = $fatpot.",".$row["fattore_potenza"];
    }else $fatpot = $row["fattore_potenza"];
     $tens = $tens.",".$row["tensione"];
    }else $tens = $row["tensione"];

/* Save the data in the pData array */
$MyData->addPoints(array($energia),"Energia Conteggiata");
$MyData->addPoints(array($fatpot),"Fattore Potenza");
/* Put the timestamp column on the abscissa axis */
//print "::Load done settings";

/* Create the pChart object */
$myPicture = new pImage(800,230,$MyData);

/* Retrieve the image map */
if (isset($_GET["ImageMap"]) || isset($_POST["ImageMap"]))

/* Set the image map name */

/* Turn of Antialiasing */
$myPicture->Antialias = FALSE;

/* Draw the background */
$Settings = array("R"=>170, "G"=>183, "B"=>87, "Dash"=>1, "DashR"=>190, "DashG"=>203, "DashB"=>107);

/* Overlay with a gradient */
$Settings = array("StartR"=>219, "StartG"=>231, "StartB"=>139, "EndR"=>1, "EndG"=>138, "EndB"=>68, "Alpha"=>50);

/* Add a border to the picture */

/* Set the default font */

/* Define the chart area */

/* Draw the scale */
$scaleSettings = array("GridR"=>200,"GridG"=>200,"GridB"=>200,"DrawSubTicks"=>TRUE,"CycleBackground"=>TRUE);

/* Write the chart legend */

/* Turn on shadow computing */

/* Draw the chart */
$Settings = array("RecordImageMap"=>TRUE);

/* Render the picture (choose the best way) */

In particular i expected six bar related to two differents times.

Attached the graph produced!!
Another question, the data scale is automatically adjusted or are there any functions that i can use to do this?

Thank you

pChartTest1.png [ 9.22 KiB | Viewed 17219 times ]
Fri Nov 15, 2013 8:11 pm
Display posts from previous:  Sort by  
Reply to topic   [ 1 post ] 

Who is online

Users browsing this forum: No registered users and 1 guest

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: