Halling Weather now PHP

Firstly thanks to Mike Challis & Ken True also Stuart of Broadstairs site (and others involded in these templates and scripts) 8)

I have revamped my site to the new Carterlake PHP / Ajax templates and moved to a new server, went from 2Gb to 125gb bandwidth, no more worrying about too many visitors!!

I have tweeked a few things here and there and tried to have as many “add-ons” as poss. ie Fly-out menu, Jp/Wx Graphs, Various WDLive pages including seperate Rain temp grapgh pages. The new Contact page is excellent (Thanks Mike)

What other extras can I have (not Meso or WxSim) :lol: Without over “Blinging” it

Have browse feel free to have input.

Regards Matt

www.halling-weather.co.uk

What other extras can I have

Don’t forget this one…WordPress Blog Add On for Carterlake/AJAX/PHP Templates Now Available :smiley:

Regards,

Jack

I remember looking at Hailing some time ago (when you first got a site?).

It’s interesting how highly pitched all the roofs are… and it appears most people use car ports or a pad of concrete instead of a driveway.

It’s also amazing to see how well kept (and uncluttered) everyone’s lawn is. You can’t go 3 houses away most places in the US without having a junk-collecting neighbor.

Now updated with NEW JPgraphs, seperated and some with shading and also WUHistory page. Also new photo album with snaps from the Village.

Thanks again all involved in the scripts, graphs and templates.

I Keep finding things to add, it’s addictive :slight_smile:

Well done. :slight_smile: You may want to change your title tag to something more descriptive than - Home. Especially for folks that will bookmark your great new web site.

Job done, missed that, along with lots of other things probably :slight_smile:

Thanks for that - I didn’t realise it’s that was takes the bookmark title and not the URL 8)

I think your site is very nice, it’s always nice when people put a little bit more into it than just the default stuff. :slight_smile:

Best Regards,
Martin

Matt,

Do you mind sharing the code for your jpgraph grahps?
I’ve tried to make them similar, to get them to fill with color etc but I can’t do it. #-o

And I’ve looked for a pure 24-hour temperature graph (without hum/dew) but I can’t find it.

Best Regards,
Martin

Sorry for the late reply. The temp graph is a rework of temp/dew/hum, I just deleted those sections.

Here is the code to get the shading fill, just adapt if to what you want. The smileys have crept in, just replace the cool smiley with 8 ) without the gap!

<?php
// Graphs Package V2.1 16th March 2008
if (!file_exists("graphsconf.php")) include("error_msg.php");
include ("graphsconf.php");
if (!file_exists($jploc."jpgraph.php")) {
  $string = "Unable to find JPGraph files";
  create_image1($string,$jploc);
  exit;
}
include ($jploc."jpgraph.php");
include ($jploc."jpgraph_line.php");

$clientrawextra = get_raw("${hostloc}clientrawextra.txt");

//temp=========================================================================
$y=array($clientrawextra['21'],$clientrawextra['22'],$clientrawextra['23'],$clientrawextra['24'],
$clientrawextra['25'],$clientrawextra['26'],$clientrawextra['27'],$clientrawextra['28'],$clientrawextra['29'],
$clientrawextra['30'],$clientrawextra['31'],$clientrawextra['32'],$clientrawextra['33'],$clientrawextra['34'],
$clientrawextra['35'],$clientrawextra['36'],$clientrawextra['37'],$clientrawextra['38'],$clientrawextra['39'],
$clientrawextra['40'],$clientrawextra['566'],$clientrawextra['567'],$clientrawextra['568'],$clientrawextra['569']);
$datay = $y;

//hum=============================================================================
$y=array($clientrawextra['611'],$clientrawextra['612'],$clientrawextra['613'],$clientrawextra['614'],
$clientrawextra['615'],$clientrawextra['616'],$clientrawextra['617'],$clientrawextra['618'],$clientrawextra['619'],
$clientrawextra['620'],$clientrawextra['621'],$clientrawextra['622'],$clientrawextra['623'],$clientrawextra['624'],
$clientrawextra['625'],$clientrawextra['626'],$clientrawextra['627'],$clientrawextra['628'],$clientrawextra['629'],
$clientrawextra['630'],$clientrawextra['631'],$clientrawextra['632'],$clientrawextra['633'],$clientrawextra['634']);
$datay2 = $y;

