Tuesday 4 December 2012

Draw graph in PHP with JpGraph

-Software requirement in this tutorial

1) XAMPP . See this post if you don’t know how to install XAMPP
http://kurup87.blogspot.com/2012/12/getting-start-with-php.html
2) JpGraph download JpGraph at this website http://jpgraph.net/download/index.php

-Unzip the jpgraph and place it in your xampp working folder. Example: C:\xampp\htdocs\example


- Create a .php file and for example graph.php and include “require_once('/jpgraph-3.5.0b1/src/jpgraph.php');” to make jpgraph available in your code.


- Here is example code
<?php
require_once('/jpgraph-3.5.0b1/src/jpgraph.php');
require_once('/jpgraph-3.5.0b1/src/jpgraph_line.php');
//  data
$ydata = array(90,80,67,87,66,71,96,53,35,73);

// Create the graph. These two calls are always required
$graph = new Graph(300,250);
$graph->SetScale('textlin');
$graph->xaxis->title->Set("Number of students");
$graph->yaxis->title->Set("Marks");
// Create the linear plot
$lineplot=new LinePlot($ydata);
$lineplot->SetColor('blue');

// Add the plot to the graph
$graph->Add($lineplot);

// Display the graph
$graph->Stroke();
?>


- Save the code and run at web browser. Before run, do not forget to Start the Apache through XAMPP Thats all!
ex) http://localhost/example/graph.php



Sunday 2 December 2012

Getting start with PHP

1) Software that you might need
    a. XAMPP
        -you can easily download XAMPP through this link.
        -choose installer file.
    b. Notepad++ (optional)
        -you can download notepad++ through this link

2) Start the XAMPP control panel
    a. start the apache

3) Create a basic php program (we can use notepad++ or notepad)
4) Create a new folder “example” inside the xampp folder>>htdocs C:\xampp\htdocs\example

5) Execute the program by using web browser. That's all.