Contents Previous Next

8.19.5 Inverting the Y-axis

One good way of illustrate the usefulness of label callbacks in a slightly different context is to show how we can achieve the effect of an inverted Y-scale.

An inverted Y-scale has the lowest number at the top and the scale values increases downwards.

Even though JpGraph doesn't directly support this feature it is quite easy to achieve with just a few extra lines of code in your image script.

Before we continue we give an example of what we are referring to.



Figure 95: Inverted Y-axis [src] 

Two achieve this effect there are two simple steps to take:

  1. Negate all you Y-value in the data
  2. Create a callback that negates the scale labels so they appear to be positive.

And that's it! We refer you to the code in the example above for the details.


Contents Previous Next