Hi there,
as i was in need to display the Y-Axis with the Datatraffic of my Server (byte >> terabyte ...) i fastly hacked a wrapper for the pImage Class.
You simly use the "setAxisDisplay" Function with the new Keyword "AXIS_FORMAT_TRAFFIC" and instead of new pImage you use new my_pImage (example follows)
Code:
<?php
/*
* Wrapper Class for Traffic Addon
*/
define("AXIS_FORMAT_TRAFFIC", 700000);
class my_pImage
extends pImage
{
function scaleFormat($Value, $Mode=NULL, $Format=NULL, $Unit=NULL)
{
$X = parent::scaleFormat($Value,$Mode,$Format,$Unit);
if( $X == $Value.$Unit )
{
if( $Mode == AXIS_FORMAT_TRAFFIC )
{
if( $Value > 0 )
{
$unit = array('B','KB','MB','GB','TB','PB');
$v = number_format($Value/pow(1024,($i=floor(log($Value,1024)))),2,',','.');
return($v.' '.$unit[$i]);
}
return(round($Value/1000,$Format));
}
}
return $X;
}
}
?>
Usage Example:
Code:
<?php
$MyData = new pData();
$MyData->setAxisDisplay(0,AXIS_FORMAT_TRAFFIC);
$myPicture = new ArtPF_pImage($width,$height,$MyData);
?>
Now you will have dynamicly calculated Traffic-Measurement for your Traffic-Graphs
Cheers