How to setup jpgraphs and wxgraphs

I have just uploaded a new graph package for downloading. This new version contains the ability to change the language used on the graph labels. There is a new file called graphlang.php which contains all the data strings used to add labels and titles to the graphs, by editing this file and changing the strings you can change the graphs to display in your own language. As I am completely dumb with foreign languages I have not provided any examples I’m afraid, however I will try not to change this file but simply add any new strings to the end of the file so that people can copy over any updates and not replace the whole file. Any changes in this file will be detailed in the Readme.txt.

Stuart

Hi Stuart

Thats a great feature - I will download it today and try it out.

I guess all my work translating the graps into Danish last week was a waste :D’

Have a nice day

Best regards,

Henrik

Hi again

I just installed the new version and see some minor missing translation:

  • temp+dew+hum_24hr.php - the explanation is missing translation

  • temp+dew+hum_1hr.php - the explanation is missing translation

  • The compass letters (N W S E N)

  • rain_yesterday.php - missing translation (rain)

  • rain_today.php - missing translation (rain)

  • rain_week.phprain_this_month.php - missing translation (rain)

  • rain_this_year.php - missing translation (rain)

  • all the “last 31 days graphs” - the name “date” in the right down corner is not translated

That was what I was noticing.

Best regards,

Henrik

Thanks Henrik, I’ll work on that later today and put up a new package. Sorry for that, it gets a bit confusing doing the testing when I only have one meaningful language to use #-o :roll:

Stuart

Hi again

Its okay - im happy to test it out for you.

I can send you the graphlang.php in Danish if you like?

Best regards,

Henrik

Yes please Henrik, that’ll make seeing what’s missing much easier. You have my email address.

Stuart

Hi Stuart

E-mail sent

Best regards,

Henrik

Thanks Henrik, I’ll have a package for you to test tomorrow when you get time. I’ll email it to you.

Stuart

Edit: email sent to you Henrik…

Hi Stuart

E-mail sent

Best regards,

Henrik

I have now sorted the issues Henrik found with the language file and have uploaded a new package with the fixes, and have included courtesy of Henrik a Danish sample language file. If anyone else creates a lanuage file other than English (or Danish) and would like it added please send me the file (you can find my email address via my website). So the latest zip file should now allow any language to be added to the graphs.

Thanks again to Henrik for all his help in sorting this.

Stuart

I just wanted to say thanks for this exellent package!

I installed it in 20 minutes and it works great. Now just to find the best places to put it in my website! :lol:

Best Regards,
Martin

Glad you like it Martin.

Stuart

You wouldn’t happen to know if it’s possible to use the different language files for the jpgraphs when my website is set to a specific language?

If you check my main page, I’ve added the temperature over last 7 days graphs in the dashboard. I was wondering if I can
get it to display the text in the correct language depending on the choice for the template…

Best Regards,
Martin

If you have the latest package there is a graphlang.php file which you can edit to change the language.

Stuart

And that could be made selectable the same way the template pages work eg http://www.berdalweather.net/index.php?lang=en

Currently I only have one other language file other than English and that’s Danish, so at present I’ve not bothered to change the code to make it user selectable you simply rename the correct language file to graphsconf.php. Its quite easy to change by making a small change to the config file but as I’d only received one langauge file I’d not done it.

Stuart

Yes, that was my point, how to get the jscript to choose between the different language files for the wxgraphic dependant on the main language selected in the Carterlake template.

I’m not so good at coding stuff from scratch, so I was hoping someone could help me out. :slight_smile:

Best Regards,
Martin

WEell it would need more than a simple code change in the config file as these graphs are for everyone not just those running the Carterlake Templates. Also currently there are only English and Danish available anyway. For now simply edit the graphlang file and change to your language. When I get time I’ll try to add the required code to the config file and make it work with and without the templates.

Stuart

Thanks Stuart!

I’m just using the default English version for now, although I’ve created a Norwegian file as well.

Best Regards,
Martin

Hi all,

I was wondering if any of you code gurus could help me with something I’d like to do with this temp graph.
I’d like to make it fill the below zero temperatures with blue, and the above zero temperatures with red.
Also, change the plot line from a fixed color to the same, ie. red if above zero and blue if below zero.

Here’s the graph:

And here’s my current code (don’t pay so much attention to the colors I’ve chosen etc it’s just for testing):

<?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;




if ($temp_conv == 1.8) {
	array_walk($datay, "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;

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(5);';
}
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,5);';
}
if (($negvalue == 1) and ($posvalue == 1)) {
  $automin = '';
  $grace = '$graph->yaxis->scale->SetGrace(5,5);';
}

//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

if (($negvalue1 == 0) and ($posvalue1 == 1)) $lplot1->SetColor("$temp_col1");
if (($negvalue1 == 1) and ($posvalue1 == 0)) $lplot1->SetColor("$temp_col2");
if (($negvalue1 == 1) and ($posvalue1 == 1)) $lplot1->SetColor("$temp_col3");

if (($negvalue1 == 1) and ($posvalue1 == 0)) $lplot1->SetFillColor("#[email protected]");
if (($negvalue1 == 1) and ($posvalue1 == 1)) $lplot1->SetFillColor("#[email protected]");
$lplot1->SetWeight(1);




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

// 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();

?>

Best Regards,
Martin