{
d3.select(container)
.selectAll('svg')
.remove();
var margin = { top: 250, right: 40, bottom: 250, left: 40 },
width = 960 - margin.left - margin.right,
height = 500 - margin.top - margin.bottom;
var x = d3.time
.scale()
.domain([new Date(2012, 0, 1), new Date(2013, 0, 1)])
.range([0, width]);
var xAxis = d3.svg.axis().scale(x);
var svg = d3
.select(container)
.append("svg")
.attr("width", width + margin.left + margin.right)
.attr("height", height + margin.top + margin.bottom)
.append("g")
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
svg
.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(xAxis)
.selectAll("text")
.attr("y", Math.abs(rotation - 90) / 5 + 10)
.attr("x", 15)
.attr("dy", ".5em")
.attr("transform", `rotate(${rotation})`)
.style("text-anchor", rotation < 30 ? "middle" : "start");
svg
.append("text")
.attr("y", -20)
.text(`${rotation}°`);
}