"From Pokémon X and Y onward, if at least one parent holds a Destiny Knot, the baby will inherit five IVs instead of three. This can be combined with an EV-enhancing item to select the IV that is transferred."
It was completely random which IV's were passed down, although it seems as though your Ditto's Attack and Special Attack were passed down and your Chimchar's Defense, Special Defense and Speed were passed down. That is of course if they had 31 IV's in these respective stats and the baby Pokémon also has 31 IV's in these stats. Since your Chimchar's HP IV wasn't passed down, it was generated a completely random IV.
Hope I helped :)