Hello Kore,

thanks for you ideas, but, in the meanwhile I was able to solve my
problem.

It was a very nice surprise to see that ezcomponents API already has the
solution for my problem :)

bellow is my code; I'm sure you'll understand what id does; it
completelly solved my problem. thx.

=========================================================
$chart = new ezcGraphLineChart();
$chart->yAxis = new ezcGraphChartElementLogarithmicalAxis();
$chart->yAxis->min = 0;//10^0
$chart->yAxis->base = 10;
$chart->yAxis->label = "bit/s";

$myfunc = '
if ($b == 0) return " 1kbit/s";
if ($b == 1) return "     10k";
if ($b == 2) return "    100k";
if ($b == 3) return " 1Mbit/s";
if ($b == 4) return "    10M";
if ($b == 5) return "    100M";
if ($b == 6) return " 1Gbit/s";
if ($b == 7) return "     10G";
$c=$b+3;
return              "   10^$c";
';

$chart->yAxis->labelCallback = create_function('$a, $b', $myfunc);
=========================================================

That was my problem. And a great solution within the API. thx :)

I have another question :) I'll send another email right away.

cheers
Joao


On Thu, 2008-10-23 at 10:57 +0200, Kore Nordmann wrote:
> Hello Joao,
> 
> On Thu, 2008-10-16 at 18:33 +0100, Joao Ferreira gmail wrote:
> > I need some way to format the string of my Y axis in a way that would
> > allow me to do this
> > 
> > Y axis tick - Label
> > 1000         -  1kbit/s
> > 1000000      -  1Mbit/s
> > 1000000000   -  1Gbit/s
> > 
> > well, this is more of a php question really :)
> 
> This function should roughly do, what you are intending here.
> 
> function format( $number )
> {
>     $identifier = array( 'k', 'M', 'G', 'T', 'P' );
>     $i = 0;
>     while ( ( $number > 900 ) &&
>             ( $i <= count( $identifier ) ) )
>     {
>         $number /= 1000;
>         ++$i;
>     }
> 
>     return sprintf( '%.2f %sbit/s',
>         $number,
>         ( $i === 0 ? '' : $identifier[$i - 1] )
>     );
> }
> 
> > is there a way for the format string to execute some procedure defined
> > by myself in order to map Y-tick values to specific strings defined by
> > me ?
> 
> I don't really get what you are intending here, can you please elaborate
> and explain what you are trying to accomplish?
> 
> Kind regrads,
> Kore
> 

-- 
Components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/components

Reply via email to