How to set the background-color of a D3.js svg?
Just add a <rect> as the first painting order item that displays the colour you want. var svg = d3.select(“body”).append(“svg”) .attr(“width”, width + margin.right + margin.left) .attr(“height”, height + margin.top + margin.bottom); svg.append(“rect”) .attr(“width”, “100%”) .attr(“height”, “100%”) .attr(“fill”, “pink”); svg.append(“g”) .attr(“transform”, “translate(” + margin.left + “,” + margin.top + “)”);