Added a scale and axis. Changed the way width and height are defined to include margins. Added all the text elements to a group so that other text elements (e.g. labels) wouldn't be selected when using selectAll().