Hallo,
ich habe ein funktionierendes Script (geklaut und) eingebaut. Mit diesem erstelle ich erfolgreich ein Liniendiagramm.
PHP
<?php
global $wpdb;
header("Content-type: image/png");
$imgWidth = '600';
$imgHeight = '200';
$theImage = imagecreate($imgWidth, $imgHeight);
$colorWhite = imagecolorallocate($theImage, 255, 255, 255); #Hintergrund
$colorGrey = imagecolorallocate($theImage, 210, 210, 210);
$colorBlue = imagecolorallocate($theImage, 0, 50, 255);
#$ie = 0;
#$result = $wpdb->get_results("SELECT `systolisch`,`datum`,`uhrzeit` FROM `gesundheit3` where `systolisch`<> '' order by `datum` DESC, `uhrzeit` DESC LIMIT 50");
#foreach ($result as $data) {
# $wert[$ie] = $data->systolisch;
# $ie++;
# }
#}
$wert[0] = '50';
$wert[1] = '100';
$wert[2] = '24';
$wert[3] = '30';
$wert[4] = '90';
$wert[5] = '102';
$wert[6] = '56';
$wert[7] = '23';
$wert[8] = '50';
$wert[9] = '100';
$wert[10] = '24';
$wert[11] = '30';
$wert[12] = '90';
$wert[13] = '102';
$wert[14] = '56';
$wert[15] = '23';
imageline($theImage, 0, 0, $imgWidth, 0, $colorGrey); #oben
imageline($theImage, $imgWidth-1, 0, $imgWidth-1, $imgHeight-1, $colorGrey); #rechts
imageline($theImage, 0, $imgHeight-1, $imgWidth, $imgHeight-1, $colorGrey); #unten
imageline($theImage, 0, 0, 0, $imgHeight, $colorGrey); #links
$pxRaster = '20'; #Größe des Rasters
$pxWidth = round($imgWidth / $pxRaster, 0);
for($i=1; $i<$pxWidth; $i++){
imageline($theImage, $i*$pxRaster, 0, $i*$pxRaster, $imgHeight, $colorGrey); #vertikal
imageline($theImage, 0, $i*$pxRaster, $imgWidth, $i*$pxRaster, $colorGrey); #horizontal
}
$countBalken = count($wert);
for($i=0;$i<$countBalken;$i++){
if($maxHeight < $wert[$i]){
$maxHeight = $wert[$i];
}
}
$dynWidth = round(($imgWidth-2) / ($countBalken-1), 0);
@$dynHeight = ($imgHeight-1) / $maxHeight;
for ($i=0; $i<$countBalken; $i++){
$aktNewSize = @round($dynHeight * $wert[$i]);
$aktNewSize2 = @round($dynHeight * $wert[$i+1]);
if($i+1 < $countBalken){
imageline($theImage, $i*$dynWidth, ($imgHeight-$aktNewSize),
($i+1)*$dynWidth, ($imgHeight-$aktNewSize2), $colorBlue);
}
}
//Ausgabe
imagepng($theImage); #ausgeben des Bildes als PNG
imagedestroy($theImage); #freigeben und zerstören des Bildes
?>
Alles anzeigen
Sobald ich aber das Array Wert per SQL (hier nun auskommentiert) füllen will, wird das Diagramm nicht mehr angezeigt.
Selbst wenn ich nur
schreibe kommt schon der Alt-Text "...kann nicht angezeigt werden".
Ich bin mir sicher irgendwo nur einen Denkfehler zu machen ... aber Wald | Bäume ... ich sehe ihn nicht.
Danke
roemi2 (weil sich roemi nicht mehr anmelden kann :-)