Horizontal and Vertical Line Graph in PHP

Introduction

In this article I will explain Horizontal and Vertical Line Graphs Using PHP. I will create a Horizontal and Vertical Line Graph using the phpmygraph5.0 file. It is very simple to do. Before doing this program you must install the PHP GD library and then you will download the phpmygraph5.0 file from the URL http://phpmygraph.abisvmm.nl/phpMyGraph5.0.5.zip. After downloading this file you can use it in graphics programs. You can create many graph programs in PHP using the phpmygraph5.0 file. You can create many graphs like Horizontal Line Graph, Simple Horizontal Column Graph, Horizontal Shadow Column Graph, Horizontal Polygon Graph, Vertical Line Graph, Simple Vertical, Column Graph, Vertical Shadow Column Graph, Vertical Polygon Graph, Compare Data Graph and Configuration Directives. Otherwise you can create a graph with a MySQL database and then you require the "jpgraphs" package. 

Example

Horizontal Line Graph

<?php

//set content type header  

    header("Content-type: image/png");

    include_once('php/phpMyGraph5.0.php');

    $graph['Title'] = 'Example graph';

    $graph['Width'] = 600;

    $graph['Height'] = 300;

       //data array

    $data = array(

        'January' => 13,

        'February' => 26,

        'March' => 0,

        'Aprile' => 8,

        'May' => 81,

        'June' => 68,

        'July' => 46,

        'August' => 67,

        'September' => 24,

        'October' => 24,

        'November' => 78,

        'December' => 24

    );

    $graph = new phpMyGraph();

    $graph->parseHorizontalLineGraph($data, $cfg);

?>

Output

here1.jpg

Example

Vertical Line Graph

<?php   

//set content type header

    header("Content-type: image/png");

    include_once('php/phpMyGraph5.0.php');

    $graph['Title'] = 'Example graph';

    $graph['Width'] = 600;

    $graph['Height'] = 300;

       //data array

    $data = array(

        'January' => 13,

        'February' => 26,

        'March' => 0,

        'Aprile' => 8,

        'May' => 81,

        'June' => 68,

        'July' => 46,

        'August' => 67,

        'September' => 24,

        'October' => 24,

        'November' => 78,

        'December' => 24

    );

    $graph = new phpMyGraph();

    $graph->parseVerticalLineGraph($data, $cfg);

?>

Output 

here2.jpg


Similar Articles