i have 2 arrays: 1 storing beginning of actions , second durations. beginnings timestamps (descending order recent) , durations in seconds, instance beginnings of user logins , durations. as:
$beginnings = array(1458945920,1458945657,1458940547,1458940444,1458940038,1458939783,1458939655); $durations = array(154,253,4973,33,202,242,115);
i wish represent 2 arrays chart.
on labels of x-axis wish show values of beginnings, horizontally separated each other proportionally difference between 1 beginning , next. on y-axis, on correspondence beginnings, wish show bar high duration value. had @ few charting libraries pchart or phpchart, in examples couldn't see that. , i'm new charting ask suggestion.
the attached chart created using commercial charting library called chartdirector using code below.
<?php require_once("../lib/phpchartdir.php"); $beginnings = array(1458945920,1458945657,1458940547,1458940444,1458940038,1458939783,1458939655); $durations = array(154,253,4973,33,202,242,115); # chart image , plotting region $c = new xychart(800, 360); $c->setplotarea(70, 20, 700, 300, transparent, -1, transparent, 0xcccccc); # x-axis configuration $c->xaxis->setcolors(0x888888); $c->xaxis->settickdensity(75); $c->xaxis->setmargin(10, 10); $c->xaxis->setrounding(true, true); $c->xaxis->setlabelstyle("arial.ttf", 10); # y-axis configuration $c->yaxis->setcolors(transparent); $c->yaxis->settickdensity(40); $c->yaxis->setlabelstyle("arial.ttf", 10); $c->yaxis->settitle("duration", "arialbd.ttf", 14, 0x555555); # bar layer $barlayerobj = $c->addbarlayer($durations, 0x6699bb); $barlayerobj->setbordercolor(transparent); $barlayerobj->setxdata(array_map(charttime2, $beginnings)); $barlayerobj->setbarwidth(10); # output chart header("content-type: image/png"); print($c->makechart2(png)); ?>
you can insert chart in web page normal image:
<img src="create_chart.php">
where "create_chart.php" file contains above charting code.
Comments
Post a Comment