There's some useful information here which explains the calibration for using this sensor as a compass.
http://hobbylogs.me.pn/?p=17
This explains that the x,y,z axis may have offsets which mean that you cannot simply do arctan to get the heading "heading=atan2(y,x)"
Calibration involves spinning the sensor in all it's axis to find out the sphere of x,y,z coordinates produced and then entering in an offset for each axis so that the sphere of x,y,z coordinates is centred on zero.