Hej igen Sebastian
Tusind tak for hjælpen - jeg kan ikke helt gennemskue hvordan tallene bliver opstillet i $temps array´et.
Når jeg bruger $array = array($temps); får jeg en fejl.
Jeg har nu følgende kode:
<?php
// Vi henter indholdet af filen
$file = file_get_contents("summary.txt");
// Find linjen med temperaturer
$pos = strpos($file,"|");
$str = substr($file,$pos,2000);
$endpos = strpos($str,"\\n");
$nstr = substr($str,0,$endpos);
// Split ved |
$days = explode("|",$nstr);
// Find temperaturer
$temps = array();
foreach ($days as $day)
{
$day = trim(rtrim($day));
if ($day)
{
$tmp = explode(" ",$day);
$temps[] = $tmp[0];
$temps[] = $tmp[1];
}
}
# -----------------------
# settings:
# -----------------------
# text color settings
$MarginColor = '#A9A9C8'; // Margin color
$TextColor = 'white'; // Text color
$FillColor = '#383875'; // Fill color
$header = 'Vejrudsigt'; // Header label
$xaxislabel = 'Skal laves'; // X-axis label
$yaxislabel = 'Grader °C'; // Y-axis label
include 'scripts/jpgraph/jpgraph.php';
include 'scripts/jpgraph/jpgraph_line.php';
$day = date(d);
$array = $temps;
$graph = new Graph(800,600);
$graph->SetScale('textint');
$graph->title->SetColor("$TextColor");
$graph->SetMarginColor("$MarginColor");
$plot = new LinePlot($array);
$plot->SetFillColor('#383875');
$graph->title->Set("$header");
$graph->Add($plot);
$days = $gDateLocale->GetShortDay();
$graph->xaxis->title->SetColor("$TextColor");
$graph->xaxis->SetColor("$TextColor");
$graph->yaxis->SetTitle("$yaxislabel", "middle");
$graph->yaxis->title->SetColor("$TextColor");
$graph->yaxis->SetColor("$TextColor");
$graph->xaxis->SetTitle("$xaxislabel", "middle");
$graph->xaxis->SetTickLabels($day);
$graph->Stroke();
?>
Denne kode virker desværre ikke - se dette link:
www.buskelundtoften.dk/vejret/test2.php
MVH
Henrik
Indlæg senest redigeret d. 03.02.2008 17:01 af Bruger #11872