//dew=============================================================================
$y=array(
dp($datay[0],$datay2[0]),dp($datay[1],$datay2[1]),dp($datay[2],$datay2[2]),dp($datay[3],$datay2[3]),
dp($datay[4],$datay2[4]),dp($datay[5],$datay2[5]),dp($datay[6],$datay2[6]),dp($datay[7],$datay2[7]),
dp($datay[8],$datay2[8]),dp($datay[9],$datay2[9]),dp($datay[10],$datay2[10]),dp($datay[11],$datay2[11]),
dp($datay[12],$datay2[12]),dp($datay[13],$datay2[13]),dp($datay[14],$datay2[14]),
dp($datay[15],$datay2[15]),dp($datay[16],$datay2[16]),dp($datay[17],$datay2[17]),
dp($datay[18],$datay2[18]),dp($datay[19],$datay2[19]),dp($datay[20],$datay2[20]),
dp($datay[21],$datay2[21]),dp($datay[22],$datay2[22]),dp($datay[23],$datay2[23])  );
$datay3 = $y;

if ($temp_conv == 1.8) {
	array_walk($datay, "CtoF");
	array_walk($datay3, "CtoF");
	}

//Check for negative values in array and do a SetAuotMin(0) if none
array_walk($datay, "NegVal");
$negvalue1 = $negvalue;

// Check for positive values in array
array_walk($datay, "PosVal");
$posvalue1 = $posvalue;

$negvalue = 0;
$posvalue = 0;

//Check for negative values in array and do a SetAuotMin(0) if none
array_walk($datay3, "NegVal");
$negvalue3 = $negvalue;

// Check for positive values in array
array_walk($datay3, "PosVal");
$posvalue3 = $posvalue;

if (($negvalue1 == 1) or ($negvalue3 == 1)) $negvalue = 1;
if (($posvalue1 == 1) or ($posvalue3 == 1)) $posvalue = 1;
if (($negvalue1 == 0) and ($negvalue3 == 0)) $negvalue = 0;
if (($posvalue1 == 0) and ($posvalue3 == 0)) $posvalue = 0;

if ($negvalue == 0) {
  if ($temp_conv == 1) $automin = '$graph->yaxis->scale->SetAutoMin(0);';
  if ($temp_conv == 1.8) $automin = '$graph->yaxis->scale->SetAutoMin(32);';
  $grace = '$graph->yaxis->scale->SetGrace(20);';
}
if (($negvalue == 1) and ($posvalue == 0)) {
  if ($temp_conv == 1) $automin = '$graph->yaxis->scale->SetAutoMax(0);';
  if ($temp_conv == 1.8) $automin = '$graph->yaxis->scale->SetAutoMax(32);';
  $grace = '$graph->yaxis->scale->SetGrace(0,20);';
}
if (($negvalue == 1) and ($posvalue == 1)) {
  $automin = '';
  $grace = '$graph->yaxis->scale->SetGrace(20,20);';
}

//create timearray for the x-axis
$x=array($clientrawextra['459'],$clientrawextra['460'],$clientrawextra['461'],$clientrawextra['462'],
$clientrawextra['463'],$clientrawextra['464'],$clientrawextra['465'],$clientrawextra['466'],$clientrawextra['467'],
$clientrawextra['468'],$clientrawextra['469'],$clientrawextra['470'],$clientrawextra['471'],$clientrawextra['472'],
$clientrawextra['473'],$clientrawextra['474'],$clientrawextra['475'],$clientrawextra['476'],$clientrawextra['477'],
$clientrawextra['478'],$clientrawextra['578'],$clientrawextra['579'],$clientrawextra['580'],$clientrawextra['581']);
$datax = $x;

// Create the graph and specify the scale for both Y-axis
$graph = new Graph($xsize,$ysize,"auto",30);    
$graph->SetScale("textlin");

$graph->SetShadow();
$graph->SetMarginColor("$margincolour");

// Adjust the margin
$graph->SetMargin($lm,$rm,$tm,$bm);

// Create the two linear plot
$lplot1=new LinePlot($datay);    // Temp






// Add the plot to the graph
$graph->Add($lplot1);


//titles
$graph->title->Set("$txt_temp - Last 24 hrs ($temp_unit)");
$graph->title->Align("center","top");
$graph->title->SetFont(FF_ARIAL,FS_BOLD,10);
$graph->title->SetColor("$textcolour");

//x-axis
$graph->xaxis->title->SetColor("$xtextcolour");
$graph->xaxis->title->Set("$txt_24h");
$graph->xaxis->title->SetFont(FF_ARIAL,FS_BOLD,8);
$graph->xaxis->SetFont(FF_ARIAL,FS_BOLD,8);
$graph->xaxis->SetTitlemargin(25);
$graph->xaxis->SetLabelMargin(10);
$graph->xaxis->SetTickLabels($datax);
$graph->xaxis->SetLabelAngle($label_angle);
$graph->xaxis->SetTextLabelInterval($label_interval);
$graph->xaxis->SetPos("min"); 
$graph->xaxis->HideTicks(true,true); 
$graph->xaxis->SetColor("$xtextcolour"); 
$graph->xgrid->Show(true);

