Search code examples
phpjpgraph

Minimum value for graph axis


I am trying to make a bargraph that plots times.

So what the technical issue we are trying to get the minimum plot value to something.

For example if what I was trying to graph was 4 min 30 s (4:30), 4:45, 4:15, and 4:20, I would like the y=0 value to be 4 minutes and each increment in the y axis to be 1 second.

Effectively, it would be a bargraph of 30, 45, 15, and 20 with the y = 0 axis labelled as. Is there anyway of doing this without have to man handle the data?

Help please if you know how to do this with jpgrah.

Otherwise, does anyone know what this feature is called in general so I can google it up?

I was reading the documentation of jpgrah: SetYBase seemed a like a good candidate but all it seemed to do when I played with the parameters was shrink the upper limit y-value [Specify the start plot for bars, (minimum Y-value). By default the base uses the value 0 as base.]


Solution

  • Found the appropriate method in the JPGraph documentation:

    $aGraph = new Graph($aWidth,$aHeight,'auto'); $graph->SetScale('textlin',$aMinY,$aMaxY);

    $aMinY and $aMaxY give the minimum and maximum values included in the graph. Also, they are optional arguments.