This is the code for Chapter 5, Figure 30 from D3.js in Action used to create a word cloud with semantically meaningfully word color and rotation using d3.layout.cloud() (a layout created by Jason Davies that does not come in core D3).
https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js