I'm really hoping someone can help here as I a 24hour graph working but need help on a 96hour historical graph using the same script. The attached script for the y axis data is perfect. I now have the X axis plotting 96hrs worth of timestamp titles in 8 hour increments. You can see the chart at www.auburnweatherlive.com/testgraph99.php.
What I need to do now is plot the time on the x axis in 12hr time vs the current 24hr time. The data being graphed is at www.auburnweatherlive.com/test99datapull.php . I need this data graphed in 12 vs 24hr time. 9am, 11am, 2pm 11pm etc.
So using the data in test99datapull.php, the graph would look like:
8am 4pm 12am 8am 4pm 12am 8am 4pm 12am 8am
the y axis does not change as it is perfect.
Lastly – not to push my luck – it would be really nice to plot the current temp from the last y position of the data file in the middle of the Graph in big numbers like at TNET Weather http://www.tnetweather.com/graphs/pool.png
Something Like:
41.5 (degree symbol) F
Current Pool Temp
If there is a writeup or something on how I would go about this it would be great. I don’t expect everyone to do my work for me, but hoping the above is something easy for someone knowledgeable with php code.
<?php
//where are your clientraw*-files relative to where this file is
$hostloc = "./";
include ("jp/src/jpgraph.php"); //maybe you have to change this path
include ("jp/src/jpgraph_line.php"); //maybe you have to change this path
// CtoF: converts degrees Celcius to degress Farenheight
function CtoF(&$value) {
return round($value = ((1.8* $value) + 32),1);
} // end function C_to_F
// Create the graph and specify the scale for Y-axis
$graph = new Graph(400,250,"auto",30);
$graph->SetScale("textlin");
$graph->SetShadow();
$graph->SetMarginColor("#191970");
$graph->img->SetAntiAliasing();
$url = "http://www.auburnweatherlive.com/testdatapull.php"; // this is the page where you get the information
$str = file_get_contents($url); // retrieve the content of the page. This results in one single string with all the content
$str = ereg_replace("<br/>"," ","$str"); // replace <br/> by an empty space otherwise you will get a problem
$str = ereg_replace("X_Axis ="," ","$str"); // replace X_Axis by an empty space
$str = ereg_replace("Y_Axis =","xx","$str"); // replace Y_Axis by xx. This xx I use as a seperator between the x an y value
$data = explode("xx", $str); // xx is the separator. You will get two strings in $data
$x = $data[0]; // first part of $data is the X_Axis data
$y = $data[1]; // second part of $data is the Y_Axis data
$datat = explode(" ", $x); // make an array of $x
$ydata = explode(" ", $y); // make an array of $y
// =====================================================================================
// From here we start creating the graphs
// =====================================================================================
// Adjust the margin
$graph->img->SetMargin(40,40,20,65);
// Create the two linear plot
$lineplot=new LinePlot($ydata);
// Add the plot to the graph
$graph->Add($lineplot);
//titles
$graph->title->Set("24 Hour Pool Temp");
$graph->title->SetFont(FF_FONT1,FS_BOLD,10);
$graph->title->SetColor("white");
//$graph->xaxis->title->Set("X-title");
//$graph->yaxis->title->Set("Y-title");
//x-axis
$time=date("M j",time());
$graph->xaxis->title->Set("\n$time");
$graph->xaxis->title->SetColor(white);
$graph->xaxis->SetColor("white");
$graph->xaxis->SetTickLabels($datat);
$graph->xaxis->SetFont(FF_FONT1,FS_NORMAL,4);
$graph->xaxis->SetTextLabelInterval(8);
$graph->xaxis->HideTicks(true,true);
$graph->xaxis->SetPos("min");
$graph->xgrid->Show(true);
//y-axis
$graph->yaxis->SetColor("red");
$graph->yaxis->SetLabelFormat('%0.0f°F');
$graph->yaxis->scale->SetGrace(5);
$graph->yaxis->HideTicks(true,true);
// Set the colors for the plots
$lineplot->SetColor("red");
// Set the legends for the plots
$lineplot->SetLegend("Temperature");
// Adjust the legend position
$graph->legend->SetLayout(LEGEND_HOR);
$graph->legend->Pos(0.5,0.9,"center","center");
// Display the graph
$graph->Stroke();
?>