We propose a quantum fitting scheme to estimate the magnetic field gradient with $N$-atom spins preparing in W state, which attains the Heisenberg-scaling accuracy. Our scheme combines the quantum multi-parameter estimation and the least square linear fitting method to achieve the quantum Cram{e}r-Rao bound (QCRB). We show that the estimated quantity achieves the Heisenberg-scaling accuracy. In single parameter estimation with assumption that the magnetic field is strictly linear, two optimal measurements can achieve the identical Heisenberg-scaling accuracy. Proper interpretation of the super-Heisenberg-scaling accuracy is presented. The scheme of quantum metrology combined with data fitting provides a new method in fast high precision measurements.