How to get maximum value of a direction working with Joysticks?

Hey mates, I’m working on a simple joystick game. For this I need the maximum value of vector that returns the joystick, in 8 ways. (Top, down, left, right, diagonal top-right, diagonal top-left, diagonal down-right, diagonal down-left). But every time I move the joystick it gets all values that are in its way. So, how can I do to only get the maximum value of each axis when I’m moving the joystick?

Thanks!

There is a gentleman that had exactly this, How to get overall intensity for each Joystick Axis? - Questions & Answers - Unity Discussions

although, he has a type-o in the code example:

float mag = Mathf.Clamp01(new Vector2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical")).magnitude);