JPgraph question or other example for line chart in php

Posted on 2009-02-23
Last Modified: 2013-12-13
i wanna a example which can show different element agianst time  in a pine chart ,
do u all have any example?

the data is from the table in MySQL
table element1
table element2 etc
Question by:ftpphptest1
    LVL 36

    Expert Comment

    by:Loganathan Natarajan

    Author Comment

    i know there is a lot~~~but i want to have some sample code for reference to use the free chart provider
    LVL 8

    Accepted Solution

    try this

               header("Content-type: image/jpeg");
            // read the data from table and put it in array
            $data = array('3400','2570','245','473','1000','3456','780');
            $sum = array_sum($data);
            $height = 255;
            $width = 320;
            $im = imagecreate($width,$height); // width , height px
            $white = imagecolorallocate($im,255,255,255);
            $black = imagecolorallocate($im,0,0,0);
            $red = imagecolorallocate($im,255,0,0);
            imageline($im, 10, 5, 10, 230, $black);
            imageline($im, 10, 230, 300, 230, $black);
            $x = 15;
            $y = 230;
            $x_width = 20;
            $y_ht = 0;
            for ($i=0;$i<7;$i++){
    //          $y_ht = ($data[$i]/$sum)* $height;
                  imagestring( $im,2,$x-1,$y+10,$data[$i],$black);
              $x += ($x_width+20);

    Open in new window

    LVL 36

    Expert Comment

    by:Loganathan Natarajan
    Please download the JPGraph and see the lot of examples in it. You can easily convert them as mYSQL based.

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Suggested Solutions

    Both Easy and Powerful How easy is PHP? (  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
    These days socially coordinated efforts have turned into a critical requirement for enterprises.
    Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
    The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    23 Experts available now in Live!

    Get 1:1 Help Now