GDlib met php

Pagina: 1
Acties:
  • 63 views sinds 30-01-2008

  • Appel-Banaan
  • Registratie: Januari 2004
  • Laatst online: 20-05 07:21

Appel-Banaan

Het leven is wat je gebeurt

Topicstarter
--------------------------------------------------------------------------------

Hallo iedereen

Ik heb net een code gevonden op internet voor het genereren van een plaatje. Maar hij werkt bij mij niet helemaal.

Het gaat om deze code:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php 
$data = array( 
"Jan" => 55, 
"Feb" => 54, 
"Mar" => 53, 
"Apr" => 33, 
"May" => 13, 
"Jun" => 15, 
"Jul" => 23, 
"Aug" => 28, 
"Sep" => 32, 
"Oct" => 45, 
"Nov" => 73, 
"Dec" => 71); 

$maxval = max($data); 
$nval = sizeof($data); 

$vmargin = 20; // top (bottom) vertical margin for title (x-labels) 
$hmargin = 38; // left horizontal margin for y-labels 

$base = floor(($width - $hmargin) / $nval); // distance between columns 

$ysize = $height - 2 * $vmargin; // y-size of plot 
$xsize = $nval * $base; // x-size of plot 

// title 
$titlefont = 3; 
$title = "PDF Download Statestieken"; 

// pixel-width of title 
$txtsz = imagefontwidth($titlefont) * strlen($title); 

$xpos = (int)($hmargin + ($xsize - $txtsz)/2); // center the title 
$xpos = max(1, $xpos); // force positive coordinates 
$ypos = 3; // distance from top 

$width = 480; 
$height = 250; 
$image = imagecreate($width, $height); 

// y labels and grid lines 
$labelfont = 2; 
$ngrid = 4; // number of grid lines 

$dydat = $maxval / $ngrid; // data units between grid lines 
$dypix = $ysize / ($ngrid + 1); // pixels between grid lines 

for ($i = 0; $i <= ($ngrid + 1); $i++) { 
    // iterate over y ticks 

    $ydat = (int)($i * $dydat); // height of grid line in units of data 
    $ypos = $vmargin + $ysize - (int)($i*$dypix); // height of grid line in pixels 

    $txtsz = imagefontwidth($labelfont) * strlen($ydat); // pixel-width of label 
    $txtht = imagefontheight($labelfont); // pixel-height of label 

    $xpos = (int)(($hmargin - $txtsz) / 2); 
    $xpos = max(1, $xpos); 

    imagestring($image, $labelfont, $xpos, $ypos - (int)($txtht/2), $ydat, $black); 

    if (!($i == 0) && !($i > $ngrid)) 
        imageline($image, $hmargin - 3, $ypos, $hmargin + $xsize, $ypos, $gray); 
        // don't draw at Y=0 and top 
} 

// colors 
$white = imagecolorallocate($image, 0xFF, 0xFF, 0xFF); 
$navy = imagecolorallocate($image, 0x00, 0x00, 0x80); 
$black = imagecolorallocate($image, 0x00, 0x00, 0x00); 
$gray = imagecolorallocate($image, 0xC0, 0xC0, 0xC0); 

// draw something here 
imagerectangle($image, $hmargin, $vmargin, 
    $hmargin + $xsize, $vmargin + $ysize, $black); 
imagestring($image, $titlefont, $xpos, $ypos, $title , $black); 

// flush image 
header("Content-type: image/png"); // or "Content-type: image/png" 
ImagePng ($image); // or imagepng($image) 
imagedestroy($image); 
?>

Bron: http://www.phpbuilder.com...anger20001218.php3?page=3

lokatie code: http://www.managementcons...in/statestieken/test2.php

Wie weet er waarom ik alleen het hoekje zie? Of heeft iemand een link naar een howto voor GDlib met php oid?

Alvast bedankt

Terwijl je andere plannen maakt


  • gorgi_19
  • Registratie: Mei 2002
  • Laatst online: 15:00

gorgi_19

Kruimeltjes zijn weer op :9

We leveren hier geen support op scripts van derden. Als het niet werkt, kan je beter de maker mailen.

Sowieso denk ik dat weinig mensen zin hebben om 83 regels code voor jou te gaan debuggen, zonder duidelijke foutmeldingen.

Zie:
P&W FAQ - De "quickstart"
**** Over topictitels in P&W - Updated 9 mei 04 ****

[ Voor 110% gewijzigd door gorgi_19 op 21-05-2004 13:12 ]

Digitaal onderwijsmateriaal, leermateriaal voor hbo


Dit topic is gesloten.