View unanswered posts | View active topics It is currently Fri Mar 01, 2024 1:14 pm



Reply to topic  [ 4 posts ] 
Y-Axis for Data-Traffic 
Author Message
New pChart user
New pChart user

Joined: Fri May 20, 2011 1:59 pm
Posts: 1
Post Y-Axis for Data-Traffic
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


Fri May 20, 2011 2:04 pm
Profile
Regular pChart user
Regular pChart user

Joined: Sun Aug 14, 2011 3:34 pm
Posts: 8
Post Re: Y-Axis for Data-Traffic
Great idea!

_________________
Random Facts Little Known Facts


Sat Sep 10, 2011 2:27 pm
Profile
Site Admin
Site Admin
User avatar

Joined: Thu Dec 02, 2010 2:31 pm
Posts: 409
Location: France
Post Re: Y-Axis for Data-Traffic
Good hit! I'll add this new format to the 2.1.4.

Thank you ;o)
JD.


Attachments:
example_drawSplineChart_network.png
example_drawSplineChart_network.png [ 69.87 KiB | Viewed 10529 times ]
Mon Sep 12, 2011 7:11 am
Profile WWW
pChart user
pChart user

Joined: Wed Sep 21, 2011 8:45 am
Posts: 4
Post Re: Y-Axis for Data-Traffic
Hello,

is there any new release planned?


Tue Dec 06, 2011 7:38 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 4 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron