Full Calibration of Motor issue

So I got an encoder attached to my motor and Full calibration of motor seems to work. Motor rotates in one direction for a while and then the other and the flag for encoder is calibrated is set to true. But one issue I am facing is sometimes the calibration process fails and when i do it for a second time in the same run by clearing errors and running the process again, it calibrates successfully. Upon checking the encoder live plotting I observed this.

So the whenever i start the calibration process, where ever be the encoder value at first, it gets reset to 0 and the motor spins for a while in one direction in the reverse direction - this is the first huge pulse you see in the graph, it just goes from 0 to the max count of encoder - 500 in my case, and ramps up to about half and stop. At this point the calibration process fails. Now i clear my errors and retry the calibration, and the motor adjusts itself to a certain encoder position value ~encoder_cpr/2 and ramps up to upper limit, goes through 0 and then goes back to negative and comes back from top. This is the second part of the graph you can see. What i observed is ONLY when I get this kind of graph while calibration, the process is successfully. Only for that pattern of encoder readings (the second shape). Am i doing something wrong or is this intended? And if it’s intended, how will i go about making the odrive do this successfully in the first try?

What is the actual value that you’re plotting there?