//y-axis
$graph->yaxis->SetFont(FF_ARIAL,FS_BOLD,8);
$graph->yaxis->SetColor("$ytextcolour");
$graph->yaxis->SetLabelFormat("%0.0f");
$graph->yaxis->HideTicks(false,false);
eval($automin);
eval($grace);

//y2-axis
//$graph->y2axis->SetFont(FF_ARIAL,FS_BOLD,8);
//$graph->y2axis->SetColor("$y2textcolour");
//$graph->yaxis->SetLabelFormat("$temp_format");
//$graph->y2axis->HideTicks(true,true); 
//$graph->y2axis->scale->SetAutoMin(0);

// Set the colors for the plots
$lplot1->SetColor("$temp_col1");
[b]$lplot1->SetFillColor("#[email protected]");[/b]
if (($negvalue1 == 1) and ($posvalue1 == 0)) $lplot1->SetColor("$temp_col2");
if (($negvalue1 == 1) and ($posvalue1 == 1)) $lplot1->SetColor("$temp_col3");
$lplot1->SetWeight(1);




[b]// Setup a background gradient image
$graph->SetBackgroundGradient('white','navy:0.5',GRAD_HOR,BGRAD_PLOT);[/b]

$graph->img->SetAntiAliasing();

// Set the legends for the plots
$graph->legend->SetFont(FF_ARIAL,FS_NORMAL,7);
$lplot1->SetLegend("$txt_temp1");

// Adjust the legend position
$graph->legend->SetLayout(LEGEND_HOR);
$graph->legend->Pos(0.02,0.01,'right','top');

// Display the graph
$graph->Stroke();

?>

If you use the code tag, you won’t get smileys in the output.

You were using the sub tag.

Matt, thanks for the code. I can’t get it to work though, it won’t draw the image.

I can see that some code has been changed, for instance ydata is datay in your code. Has that got something to do with it?

Here is the code using the correct format for this site, (so the smileys don’t creep in :oops:)

Now copy it to wordpad and then take the code from temp+dew+hum_24hr.php from the WXgraph folder. Then if you look section by section you’ll see the differences. Or just copy the original code place somewhere safe (just in case) and replace with this code and it should work.

