The chart that you are showing is majorly based on team accomplishments rather than individual. Barcelona and Madrid have different playing styles and that is why Messi has more goals because his team always has more possession.
Ronaldo likes to play the counter game rather than possession playing style !! and don't make it an excuse please !! Blame Real Madrid for that !!