Liniendiagramm

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • Liniendiagramm

    Code unten bitte fragen beantworten wenn möglich

    Grüße V. Maurer
    Zuletzt geändert von Firefly; 12.12.2007, 15:02.

  • #2
    deshalb habe ich es jetzt auf png gestellt aber auch das ändert nichts, was mache ich falsch?
    Echt???

    imagejpeg($bild,"name.png");
    ICH BIN ICH!!!

    Kommentar


    • #3
      looool

      kk jap augen auf ich weiß schon ^^

      danke dir ^^

      Kommentar


      • #4
        ...oder vielleicht an der Qualität drehen...

        int imagejpeg ( resource $im [, string $filename [, int $quality ]] )

        Kommentar


        • #5
          ah cool danke aber ich lass es jetzt als png

          Hier mal der Code seht:
          (was könnte ich daran noch optimieren, es soll später mal die besucher auf einer website im jahr anzeigen also pro monat halt)
          PHP-Code:
          <?
          /* +----------------------------------------------------------+
             | Voreinstellungen des Diagramms                           |
             +----------------------------------------------------------+
          */
          // Streckfaktor
          $streckf = 50;
          // Verschiebung in x
          $driftx = 30;
          // Bild erstellen
          $bild = imagecreate(630,300);
          $coldb = ImageColorAllocate($bild,0,105,140);
          $colblack = ImageColorAllocate($bild,0,0,0);
          $colwhite = ImageColorAllocate($bild,255,255,255);
          $colwb = ImageColorAllocate($bild,33,142,173);

          imageline($bild, 30, 0, 30, 250, $colwhite); // achse y
          // imageline($bild, 0, 0, 600, 0, $colwhite); // achse x oben
          imageline($bild, 30, 250, 630, 250, $colwhite); // achse x
          // imageline($bild, 599, 0, 599, 250, $colwhite); // achse y rechts
          // Array werte :)
          $werte[] = 0;
          $werte[] = 0;
          $werte[] = 0;
          $werte[] = 0;
          $werte[] = 0;
          $werte[] = 0;
          $werte[] = 0;
          $werte[] = 0; 
          $werte[] = 0; 
          $werte[] = 0; 
          $werte[] = 0; 
          $werte[] = 10;  

          // Maximalen Wert ermitteln
          $blub = $werte;
          sort($blub);
          $test = count($werte);
          $max = $blub[$test-1];

          // Beschriftung erzeugen (Y-Achse)
          $count = 0;
          for($i = 10; $i >= 0; $i--) {
          $y = $count * 25 - 6;
          ImageString($bild, 1, 10, $y, $i * 25, $colwhite);
          $count++;
          }
          // Beschriftung erzeugen (X-Achse)
          $zeit[] = "Jan.";
          $zeit[] = "Feb.";
          $zeit[] = "Mär.";
          $zeit[] = "Apr.";
          $zeit[] = "Mai";
          $zeit[] = "Jun.";
          $zeit[] = "Jul.";
          $zeit[] = "Aug.";
          $zeit[] = "Sep.";
          $zeit[] = "Okt.";
          $zeit[] = "Nov.";
          $zeit[] = "Dez.";
          for($i = 0; $i <= 12; $i++) {
          $x = $i * $streckf + 25;
          ImageString($bild, 2, $x, 252, $zeit[$i], $colwhite);
          }

          for($i = 0; $i < count($werte); $i++) {
          $x = $i * $streckf + 30;
          $y = 250 - $werte[$i];
          $x1 = ($i + 1) * $streckf + 30;
          $y1 = 250 - $werte[$i+1];
          if($werte[$i+1] != "") {
          imageline($bild, $x, $y, $x1, $y1, $colwb);
          }
          $x = $x - 6;
          if($x < 0 + $driftx)
            $x = 2 + $driftx;
          if($x > 593 + $driftx)
            $x = 585 + $driftx;

          $y = $y - 10;
          if($y < 0)
            $y = 2;
          if($y > 250)
            $y = 245;
          ImageString($bild, 1, $x, $y, $werte[$i], $colwhite);
          }

          imagepng($bild,"diagramm.png");
          echo '<img src="diagramm.png"><br>';
          ?>
          Ich weiß nicht was mit der array(); funktion bei ir ist irgendwie funzt die nicht kein plan bei mir gehts nur so ^^ aber da kommen ja später eh mysql werte rein, von dem her isses ja egal. ich hab mir die funktionen und so hier ausm forum und aus der manual zusammengebastelt ber eins versteh ich nicht und zwar das:

          PHP-Code:
          $bild imagecreate(630,300);
          $coldb ImageColorAllocate($bild,0,105,140);
          $colblack ImageColorAllocate($bild,0,0,0);
          $colwhite ImageColorAllocate($bild,255,255,255);
          $colwb ImageColorAllocate($bild,33,142,173); 
          wieso ist die hintergrundfabe des bildes nicht $colwb sondern $coldb, klar es ist so gewollt aber warum nimmt der das erste und nicht eins nach dem anderen und schließlich bleibt das letzte???

          Grüße danke für antworten Gruß vincent

          Kommentar

          Lädt...
          X