For the first time in history, renewable energy has produced more of the world's electricity than coal, according to a new analysis of global energy trends.