How to remove the gravity from accelerometer

My advice right now is to try the code in reply#8, as you do not yet have the skills or understanding to modify the code I posted.

I won't make those modifications because I do not have an LSM6DS3 to test it with.