Dynamisches Achsenbild eines generierten Koordinatensystems??

Hallo!

Ich habe ein Problem ;)

http://www.ap-1.org/forum/_drawstatsline_posts.php
http://www.ap-1.org/forum/_drawstatsline_threads.php

Diese zwei Kurven, man siehts, werden Automatisch generiert! Aber alles was automatisch generiert wird, kommt von diiiieser... Datei hier (also aus der DB ;) nur in der Datei sieht man weiter unten WAS in der DB steht..) Fest steht ich möchte die Achsenbeschriftung nicht immer Selbstständig per Hand editieren :/ ... Wie kann ich sowas machen?

Code:
DB Struktur:
id | timestamp | rendertime | date | day | month | year | hour | minute | posts | users | usersonline | threads
1 | 1207764178 | 0.144726 | Wed, 09 Apr | 09 | 04 | 2008 | 20 | 02 | 1018 | 34 | 5 | 174

Hoffe ihr könnt mir helfen ;(
 
Nützlich wäre vielleicht, wenn wir den Code sehen könnten, wie du dir die Bilder erzeugst.
 
Hoffe er hilft weiter ^^

Code:
<?php
$filename="_drawstatline.php"; 
$Diagrammtitel = "BEITRAEGE STATS"; // Definiere Linienname

require("./acp/lib/config.inc.php");
require("./acp/lib/class_db_mysql.php");

$db = new db($sqlhost,$sqluser,$sqlpassword,$sqldb,$phpversion);

$timestamp = time();
$daysorting   = date("d", $timestamp); // Um aus der Datenbank den Tag ... abzurufen
$monatsorting = date("m", $timestamp); // Um aus der Datenbank den Monat ... abzurufen
$yearsorting  = date("Y", $timestamp); // Um aus der Datenbank das Jahr ... abzurufen

$i=0; 
$last=0;

$X = 1;
$Y = 500;
$X2 = 1;
$Y2 = 500;

$image = imagecreate(500,200); // Erzeuge Bild


// Definiere Farben

$farbe_body = imagecolorallocate($image,200,200,200); 
$Schwarz = imagecolorallocate($image,0,0,0);
$Schwarz2 = imagecolorallocate($image,0,255,255);
$SBG = imagecolorallocate($image,161,161,161);
$RBG = imagecolorallocate($image,177,124,124);
$weis = imagecolorallocate($image,255,255,255);
$red = imagecolorallocate($image,255,0,0);
$blau = imagecolorallocate($image,100,100,255);
$grun = imagecolorallocate($image,0,255,36);
$dgreen = imagecolorallocate($image,10,140,0);
$gelb = imagecolorallocate($image,255,255,0);
imagefill($image, 0, 0, $farbe_body);

// Y-Raster zeichnen - - -

imageline($image, 0, 20, 500, 20, $SBG);
imageline($image, 0, 40, 500, 40, $RBG);
imageline($image, 0, 60, 500, 60, $SBG);
imageline($image, 0, 80, 500, 80, $RBG);
imageline($image, 0, 100, 500, 100, $SBG);
imageline($image, 0, 120, 500, 120, $RBG);
imageline($image, 0, 140, 500, 140, $SBG);
imageline($image, 0, 160, 500, 160, $RBG);
imageline($image, 0, 180, 500, 180, $SBG);
imageline($image, 1, 0, 1, 200, $SBG);

// X-Raster Einzeichnen | | |

while ($a < 600)
	{
	$a = $a + 20;
	imageline($image, $a, 0, $a, 200, $SBG);
	}

// Grafik "Umstylen"

imagesetstyle($image, array($Schwarz, $Schwarz, IMG_COLOR_TRANSPARENT, IMG_COLOR_TRANSPARENT));
$YMaxAbstand = 10;
for($i=0; $i<$YMaxAbstand; $i++)
{
   imageline($image, $AbstandAussen+$RandLinks, $AbstandAussen+$RandOben+10+($YAbstand*$i), $Diagrammbreite-$AbstandAussen-$RandRechts-1, $AbstandAussen+$RandOben+10+($YAbstand*$i), IMG_COLOR_STYLED);
}

// Bezeichner anzeigen (Leider Manuell.....)

imagestring($image, 3, 2 , 20-8 , "1800", $Schwarz);
imagestring($image, 3, 2 , 40-8 , "1600", $Schwarz);
imagestring($image, 3, 2 , 60-8 , "1400", $Schwarz);
imagestring($image, 3, 2 , 80-8 , "1200", $Schwarz);
imagestring($image, 3, 2 , 100-8 , "1000", $Schwarz);
imagestring($image, 3, 2 , 120-8 , "800", $Schwarz);
imagestring($image, 3, 2 , 140-8 , "600", $Schwarz);
imagestring($image, 3, 2 , 160-8 , "400", $Schwarz);
imagestring($image, 3, 2 , 180-8 , "200", $Schwarz);
imagestring($image, 3, 2 , 200-12 , "0.0", $Schwarz);

// Datenabfrage

$abfrage = "SELECT * FROM bb".$n."_rendertime WHERE month like '$monatsorting' and year like '$yearsorting'";
$ergebnis = mysql_query($abfrage); 

$ergebnis2 = mysql_query($abfrage);
$menge = mysql_num_rows($ergebnis2);

// Definiere X1, X2, Y1, Y2

$i = 0;   // Zähler
$b = 0;   // Y1
$a = 0;   // Y2
$old = 0; // X1

$rowPOSTS = mysql_fetch_object($ergebnis);

$faktor = 10; // Dieser Wert reguliert (leider per hand) das Verhältnis Pixel->Postings

// X2
$olda = 199 - $rowPOSTS->posts / $faktor;

$steps = 500 / $menge; // Berechnet den Abstand der pro Kurvenknick nötig ist
while($row = mysql_fetch_object($ergebnis))
	{
	$i++;
	$this = $row->posts;

	$a = $this / $faktor;
	$a = 199 - $a;
	$b = $b + $steps;

	imageline($image, $old, $olda, $b, $a, $dgreen);

	$olda = $a;
	$old = $b;
	}

$average = round($online / $menge,2); // Durchschnittswert

$abfrage1 = "SELECT * FROM bb".$n."_rendertime WHERE day like '$daysorting' and month like '$monatsorting' and year like '$yearsorting'  order by users desc limit 1";
$ergebnis1 = mysql_query($abfrage1);
$row1 = mysql_fetch_object($ergebnis1);
$registered = $row1->users;


$abfrage2 = "SELECT * FROM bb".$n."_posts";
$ergebnis2 = mysql_query($abfrage2); 
$posts = mysql_num_rows($ergebnis2);

$abfrage2 = "SELECT * FROM bb".$n."_threads";
$ergebnis2 = mysql_query($abfrage2); 
$threads = mysql_num_rows($ergebnis2);

imagestring($image, 3, (500-imagefontwidth(5)*strlen($Diagrammtitel))/2, 20 , "$threads Themen", $Schwarz);
imagestring($image, 3, (500-imagefontwidth(5)*strlen($Diagrammtitel))/2, 30 , "$posts Posts", $Schwarz);
imagestring($image, 3, (500-imagefontwidth(5)*strlen($Diagrammtitel))/2, 40 , "(Messzeitraum: $monatsorting.$yearsorting)", $Schwarz);
imagefilledrectangle  ( $image , 160 , 0 , 360  , 20 , $farbe_body ) ;
imagerectangle  ( $image , 161 , 0 , 361  , 21 , $Schwarz) ;
imagestring($image, 5, (500-imagefontwidth(5)*strlen($Diagrammtitel))/2, 2, $Diagrammtitel, $Schwarz);

// Durchschnittslinie einzeichnen
$a = 199 - $average;
// imageline($image, 0, $a, 500, $a, $blau);


imagefilledpolygon ($image, $punkte, count($punkte)/2, $red);
//header("Content-Type: image/gif");
//imagegif($image);
//header("Content-Type: image/png");
//imagepng($image);
header("Content-Type: image/jpeg");
imagejpeg($image,"",100);
imagedestroy($image);

?>
 
Zurück
Oben