php - How to draw multi line graph using phpGraphlib -



php - How to draw multi line graph using phpGraphlib -

i have created line graph using phpgraphlib. don't thought how draw multiline graph using library . x-y values stored in arrays here. code here

<?php include("phpgraphlib.php"); $graph=new phpgraphlib(1000,1000); include("db_connect.php"); $dataarray=array(); $graph_array=array(); $sql="select name,mark1,mark2, entered_time pupil "; $result = mysql_query($sql,$con) ; if ($result) { while ($row = mysql_fetch_assoc($result)) { $without_comma_value=explode(',', $row['mark1']); $count=count($without_comma_value); for($i=0;$i<$count;$i++) { $val_onebyone= $without_comma_value[$i]; $num=$i+1; $dataarray[$num]=$val_onebyone; } } } $graph->setbackgroundcolor("#f78181"); $graph->adddata($graph_array); $graph->setbars(false); $graph->setline(true); $graph->setupyaxis(20, 'black'); $graph->setupxaxis(20, 'black'); $graph->settextcolor('black'); $graph->setdatapoints(true); $graph->setdatapointcolor('maroon'); $graph->setlinecolor('maroon'); $graph->creategraph(); ?>

it plots graph mark1 values. want show mark2 values too. how possible ?

like this

include('phpgraphlib.php'); $graph = new phpgraphlib(650,200); $datax = range(1, 15); $datay1 = array(); $datay2 = array(); foreach($datax $x => $y) { $datay1[$x] = rand(-10, 10); $datay2[$x] = rand(-10, 10); } $graph->adddata($datay1, $datay2); $graph->setdatapointcolor('red'); $graph->setlinecolor('red', 'blue'); $graph->setbars(false); $graph->setline(true); $graph->setdatapoints(true); $graph->creategraph();

result (line color can different, color of datapoints stays same)

php html phpgraphlib

Comments

Popular posts from this blog

assembly - What is the addressing mode for ld, add, and rjmp instructions? -

vowpalwabbit - Interpreting Vowpal Wabbit results: Why are some lines appended by "h"? -

Is there a way to convert an HTML page styled with Bootstrap CSS into email-compatible html? -