pChart 2.x forum
http://wiki.pchart.net/forum/

Y-Axis for Data-Traffic
http://wiki.pchart.net/forum/viewtopic.php?f=4&t=461
Page 1 of 1

Author:  Artnessde [ Fri May 20, 2011 2:04 pm ]
Post subject:  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

Author:  lnf [ Sat Sep 10, 2011 2:27 pm ]
Post subject:  Re: Y-Axis for Data-Traffic

Great idea!

Author:  jean-damien [ Mon Sep 12, 2011 7:11 am ]
Post subject:  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 12124 times ]

Author:  rom [ Tue Dec 06, 2011 7:38 pm ]
Post subject:  Re: Y-Axis for Data-Traffic

Hello,

is there any new release planned?

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/