The grad fill is just this part:
[i]
// Set the colors for the plots
$lplot1->SetColor(“$temp_col1”);
$lplot1->SetFillColor(“#ff3300@0.5”);
if (($negvalue1 == 1) and ($posvalue1 == 0)) $lplot1->SetColor(“$temp_col2”);
if (($negvalue1 == 1) and ($posvalue1 == 1)) $lplot1->SetColor(“$temp_col3”);
$lplot1->SetWeight(1);

// Setup a background gradient image
$graph->SetBackgroundGradient(‘white’,‘navy:0.5’,GRAD_HOR,BGRAD_PLOT);

$graph->img->SetAntiAliasing();
[/i]


<?php
// Graphs Package V2.1 16th March 2008
if (!file_exists("graphsconf.php")) include("error_msg.php");
include ("graphsconf.php");
if (!file_exists($jploc."jpgraph.php")) {
  $string = "Unable to find JPGraph files";
  create_image1($string,$jploc);
  exit;
}
include ($jploc."jpgraph.php");
include ($jploc."jpgraph_line.php");

$clientrawextra = get_raw("${hostloc}clientrawextra.txt");

//temp=========================================================================
$y=array($clientrawextra['21'],$clientrawextra['22'],$clientrawextra['23'],$clientrawextra['24'],
$clientrawextra['25'],$clientrawextra['26'],$clientrawextra['27'],$clientrawextra['28'],$clientrawextra['29'],
$clientrawextra['30'],$clientrawextra['31'],$clientrawextra['32'],$clientrawextra['33'],$clientrawextra['34'],
$clientrawextra['35'],$clientrawextra['36'],$clientrawextra['37'],$clientrawextra['38'],$clientrawextra['39'],
$clientrawextra['40'],$clientrawextra['566'],$clientrawextra['567'],$clientrawextra['568'],$clientrawextra['569']);
$datay = $y;

//hum=============================================================================
$y=array($clientrawextra['611'],$clientrawextra['612'],$clientrawextra['613'],$clientrawextra['614'],
$clientrawextra['615'],$clientrawextra['616'],$clientrawextra['617'],$clientrawextra['618'],$clientrawextra['619'],
$clientrawextra['620'],$clientrawextra['621'],$clientrawextra['622'],$clientrawextra['623'],$clientrawextra['624'],
$clientrawextra['625'],$clientrawextra['626'],$clientrawextra['627'],$clientrawextra['628'],$clientrawextra['629'],
$clientrawextra['630'],$clientrawextra['631'],$clientrawextra['632'],$clientrawextra['633'],$clientrawextra['634']);
$datay2 = $y;

//dew=============================================================================
$y=array(
dp($datay[0],$datay2[0]),dp($datay[1],$datay2[1]),dp($datay[2],$datay2[2]),dp($datay[3],$datay2[3]),
dp($datay[4],$datay2[4]),dp($datay[5],$datay2[5]),dp($datay[6],$datay2[6]),dp($datay[7],$datay2[7]),
dp($datay[8],$datay2[8]),dp($datay[9],$datay2[9]),dp($datay[10],$datay2[10]),dp($datay[11],$datay2[11]),
dp($datay[12],$datay2[12]),dp($datay[13],$datay2[13]),dp($datay[14],$datay2[14]),
dp($datay[15],$datay2[15]),dp($datay[16],$datay2[16]),dp($datay[17],$datay2[17]),
dp($datay[18],$datay2[18]),dp($datay[19],$datay2[19]),dp($datay[20],$datay2[20]),
dp($datay[21],$datay2[21]),dp($datay[22],$datay2[22]),dp($datay[23],$datay2[23])  );
$datay3 = $y;

if ($temp_conv == 1.8) {
	array_walk($datay, "CtoF");
	array_walk($datay3, "CtoF");
	}

//Check for negative values in array and do a SetAuotMin(0) if none
array_walk($datay, "NegVal");
$negvalue1 = $negvalue;

// Check for positive values in array
array_walk($datay, "PosVal");
$posvalue1 = $posvalue;

$negvalue = 0;
$posvalue = 0;

//Check for negative values in array and do a SetAuotMin(0) if none
array_walk($datay3, "NegVal");
$negvalue3 = $negvalue;

// Check for positive values in array
array_walk($datay3, "PosVal");
$posvalue3 = $posvalue;

if (($negvalue1 == 1) or ($negvalue3 == 1)) $negvalue = 1;
if (($posvalue1 == 1) or ($posvalue3 == 1)) $posvalue = 1;
if (($negvalue1 == 0) and ($negvalue3 == 0)) $negvalue = 0;
if (($posvalue1 == 0) and ($posvalue3 == 0)) $posvalue = 0;

if ($negvalue == 0) {
  if ($temp_conv == 1) $automin = '$graph->yaxis->scale->SetAutoMin(0);';
  if ($temp_conv == 1.8) $automin = '$graph->yaxis->scale->SetAutoMin(32);';
  $grace = '$graph->yaxis->scale->SetGrace(20);';
}
if (($negvalue == 1) and ($posvalue == 0)) {
  if ($temp_conv == 1) $automin = '$graph->yaxis->scale->SetAutoMax(0);';
  if ($temp_conv == 1.8) $automin = '$graph->yaxis->scale->SetAutoMax(32);';
  $grace = '$graph->yaxis->scale->SetGrace(0,20);';
}
if (($negvalue == 1) and ($posvalue == 1)) {
  $automin = '';
  $grace = '$graph->yaxis->scale->SetGrace(20,20);';
}

//create timearray for the x-axis
$x=array($clientrawextra['459'],$clientrawextra['460'],$clientrawextra['461'],$clientrawextra['462'],
$clientrawextra['463'],$clientrawextra['464'],$clientrawextra['465'],$clientrawextra['466'],$clientrawextra['467'],
$clientrawextra['468'],$clientrawextra['469'],$clientrawextra['470'],$clientrawextra['471'],$clientrawextra['472'],
$clientrawextra['473'],$clientrawextra['474'],$clientrawextra['475'],$clientrawextra['476'],$clientrawextra['477'],
$clientrawextra['478'],$clientrawextra['578'],$clientrawextra['579'],$clientrawextra['580'],$clientrawextra['581']);
$datax = $x;

// Create the graph and specify the scale for both Y-axis
$graph = new Graph($xsize,$ysize,"auto",30);    
$graph->SetScale("textlin");

$graph->SetShadow();
$graph->SetMarginColor("$margincolour");

// Adjust the margin
$graph->SetMargin($lm,$rm,$tm,$bm);

// Create the two linear plot
$lplot1=new LinePlot($datay);    // Temp






// Add the plot to the graph
$graph->Add($lplot1);


//titles
$graph->title->Set("$txt_temp - Last 24 hrs ($temp_unit)");
$graph->title->Align("center","top");
$graph->title->SetFont(FF_ARIAL,FS_BOLD,10);
$graph->title->SetColor("$textcolour");

//x-axis
$graph->xaxis->title->SetColor("$xtextcolour");
$graph->xaxis->title->Set("$txt_24h");
$graph->xaxis->title->SetFont(FF_ARIAL,FS_BOLD,8);
$graph->xaxis->SetFont(FF_ARIAL,FS_BOLD,8);
$graph->xaxis->SetTitlemargin(25);
$graph->xaxis->SetLabelMargin(10);
$graph->xaxis->SetTickLabels($datax);
$graph->xaxis->SetLabelAngle($label_angle);
$graph->xaxis->SetTextLabelInterval($label_interval);
$graph->xaxis->SetPos("min"); 
$graph->xaxis->HideTicks(true,true); 
$graph->xaxis->SetColor("$xtextcolour"); 
$graph->xgrid->Show(true);

//y-axis
$graph->yaxis->SetFont(FF_ARIAL,FS_BOLD,8);
$graph->yaxis->SetColor("$ytextcolour");
$graph->yaxis->SetLabelFormat("%0.0f");
$graph->yaxis->HideTicks(false,false);
eval($automin);
eval($grace);

//y2-axis
//$graph->y2axis->SetFont(FF_ARIAL,FS_BOLD,8);
//$graph->y2axis->SetColor("$y2textcolour");
//$graph->yaxis->SetLabelFormat("$temp_format");
//$graph->y2axis->HideTicks(true,true); 
//$graph->y2axis->scale->SetAutoMin(0);

// Set the colors for the plots
$lplot1->SetColor("$temp_col1");
$lplot1->SetFillColor("#[email protected]");
if (($negvalue1 == 1) and ($posvalue1 == 0)) $lplot1->SetColor("$temp_col2");
if (($negvalue1 == 1) and ($posvalue1 == 1)) $lplot1->SetColor("$temp_col3");
$lplot1->SetWeight(1);




// Setup a background gradient image
$graph->SetBackgroundGradient('white','navy:0.5',GRAD_HOR,BGRAD_PLOT);

$graph->img->SetAntiAliasing();

// Set the legends for the plots
$graph->legend->SetFont(FF_ARIAL,FS_NORMAL,7);
$lplot1->SetLegend("$txt_temp1");

// Adjust the legend position
$graph->legend->SetLayout(LEGEND_HOR);
$graph->legend->Pos(0.02,0.01,'right','top');

// Display the graph
$graph->Stroke();

?>



Thanks Matt!

It worked, I had to remove this line though:

$graph->img->SetAntiAliasing();

Got an error message within where the graph was supposed to display which said that antialiasing wasn’t supported or something.
I got a question, is there a way of making this graph (this graph only) fill the temp with blue when it’s below zero and red when it’s above zero (like now)?
And make it fill the graph all the way to the “bottom” of the graph.

Take a look at my graph here:

Best Regards,
Martin

8O Lol, I’m no expert by any means, I cheat, well let’s say, I plagiarize others codes, scripts, and study what bits are user changable then change and experiment to get what I want, so it’s sort of plagiarism and sort of not :oops:. Could I write that code from scratch… lol…NO!

Looking at this bit

$lplot1->SetColor(“$temp_col1”);
$lplot1->SetFillColor(“#ff3300@0.5”);
if (($negvalue1 == 1) and ($posvalue1 == 0)) $lplot1->SetColor(“$temp_col2”);
if (($negvalue1 == 1) and ($posvalue1 == 1)) $lplot1->SetColor(“$temp_col3”);

$lplot1 can have different colors on that plot line +/- but the fill looks default for the whole thing, though it may be worth experimenting. Maybe something like:
if (($negvalue1 == 1) and ($posvalue1 == 0)) $lplot1->SetFillColor(“#ff3300@0.5”);
if (($negvalue1 == 1) and ($posvalue1 == 1)) $lplot1->SetFillColor(“#3366ff@0.5”);

I have no idea…give it a try #-o

Don’t for get the colors in the gradients and fills are all changeable, so you can have whatever suits your needs.

I can’t try here, as next time it’s below zero won’t be for another 2-3 months :frowning:

Cheers Matt, doing some experimenting now. :slight_smile:

But I can’t manage to make the graph fill the below zero temperature with blue and the above zero temperature with red.

Maybe someone else can help?