www.webdeveloper.com
Results 1 to 7 of 7

Thread: Graph from Database

  1. #1
    Join Date
    Jun 2011
    Posts
    20

    Post Graph from Database

    Salam,
    Dear,I have database with 3 tables.
    country, birth rate, and effecting factor.
    I want to Make Bar Graph, Pie Chart , Line Graph.
    from database.
    I m uing Wamp server.
    Can any body help me , How can i make Graphs by database values.
    Please help me or provide link.
    thanks.

  2. #2
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,221
    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  3. #3
    Join Date
    Feb 2011
    Posts
    231
    Hi,
    Here's a simple php class to create graph charts: Create Graphic Charts. It uses data stored in array.
    If you know how to extract data from your database and store it in an array, you can use that class, or other similar "php hraph class" that can be found on the net.

  4. #4
    Join Date
    Jun 2011
    Posts
    20

    Post graph

    Dear, thanks.I used this class.But please guide me that how can I extract the data from database and create graph according to that.thanks again.

    <?php
    include('graidle.php');

    // array with data points for each name
    $data = array('N_1'=>12, 'N_2'=>23.5, 'N_3'=>8, 'N_4'=>9.8, 'N_5'=>50);

    // set 2 numeric arrays, one with names (for x-axis), another with the points (y-axis)
    $names = array_keys($data);
    $points = array_values($data);

    // create object of graidle class (define Title)
    $graph = new graidle('Number of points');
    $graph->setColor('#a7b8ed');
    $graph -> setValue($points,'b'); // set series values, type of graph (b=bar)

    $graph -> setSecondaryAxis(1,0); // display secondary x-axis grid
    $graph -> setWidth(300); // graphic chart width
    $graph -> setHeight(180); // graphic chart height
    $graph -> setXValue($names); // add the names to x-axis
    $graph->setDivision(10); // set division on scale axis
    $graph->setBgCl('#efefef'); // background color
    $graph -> setExtLegend(); // to show values to each bar

    $graph -> create(); // create chart
    $graph -> carry(); // outputs the graph

    /*
    To save the chart, use carry2file() method, with: 'dir_name', 'file_name' (without extension)
    Ex.: save "graphic_chart_1.png" in directory "charts/"
    $graph->carry2file('charts/', 'graphic_chart_1');
    */
    ?>

  5. #5
    Join Date
    Apr 2010
    Posts
    227
    I used gdi to buils my graph from db

  6. #6
    Join Date
    Feb 2011
    Posts
    231
    Hi,
    I don't know how to guide you to extract data from your database, depends of your table and data you want to extract.
    As a general code, you can apply this syntax:
    Code:
    $storedata = array();
    $i = 0;
    while ($row = mysql_fetch_array($query_result, MYSQL_ASSOC)) {
      $storedata['column'.$i] = $row['column'];     // store in array 'columnindex'=>value
      $i++;
    }
    Assuming that you know how to connect to mysql database and perform your query. If not, there are on the net tutorials about "php select data from mysql".

  7. #7
    Join Date
    Sep 2008
    Posts
    120
    Hi
    Try this. It is with good documentation and easy for use. http://teethgrinder.co.uk/open-flash-chart/

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles