how to label the points on my graph (x and y axis)

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • monomaniac21

    how to label the points on my graph (x and y axis)

    Hi all!

    Ive got a very simple page shown below to draw a line graph and I need
    some help, how do can i label each point on the X and the Y axis? The
    lines are drawn with an imageline function, any ideas?

    Kind regards

    Marc


    <?
    // Add values to the graph
    $graphValues=ar ray(0,80,23,11, 190,245,50,80,1 11,240,55);

    // Define .PNG image
    header("Content-type: image/png");
    $imgWidth=250;
    $imgHeight=250;

    // Create image and define colors
    $image=imagecre ate($imgWidth, $imgHeight);
    $colorWhite=ima gecolorallocate ($image, 255, 255, 255);
    $colorGrey=imag ecolorallocate( $image, 192, 192, 192);
    $colorBlue=imag ecolorallocate( $image, 0, 0, 255);

    // Create GREY border around image
    imageline($imag e, 0, 0, 0, 250, $colorGrey);
    imageline($imag e, 0, 0, 250, 0, $colorGrey);
    imageline($imag e, 249, 0, 249, 249, $colorGrey);
    imageline($imag e, 0, 249, 249, 249, $colorGrey);

    // Create grid using the imageline function to draw lines on the x and
    the y (in grey)
    for ($i=1; $i<11; $i++){

    imageline($imag e, $i*25, 0, $i*25, 250, $colorGrey);
    imageline($imag e, 0, $i*25, 250, $i*25, $colorGrey);
    }

    // Create line graph by looping through the data
    for ($i=0; $i<10; $i++){
    imageline($imag e, $i*25, (250-$graphValues[$i]), ($i+1)*25,
    (250-$graphValues[$i+1]), $colorBlue);
    }

    // Output graph and clear image from memory
    imagepng($image );
    imagedestroy($i mage);
    ?>

  • Colin McKinnon

    #2
    Re: how to label the points on my graph (x and y axis)

    monomaniac21 wrote:
    [color=blue]
    > Hi all!
    >
    > Ive got a very simple page shown below to draw a line graph and I need
    > some help, how do can i label each point on the X and the Y axis? The
    > lines are drawn with an imageline function, any ideas?
    >
    > Kind regards
    >
    > Marc
    >[/color]

    Use jpgraph. Or gnuplot. If you're just masochistic see the notes on


    C.

    Comment

    Working...