[Webinar] Learn how to a build a cloud-first strategyRegister Now


JPgraph question or other example for line chart in php

Posted on 2009-02-23
Medium Priority
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
  • 2
LVL 36

Expert Comment

by:Loganathan Natarajan
ID: 23713052

Author Comment

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

Accepted Solution

agamal earned 2000 total points
ID: 23731612
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
ID: 23731638
Please download the JPGraph and see the lot of examples in it. You can easily convert them as mYSQL based.

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
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.
Suggested Courses
Course of the Month20 days, 10 hours left to enroll

867 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