Jump to content

Multiple Line Graph


benchew0904

Recommended Posts

Anyone can help me with plotting of multiple line graph in php.

 

I have researched on multiple line graph online and  I would like to plot the graph by taking data from my database but the example below is inserting the graph data manually.

Anyone can teach me how to use a for loop inside an array?

 

<?php
//Include the code
require_once 'phplot.php';

//Define the object
$plot = new PHPlot(800,600);

//Set titles
$plot->SetTitle("A 3-Line Plot\nMade with PHPlot");
$plot->SetXTitle('X Data');
$plot->SetYTitle('Y Data');

//Define some data
$example_data = array(
     array('a',3,4,2),
     array('b',5,3,1),  
     array('c',7,2,6),
     array('d',8,1,4),
     array('e',2,4,6),
     array('f',6,4,5),
     array('g',7,2,3)
);
$plot->SetDataValues($example_data);

//Turn off X axis ticks and labels because they get in the way:
$plot->SetXTickLabelPos('none');
$plot->SetXTickPos('none');

//Draw it
$plot->DrawGraph();
?>

Link to comment
https://forums.phpfreaks.com/topic/254450-multiple-line-graph/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.